您好,登錄后才能下訂單哦!
1. 加載 節(jié)點(diǎn)到場(chǎng)景
第一種方法
local scene = cc.CSLoader:createNode("scene.csb")
self:addChild(scene)
第二種方法
local scene = cc.uiloader:load("MainScene.csb"):addTo(self)
2.強(qiáng)轉(zhuǎn)精靈類型
local sprite = tolua.cast(object,"cc.Sprite")
CocoStudio 做的里面的精靈是 CCSprite (c++里面的)類型 不能使用 setPosition 等 一些 Lua 里面的方法 需要 使用 tolua.cast(object,type)進(jìn)行強(qiáng)制轉(zhuǎn)換類型
3.按鈕不一樣的使用方法
local btn = scene:getChildByName("Button_1")
btn:addTouchEventListener(function (event,type)
if type == ccui.TouchEventType.began then
print("began")
end
if type == ccui.TouchEventType.ended then
print("ended")
end
end)
4. 動(dòng)畫 (播放時(shí)間軸)
local timeline = cc.CSLoader:createTimeline("MainScene.csb");
scene:runAction(timeline);
timeline:gotoFrameAndPlay(0,true);
timeline:setFrameEventCallFunc(function(dt)
print(dt:getEvent()) -- 幀事件
end)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。