–[[
特效统一添加接口
]]–
function util.addEffect( parent,name,group,id,pos,ap,isblend,loop,fun )
if not parent then return end
if not name then return end
if parent:getChildByName(name) then return end
if not id then return end
if not util.isNumber(group) then
group = 4
end
local effectSprite = cc.Sprite:create()
local animate = cc.AnimManager:getInstance():getPlistAnimate(4, id, 4, 3)
effectSprite:setName(name)
if animate then
effectSprite:runAction(cca.repeatForever(animate))
end
if not isblend then
effectSprite:setBlendFunc({src=gl.SRC_ALPHA,dst=gl.ONE})
end
if pos and pos.x then
effectSprite:setPositionX(pos.x)
end
if pos and pos.y then
effectSprite:setPositionY(pos.y)
end
if not ap then
effectSprite:setAnchorPoint(cc.p(0.5,0.5))
end
if not pos then
local parentSize = parent:getContentSize()
effectSprite:setPositionX(parentSize.width * 0.5)
effectSprite:setPositionY(parentSize.height * 0.5)
end
parent:addChild(effectSprite)
return effectSprite
end
感谢各位,问题已解决。
