Transiton.to Quesiton...

I have a few questions. I'm using transiton.to to basically power everything in my game and I have a projectile launching from the center left of the screen at various objects at different locations coming from the right of the screen.

My Questions:

1. I'm trying to think of a way to have my projectiles point to the objects. I suck at math so does anyone know the equation to get the angle from one position to the next?

2. Is there a way to give an arch a transition without using a bezier curve. Much like the TweenMax plugin for Flash.

Thanks in advance.

As far as your first question goes here is code I use which I pulled from the Ghosts Vs Monsters example app.

1
2
-- Formula: 90 + (math.atan2(y2 - y1, x2 - x1) * 180 / PI)
local angleBetween = mCeil(mAtan2( (object2.y - object1.y), (object2.x - object1.x) ) * 180 / mPi) + 90

Thanks for that.. The only problem is that when I set the rotation of my object to that angle it is not pointing toward my second object. Am I not supposed to be applying that to my rotation?

Sorry, I forgot the last part. Here it is in it's entirety.

1
2
3
4
5
6
7
local mCeil = math.ceil
local mAtan2 = math.atan2
local mPi = math.pi
local mSqrt = math.sqrt
-- Formula: 90 + (math.atan2(y2 - y1, x2 - x1) * 180 / PI)
local angleBetween = mCeil(mAtan2( (object2.y - object1.y), (object2.x - object1.x) ) * 180 / mPi) + 90
object1.rotation = angleBetween

That worked perfectly! Thank you. I just had to remove the +90 from the last portion and it worked perfect.

views:1327 update:2011/9/28 8:56:32
corona forums © 2003-2011