Physics Body - like in Doodle jump

Hello,

i want to create a character that jump a paddle like in Doodle Jump. but when i try the character hits the bottom paddle. how can i create effects like character in Doodle Jump, that has collision whithout hit the paddle when he jump from bottom. but can stand in the paddle :smiley: [import]uid: 7427 topic_id: 3996 reply_id: 303996[/import]

“As of Alpha 3, any collision event handler that returns true will stop further propagation of that collision event, even if there are further listeners that would otherwise have received it”

try that. might work [import]uid: 6645 topic_id: 3996 reply_id: 12119[/import]

Turn off collisions until your character is “falling”. This will allow doodle jump behavior. Keep it on for things you can hit going up and down. ie monsters or powerups.

[import]uid: 9827 topic_id: 3996 reply_id: 12125[/import]

hai, do you have any simple sample…
i’m newbie :smiley: i just know Corona, but never try it. just known it for less than a month :smiley: [import]uid: 7427 topic_id: 3996 reply_id: 12138[/import]

well i just figure it out, but i try to code :smiley: [import]uid: 7427 topic_id: 3996 reply_id: 12142[/import]

guessing here but try
setting up a precollision handler then saying

[lua]local obj1=event.object1
local obj2=event.object2
if(obj1.is == “platform” and obj2.is == “player” and obj2.y < obj1.y) then
return true
end[/lua]

Note “.is” is just a custom variable assigned to an object at creation. You can call this what you want

You might also need to test when obj1 and obj2 are swapped ie the other half of the collision event pair

[import]uid: 6645 topic_id: 3996 reply_id: 12144[/import]

i try this, and it doesn’t work. is it a bug or something wrong in the code… :frowning:
well let’s find a new way :smiley: :smiley: :smiley: [import]uid: 7427 topic_id: 3996 reply_id: 12170[/import]

I have not test this but here is what I will do, so hope it helps:

  1. First you will have to use the collision categories for your objects (see http://developer.anscamobile.com/content/game-edition-collision-detection) So you will have two filters for your main jumper character and other category filter for all the platforms.

For example:

local PlataformeCollisionFilter = { categoryBits = 1, maskBits = 1 }
— platform only collides with objects with category bit equal to 1

local JumperHallowCollideFilter = { categoryBits = 2, maskBits = 2 }
— jumper will collide only with objects category 2 only

local JumperCollideFilter = { categoryBits = 2, maskBits = 3 }
— jumper will collide only with objects category 1 and 2

  1. When creating the objects (jumper and platforms) add a name to the object:
    plataform.myName = “plataform”
    jumper.myName= “jumper”

  2. Use the “preCollision” event to detect when a collision is about to happen. The preCollision event will give you the two objects that will be collide.

  3. The “preCollision” event will give you the two objects that will collide. So you can check their names to see if one is the jumper and the other is the platform (or viceversa) (this is only if you have more objects that will collide with the jumper like bonus objects or coins etc.

local function onPreCollision( event )
if ( event.phase == “began” ) then

if (event.object1.myName == “platform” and event.object2.myName==“jumper” ) then

— do here the magic with object 1
end
if (event.object1.myName == “jumper” and event.object2.myName==“platform” )) then

— do here the magic with object 2

end
end
end
5) Now you will only need to identify the platform object. With this object you will get his linear velocity x,y = event.object1:getLinearVelocity()

  1. Check the value of y . If y is >0 is going down if y<0 is going up (or viceversa dont remember which is up or down but you try it)

  2. If you detect that the y points up that means that the jumper is going up and you will change the jumper collision filter to JumperHallowCollideFilter and if it’s going down you will change it to local JumperCollideFilter

  3. The collision event will trigger after the preCollision so when it does your jumper will collide with the platform or pass thru it.
    [import]uid: 9975 topic_id: 3996 reply_id: 12214[/import]