I’m want to move a bullet with transition to an certain angle… eg 30º, 70º, 150º, 270º
someone knows how can I apply this with transition?
transition.to( object, { time = 1000, x = ?, y = ? } )
Thanks
I’m want to move a bullet with transition to an certain angle… eg 30º, 70º, 150º, 270º
someone knows how can I apply this with transition?
transition.to( object, { time = 1000, x = ?, y = ? } )
Thanks
This should help… you need to use the proper formula to figure out the X and Y.
http://www.csgnetwork.com/trigtriformulatables.html
Brent
I really don’t know how to use it :S
I need to knows how to make a fixed angle like 30º with an X and Y given
eg.
object.x = 50
object.y = 30
angle30 = ?
Found it!
I search a little bit more and I find how to do this…
local anguloX = math.cos( math.rad( 30 ) ) local anguloY = math.sin( math.rad( 30 ) ) bullet.transition = transition.to( bullet, { x = anguloX, y = anguloY, time = bt, onComplete = remove\_bullet} )
hope this help someone else that have the same question that I did
Thanks
question… why it only goes to the same direction??
if I change the rad value, it still going to top left corner :S
local anguloX = math.cos( math.rad( 180 ) ) local anguloY = math.sin( math.rad( 180 ) )
and there’s a way to move the bullet 30º of my tower instand 30º of device ?
something like that
tower1.x = 50 tower1.y = 50 tower2.x = 300 tower2.y = 300 local anguloX = tower1.x + math.cos( math.rad( 30 ) ) local anguloY = tower1.y + math.sin( math.rad( 30 ) ) local anguloX = tower2.x + math.cos( math.rad( 30 ) ) local anguloY = tower2.y + math.sin( math.rad( 30 ) )
The problem with this is: you’ve used the angle the bullet needs to travel in, but not how far it must go. math.sin and math.cos give you the horizontal and vertical distance the bullet must travel to reach a displacement defaulting to 1 pixel. The values of math and cos are always between 0 and 1, so now you’re adding something like 0.3 to the tower1.x That means the bullet will seem stuck on the origin, in your case the left corner.
You need to multiply the angle with the distance you want the bullet to travel. For example:
<code>local anguloX = tower1.x + math.cos(math.rad(30))*300 </code> for a 300 pixel diagonal displacement at 30 degrees
This should help… you need to use the proper formula to figure out the X and Y.
http://www.csgnetwork.com/trigtriformulatables.html
Brent
I really don’t know how to use it :S
I need to knows how to make a fixed angle like 30º with an X and Y given
eg.
object.x = 50
object.y = 30
angle30 = ?
Found it!
I search a little bit more and I find how to do this…
local anguloX = math.cos( math.rad( 30 ) ) local anguloY = math.sin( math.rad( 30 ) ) bullet.transition = transition.to( bullet, { x = anguloX, y = anguloY, time = bt, onComplete = remove\_bullet} )
hope this help someone else that have the same question that I did
Thanks
question… why it only goes to the same direction??
if I change the rad value, it still going to top left corner :S
local anguloX = math.cos( math.rad( 180 ) ) local anguloY = math.sin( math.rad( 180 ) )
and there’s a way to move the bullet 30º of my tower instand 30º of device ?
something like that
tower1.x = 50 tower1.y = 50 tower2.x = 300 tower2.y = 300 local anguloX = tower1.x + math.cos( math.rad( 30 ) ) local anguloY = tower1.y + math.sin( math.rad( 30 ) ) local anguloX = tower2.x + math.cos( math.rad( 30 ) ) local anguloY = tower2.y + math.sin( math.rad( 30 ) )
The problem with this is: you’ve used the angle the bullet needs to travel in, but not how far it must go. math.sin and math.cos give you the horizontal and vertical distance the bullet must travel to reach a displacement defaulting to 1 pixel. The values of math and cos are always between 0 and 1, so now you’re adding something like 0.3 to the tower1.x That means the bullet will seem stuck on the origin, in your case the left corner.
You need to multiply the angle with the distance you want the bullet to travel. For example:
<code>local anguloX = tower1.x + math.cos(math.rad(30))*300 </code> for a 300 pixel diagonal displacement at 30 degrees