Hey everyone 
I have this rocket in my game, and i have given it thrust (when you hold down the throttle, the speed gradually increase and when you let go, the speed decrease until you hit the ground again).
But now i want the rocket to be able to turn in mid air. (my background moves instead of the rocket). When the rocket is off the ground, i want to be able to rotate (turn) it so that it flies in different directions, while still accelerating (technically, the background moves in the different directions).
Ive tried a lot of things to try and do this but they dont really work.
Any ideas of how to do this?
Thanks 
[import]uid: 86598 topic_id: 14793 reply_id: 314793[/import]
Does your background only move two directions (left/right or up/down) or is it more like a large map? [import]uid: 52491 topic_id: 14793 reply_id: 54701[/import]
its more like a large map - so you can fly in all directions [import]uid: 86598 topic_id: 14793 reply_id: 54705[/import]
Oh OK, well if it’s just moving with the ship (or in the reverse when the ship moves) can you not adjust it’s speed relative to the speed of the ship’s thrust? If you are only making the ship appear to move by moving the background you could set an attribute the goes up the longer the thrust button is held and move the background by a multiple of that - then when the ship turns, change it. (You could use ship.rotation to tell which way it’s facing and proceed accordingly.) [import]uid: 52491 topic_id: 14793 reply_id: 54832[/import]
thanks i got it working
[import]uid: 86598 topic_id: 14793 reply_id: 54846[/import]
Very pleased to hear that! Look forward to seeing the finished product
[import]uid: 52491 topic_id: 14793 reply_id: 54929[/import]
@ shaunv1995
Would you mind sharing this little bit of code? I’m looking at doing something like this.
I just want to see how you applied thrust and how you were rotating? Is it something like apply force, and then increasing force with some kind of function or?
ng [import]uid: 61600 topic_id: 14793 reply_id: 55001[/import]
so basically, im moving the clouds to coincide with the players direction:
[code]
local isTouched
local speed = -0.7
function pressThrottle(event)
if event.phase == “began” then
isTouched = true
end
if event.phase == “ended” or event.phase == “cancelled” then
isTouched = false
end
end
throttle:addEventListener(“touch”, pressThrottle)
–spawn the clouds
function spawnClouds()
local cloud = display.newImage(“cloud.png”)
cloud.x = math.random(-500, 500)
cloud.y = math.random(-2000, 200)
physics.addBody(cloud)
cloud.isSensor = true
–move clouds when holding down throttle
function moveClouds()
if isTouched == true then
cloud:applyForce(speed * math.sin( math.rad(180 - player.rotation)), speed * math.cos( math.rad( 180 + player.rotation ) ), cloud.x, cloud.y )
end
end
timer.performWithDelay(1, moveClouds, -1)
end
timer.performWithDelay(1, spawnClouds, 50)
hope it helps
[import]uid: 86598 topic_id: 14793 reply_id: 55025[/import]