----示例代码
local CANNON_TYPE_NORMAL = 1 --普通炮
local CANNON_TYPE_GOLD = 2 --能量炮
local CANNON_TYPE_SUPPER = 3 --超级炮
--鱼网类
local FishnetClass = class("FishnetClass", function ()
return cc.Sprite:create()
end)
function FishnetClass.create()
local fishnet = FishnetClass.new()
return fishnet
end
function FishnetClass:ctor()
self.normalNet = nil
self.goldNet = nil
self.superLaser = nil
--TODO 加载炮台网动画
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("pao_net.ExportJson")
self.normalNet = ccs.Armature:create("pao_net")
self.normalNet:setVisible(false)
-- self.normalNet:setAnchorPoint(cc.p(1,1))
self:addChild(self.normalNet)
--加载炮台网动画
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("pao_gold_net.ExportJson")
self.goldNet = ccs.Armature:create("pao_gold_net")
self.goldNet:setVisible(false)
self:addChild(self.goldNet)
--加载激光炮光柱
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("pao_super_fly.ExportJson")
self.superLaser = ccs.Armature:create("pao_super_fly")
self.superLaser:setPosition(cc.p(300,200))
self:addChild(self.superLaser)
end
function FishnetClass:PlayFishnetAnimation()
if CANNON_TYPE_NORMAL == GetCannonTypeSD() then
self.normalNet:setVisible(true)
self.normalNet:getAnimation():playWithIndex(0)
elseif CANNON_TYPE_GOLD == GetCannonTypeSD() then
self.goldNet:setVisible(true)
self.goldNet:getAnimation():playWithIndex(0)
end
end
return FishnetClass
--使用说明
--捕鱼网
self.fishnetClass = require("FishnetClass").create()
self:addChild(self.fishnetClass, 2)