local rocket = display.newImageRect( "spriteFolder/set\_10.png",16,16 ) rocket.x = 8 ; rocket.y = 296 rocket.myName = "rocket" physics.addBody( rocket, "static") local square = display.newRect( 435, 25, 50, 50 ) ---------------------- local touchStarted = false local moveRocket = function(event) local function moveRight( ) if touchStarted then local xx = rocket.x local xx = xx+16 print("in functon".."--xx = "..xx) transition.moveTo( rocket, { x=xx, y=296, time=50, onComplete } ) end end if event.phase == 'began' then touchStarted = true elseif ( event.phase == "ended" ) then touchStarted = false end timer.performWithDelay(100,moveRight,0) end square:addEventListener( "touch", moveRocket )
im trying to create a function that moves a rocket object left and right, im currently working on moving right…the idea is to start at x = 8, when you press and and hold a button it will add 16 and move to, althought it is running to fast through the process… i think i should be using oncomplete, but im at a loss how to incorporate this into my function.