local size = cc.Director:getInstance():getWinSize() ---------------------------------------- ----Sprite3DBasicTest ---------------------------------------- local Sprite3DBasicTest = {} Sprite3DBasicTest.__index = Sprite3DBasicTest function Sprite3DBasicTest.onTouchesEnd(touches, event) for i = 1,table.getn(touches) do local location = touches[i]:getLocation() Sprite3DBasicTest.addNewSpriteWithCoords(Helper.currentLayer, location.x, location.y ) end end function Sprite3DBasicTest.addNewSpriteWithCoords(parent,x,y) local sprite = cc.Sprite3D:create("Sprite3DTest/boss1.obj") sprite:setScale(3.0) sprite:setTexture("Sprite3DTest/boss.png") parent:addChild(sprite) sprite:setPosition(cc.p(x,y)) local random = math.random(0, 1) local action = nil if random < 0.2 then action = cc.ScaleBy:create(3,2) elseif random < 0.4 then action = cc.RotateBy:create(3, 360) elseif random < 0.6 then action = cc.Blink:create(1, 3) elseif random < 0.8 then action = cc.TintBy:create(2, 0, -255, -255) else action = cc.FadeOut:create(2) end local action_back = action:reverse() local seq = cc.Sequence:create(action, action_back) sprite:runAction(cc.RepeatForever:create(seq)) end function Sprite3DBasicTest.create() local layer = cc.Layer:create() Helper.initWithLayer(layer) Helper.titleLabel:setString("Testing Sprite3D") Helper.subtitleLabel:setString("Tap screen to add more sprites") local listener = cc.EventListenerTouchAllAtOnce:create() listener:registerScriptHandler(Sprite3DBasicTest.onTouchesEnd,cc.Handler.EVENT_TOUCHES_ENDED ) local eventDispatcher = layer:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer) Sprite3DBasicTest.addNewSpriteWithCoords(layer, size.width / 2, size.height / 2) return layer end function Sprite3DTest() local scene = cc.Scene:create() Helper.createFunctionTable = { Sprite3DBasicTest.create, } scene:addChild(Sprite3DBasicTest.create()) scene:addChild(CreateBackMenuItem()) return scene end