--示例代码
local GoldCoinRoll = class("GoldCoinRoll", function(coinNum)
return cc.Sprite:create()
end)
function GoldCoinRoll.create(coinNum)
local goldCoinRoll = GoldCoinRoll.new(coinNum)
return goldCoinRoll
end
function GoldCoinRoll:ctor(coinNum)
self.coinNum = coinNum
self:init()
end
function GoldCoinRoll:init()
--精灵批量
local batch = cc.SpriteBatchNode:create("gold-coin.png")
batch:setPosition(0,0)
self:addChild(batch)
local num = self.coinNum / 2 + 1
for var=1, num do
local sprite = cc.Sprite:createWithTexture(batch:getTexture())
sprite:setPosition(5, var * 5)
batch:addChild(sprite)
end
--金币个数
local label = cc.Label:createWithTTF(tostring(self.coinNum), "fonts/Marker Felt.ttf", 20)
label:setPosition(5, num*5 + 15)
self:addChild(label)
end
return GoldCoinRoll
local coinList = require("GoldCoinRoll").create(coinNum)