Angle of Image

I’m building a fairly simple space shooter game but I want projectiles to shoot at the angle my spaceship is rotated. Here’s a couple lines of my code to see what the image is and how it’s being rotated:

ship = display.newImageRect("ship.png", 78, 22) transition.to(ship, {rotation = 90, time=750, transition=easing.inSine})

Right now the game is using display.newImageRect but eventually I’m going to use a sprite sheet (once I get the art). To angle the ship I’m using transition.to, neither the player nor myself have direct control over that angle so I’m wondering how I can find the angle at any given time. I’ve looked in the api and did a google search but couldn’t find a function that returned an angle. Am I overlooking a function somewhere or do I have to approach the problem differently? The only thing I can think of right now is I’ll have to calculate the angle myself, and feed it to the ship…that way I’m the one who controls the angle of the ship so I’ll always know what angle the projectile needs to be fired.

Thanks in advance for any help.

Here’s a good tutorial on calculating firing angles between the enemy and the player. Oldie, but a goodie.

Also this should help :slight_smile:

http://developer.coronalabs.com/code/maths-library

Thanks for the links, they’ll probably help me within the next few days, however, my problem was finding the angle my image was already in, not changing it into something else. It turns out there’s a variable for that: rotation. The answer was so simple you guys probably thought I meant something else. I was using it the whole time in my transition but didn’t know it could be used to find the current angle. 

Here’s a good tutorial on calculating firing angles between the enemy and the player. Oldie, but a goodie.

Also this should help :slight_smile:

http://developer.coronalabs.com/code/maths-library

Thanks for the links, they’ll probably help me within the next few days, however, my problem was finding the angle my image was already in, not changing it into something else. It turns out there’s a variable for that: rotation. The answer was so simple you guys probably thought I meant something else. I was using it the whole time in my transition but didn’t know it could be used to find the current angle.