collision performance

q1)what is the difference in performance with global run time collisions compared with the below?

q2)what have bein and end phase as what is the difference?

q3) I need to alter properties in collision event but the docs say you should not? how do i alter properties etc in collision events

[lua]function myplayer:collision (event)
if ( event.phase == “began” ) then
if event.other.myName == “ground” then
print " hit the ground"
print (ground.y …" - " … myplayer.y)
end

end

end

myplayer:addEventListener(“collision”, myplayer)[/lua]
[import]uid: 138547 topic_id: 25413 reply_id: 325413[/import]

q1) Performance difference IIRC is negligible, it really depends on what you are trying to achieve as to what you are better off using. One global would be better than a large number of objects all listening for collisions and take less time to code, of course.

q2) Begin phase fires when collision begins, end phase is when collision ends.

q3) Alter properties in the ended phase. [import]uid: 52491 topic_id: 25413 reply_id: 102672[/import]

thanks for the replies

q1) I just saw this link as well

http://jonbeebe.tumblr.com/post/2515495262/corona-collision-no-no

q2) when I walk into a wall , I walk into the middle of the wall even though I specified a rectangle around my char image. How can I get a collision into a static body look more realistic [import]uid: 138547 topic_id: 25413 reply_id: 102684[/import]

@Jagguy999: You can use a third party program such as PhysicsEditor: http://www.physicseditor.de/

To create exact shape definitions. [import]uid: 84637 topic_id: 25413 reply_id: 102698[/import]

You may not need a custom shape if both objects are rectangular - use;
[lua]physics.setDrawMode ( “hybrid” )[/lua]
to check out body shapes and make sure they are correct.

If bodies appear to be sleeping and that is creating issues you can also set obj.isSleepingAllowed to false.

Peach :slight_smile: [import]uid: 52491 topic_id: 25413 reply_id: 102763[/import]

I see the rectangle around the char. YOu cant have an exact fit around the char for horizontal collisions or else the char will appear to walk into
walls and bounce back.

If I continually walk into a wall the began event only gets fired once. I gues this is to save from continually testing for collisions.
Is this correct?

[lua]if event.other.myName == “wall” then
if ( event.phase == “began” ) then
print " hit wall !"
elseif ( event.phase == “ended” ) then
print “end phase hit wall”
else
print “wall hit outside phases”
end

end[/lua] [import]uid: 138547 topic_id: 25413 reply_id: 102814[/import]

Please only hit the post/save button once and wait for it to load, don’t hit multiple times while you wait or it will dupe and can get flagged as spam.

You are correct re the event firing once. If you step away and back again the collision will reoccur. [import]uid: 52491 topic_id: 25413 reply_id: 102848[/import]

the post never appeared until now.
When I post at work I am not seeing the threads or replies so I have no idea what is being saved.

AT home this forum works fine. [import]uid: 138547 topic_id: 25413 reply_id: 102865[/import]

The post didn’t show up because it was marked as spam 3 or 4 times - I went in and cleared 3 of them and then marked the last one as not being spam :slight_smile: [import]uid: 52491 topic_id: 25413 reply_id: 102872[/import]