--3d model and creation of 3D animations
Require "cocos2d"
Local Sprite3dscene=class ("Sprite3dscene", function ()
return CC. Scene:create ()
End
--Add Create function
function Sprite3dscene:create ()
Local scene=sprite3dscene.new ()
Scene:addchild (Scene:init ())
Return scene
End
--Adding constructors
function Sprite3dscene:ctor ()
SELF.WINSIZE=CC. Director:getinstance (): Getwinsize ()
End
--Add initialize init () function
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))
--Adding dynamic models
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)
--Create 3D animations
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
The models that are called in the code are copied from the 3D case in cocos2d-x-3.2.
This article is from the computer blog, so be sure to keep this source http://5152481.blog.51cto.com/5142481/1593205
Cocos2d-x adding 3d models to Lua to create 3D animations