local root = cc.CSLoader:createNode("SecondLayer.csb")事件
layer:addChild(root)get
self.sprite2 = root:getChildByName("Sprite_2")it
local timeline = cc.CSLoader:createTimeline("SecondLayer.csb");io
layer:runAction(timeline);event
timeline:setFrameEventCallFunc(function(dt)function
print(dt:getEvent()) -- 幀事件List
end)im
local startBtn = root:getChildByName("Button_1")timeline
local function startAction(sender,eventType)co
if eventType == 2 then
if sender:getTitleText() == "開始" then
sender:setTitleText("暫停")
timeline:gotoFrameAndPlay(0,true);
else
sender:setTitleText("開始")
timeline:gotoFrameAndPlay(5,false);
end
end
print(eventType)
end
startBtn:addTouchEventListener(startAction)