--3d模型和3D动画的创建
require"Cocos2d"
local Sprite3DScene=class("Sprite3DScene",function()
return cc.Scene:create()
end)
function Sprite3DScene:create()
local scene=Sprite3DScene.new()
scene:addChild(scene:init())
return scene
end
function Sprite3DScene:ctor()
self.winsize=cc.Director:getInstance():getwinsize()
end
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))
--添加动态模型
local spt=cc.Sprite3D:create("tortoise.c3b")
spt:setScale(0.1)
spt:setPosition3D(cc.Vertex3F(self.winsize.width/2,self.winsize.height/2-80,255);">layer:addChild(spt)
--创建3D动画
local animation=cc.Animation3D:create("local animate=cc.Animate3D:create(animation,0.4)
spt:runAction(cc.RepeatForever:create(animate))
return layer
end
return Sprite3DScene