as the demo in OneSidedPlatform.h of box2d source code.
and another question,how to determine whether the player is jumping onto some body or the player is smashed by some body falling from upside in the collision handler.
in other words,is it possible to get the force vector and force point during a collision?
Comments
https://sites.google.com/site/xraystudiogame
is that to say it's impossible to implement my game currently?
https://sites.google.com/site/xraystudiogame
thanks for reply.
you are right,maybe I could determine by the positions and velocity of the player and the objects
https://sites.google.com/site/xraystudiogame
Comparing the Y positions of the player and the object will tell you which one is higher than the other: if the players Y is (player radius + half platform height) less than platform Y, then the player is above and safe. You probably need to tune those numbers a little bit though.
Another way to do it is to use two collision fixtures, one for feet and one for head. That's what I do, in a skateboarding game with free rotation - anything at the feet is fine, anything at the head means death.
If you want to have the player take damage based on the impact of the collision, it might be easier to simply add the velocities involved (player + falling object) than use maxImpulse and do it in regular collision. Impacts, especially summed up, can be a bit... unpredictable, and in games it often gives better results to cheat and simplify.
It all depends on what you are aiming for. For instance, can the player collide with the falling object from the side? What happens then?
If your problem is more complicated than that, please elaborate.
Likes: atilim
by the way,I think move and rotate a movieclip using physics is not very convenient since the anchor point is not in the center. I can set the position of movieclip by using an offset to the body,but no way to set the rotation.
https://sites.google.com/site/xraystudiogame
mc:setPosition(-mc:getWidth()/2, -mc:getHeight()/2)
https://sites.google.com/site/xraystudiogame
http://www.emanueleferonato.com/2010/03/02/understanding-box2ds-one-way-platforms-aka-clouds/
The code there mentions to disable the contact. Is this somehow supported in Gideros?
Having access to the contact information and the ability to simply disable / ignore it if the ball is found to be on the correct side of the gate ( determined with a bit of vector maths as the gates could be arbitrarily oriented ) would be really useful.
At the moment I am left with trying to find another way to achieve the effect. Any suggestions?