How to move the coordinates of an object on collision.

Hello I need to know how to make the coordinates of an object on collision. If you have an idea that would be great. Thanks! [import]uid: 44060 topic_id: 8673 reply_id: 308673[/import]

COULD SOMEONE HELP PLEASE:) [import]uid: 44060 topic_id: 8673 reply_id: 32574[/import]

Not sure how u want it done, but you can use transition.to or use the Run time.

[lua]local object

local oncollide = function (event)
if event.phase == “began” then
local moveTran = transition.to(object, {time=1000, x=200, y=160})
end
end

object = display.newRect(0,0,50,50)
object.x = 50
object.y = 50
object:setFillColor(255,255,0,255)
Object.collision = on collide

– maybe this might help. I haven’t tested this. [import]uid: 12455 topic_id: 8673 reply_id: 32585[/import]

No im sorry but that didnt quite do the trick but what im looking for is that when a balloon gets close to another balloon it changes corridenets and moves away or into the other balloon. Any ideas. [import]uid: 44060 topic_id: 8673 reply_id: 32742[/import]

In your collision function you can change coords instantly.

Say that you wanted the red balloon’s coords to change, inside your function simply say;

[lua]redballoon.x = 100
redballoon.y = 100[/lua]

Obviously replacing “100” with your own coordinates.

Is that what you are wanting to do? When you say you want to “make the coordinates” I’m not totally sure.

Peach [import]uid: 52491 topic_id: 8673 reply_id: 33439[/import]

try applyforce or impulseforce. Unless you want the balloon to move at a constant speed, then you’ll have to use Runtime or transition.

hope this help. [import]uid: 12455 topic_id: 8673 reply_id: 33685[/import]

Hello

I’ve been trying to do the same thing - but with little success:

http://developer.anscamobile.com/forum/2011/04/22/function-causes-crash

Peach, that doesn’t work - I get the following error message:

“ERROR: Cannot translate an object before collision is resolved”

There are quite a few posts about this not working on the forums - so I’m stuck at the moment! ;-( [import]uid: 45932 topic_id: 8673 reply_id: 33818[/import]

I would suggest trying a short timer before attempting to perform the function, I had to add a timer to my Space Shooter template which I imagine may have been similar to your issue. (Not that I can say for sure, but it sounds it.)

If you cannot get it to work and cannot find an answer, I do offer paid support (separate from and not associated with Ansca) via my website, http://Techority.com.

Often I find the solution is just to test, change a little, test, change a little, etc.

However, timers frequently seem to fix this sort of issue :slight_smile:

Peach [import]uid: 52491 topic_id: 8673 reply_id: 33829[/import]