I essentially want to rotate my rocket both clockwise and anti clock wise and have its x and y adjusted in order to move in the direction its facing when the thrust button is pressed
I’ve tried numerous ways and am getting caught up in the equations and how to implement them, see my code below (feel free to laugh if its way off the mark)
[code] local rocket = display.newSprite( rocketsheet, rocketsequencedata)
physics.addBody(rocket, { bounce = 0.5} )
rocket.x = display.contentWidth/3
rocket.y = display.contentHeight/1.5
rocket.rotation = angle
rocket:setSequence(“idle”)
rocket:play()
local inverseRotation = rocket.rotation + math.pi
local speedX = 0.000
local speedY = 0.005
speedX = speedX * math.cos(inverseRotation) + speedY * math.sin(inverseRotation)
speedY = -speedX * math.sin(inverseRotation) + speedY * math.cos(inverseRotation)
function thrust(event)
rocket:applyLinearImpulse(speedX, speedY, rocket.x, rocket.y)
rocket:setSequence(“afterburn”)
rocket:play()
end
function rotateleft(event)
speedX = speedX - 0.0005
rocket.rotation = rocket.rotation - 2
end
function rotateright(event)
speedX = speedX + 0.0005
rocket.rotation = rocket.rotation + 2
end
controlthrust:addEventListener( “touch”, thrust)
controlleft:addEventListener( “touch”, rotateleft)
controlright:addEventListener( “touch”, rotateright) [/code]
Frustration isn’t even the word I’m feeling right now [import]uid: 166613 topic_id: 33023 reply_id: 333023[/import]