Transition not giving consistent x coords

Why isn't transition returning regular x coordinates? I'm trying to make a collision detection with the player(player.x) and a moving object(object.x) but the coord object.x is returning doesn't always match my non-moving player.x.
My player.x is locked at 120 since he isn't moving in X space, only Y but object.x sometimes return X as this:

Object X coord is: 125
Object X coord is: 124
Object X coord is: 123
Object X coord is: 122
Object X coord is: 121
Object X coord is: 119
Object X coord is: 118

and it varies. So it skips a few numbers. How come?

Oh, I might add that I'm using math.ceil to round the numbers up. I'm guessing that has something to do with it. If I don't round the numbers up I get object.x coords that look like this "120.16400146484" and that don't work with my collison detection since it has decimals.

obj.x = 100
transition.to(obj,{x= 300,time = 500})

from the above code (posted by me) i can say that in 500 miliseconds my object will travel from x= 100 to x= 300 not necessary that it goes from each and every point or pixel in its path not even necessary that it will follow the same points at each time i can only say that it will be at x = 300 after 500 miliseconds

got ??

so if you are trying to see x= 120 as per u thought you can not see that all time may be sometimes only you can get that position why u are not using physics for chking collision

Yeah, I understand that all transition is moving the object specified in the transition call. My guess is that if I divided the amount of x coords with the exact amount of time it has to move this distance, the numbers would be perfect. But what if the time is different? How can I then check collisions? Is there a way to let's say use this logic:

1
2
3
if object.x is somehwhere between 100-140 then
   print("COLLISION")
end

try something like this,

1
2
3
if math.abs(player.x - obj.x) < player.width*0.5 + obj.width * 0.5 and math.abs(player.y - obj.y) < player.width*0.5 + obj.width * 0.5 then
print("collision")
end

Thanks, I'll try that later on.

I tried something like this:

1
2
3
if object.x == player.x or object.x == player.x - 1 or object.x == player.x + 1 then
   print("HOUSECOLLISION")
end

if it is working and fulfilling ur requirement then very good go ahead

:)

Actually, it didn't work haha. It wasn't very accurate at all.
But... I tried some old collision detection I had which is basically what finefin said in this thread:
http://developer.anscamobile.com/forum/2011/09/05/make-hitbox-inside-newimage

Thanks for taking your time answering my question hgvyas123!

views:1335 update:2011/10/11 8:57:46
corona forums © 2003-2011