您好,登錄后才能下訂單哦!
--3d模型和3D動(dòng)畫的創(chuàng)建
require"Cocos2d"
local Sprite3DScene=class("Sprite3DScene",function()
return cc.Scene:create()
end)
--添加create函數(shù)
function Sprite3DScene:create()
local scene=Sprite3DScene.new()
scene:addChild(scene:init())
return scene
end
--添加構(gòu)造函數(shù)
function Sprite3DScene:ctor()
self.winsize=cc.Director:getInstance():getwinsize()
end
--添加初始化init()函數(shù)
function Sprite3DScene:init()
local layer=cc.layer:create()
local spobj=cc.Sprite3D:create("boss.obj")
spobj:setTexture("boss.png")
spobj:setScale(10)
layer:addChild(spobj)
spobj:setPosition3D(cc.Vertex3F(self.winsize.width/2,self.winsize.height/2,0))
local a1=cc.RotateBy:create(10,cc.Vertex3F(360,360,360))
local a2=spobj:runAction(cc.RepeatForever:create(a1))
--添加動(dòng)態(tài)模型
local spt=cc.Sprite3D:create("tortoise.c3b")
spt:setScale(0.1)
spt:setPosition3D(cc.Vertex3F(self.winsize.width/2,self.winsize.height/2-80,0))
layer:addChild(spt)
--創(chuàng)建3D動(dòng)畫
local animation=cc.Animation3D:create("tortoise.c3b")
local animate=cc.Animate3D:create(animation,0.4)
spt:runAction(cc.RepeatForever:create(animate))
return layer
end
return Sprite3DScene
代碼中調(diào)用的這些模型是從cocos2d-x-3.2中3D案例里面復(fù)制過來的。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。