I tried to make camera move in vertical direction by referencing ghost&monster code.
But I am confused about how to use transition.to API. I read the document but still do not understand well.
my transtion.to API does not call onComplete event.
How can I make the camera to move(smoothly) when player moved to some specific distance?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | local physics = require("physics"); local player = require("player").new(); local camera = display.newGroup(); camera:insert(player); physics.addBody(player,{density = 0.1, friction = 0.1, bounce = 0.1}); local times = 0; function update() if(player.y > -320*times)then times = times +1; transition.to(camera, { time=1000, y = -320*times, onComplete=listener1 } ); end end local listener1 = function( obj ) print( "Transition 1 completed on object: " .. tostring( obj ) ) end Runtime:addEventListener("enterFrame",update); |