Jump to content

i made a jump-through-from-below moving-platform with P2 - your thoughts please


valueerror
 Share

Recommended Posts

here is the testcase:  http://test.xapient.net/phaser/ALL/jumpthrough.html

 

i made two versions of the checkOverlap() function..  in the second (commented out atm) i check in both ways but specially for the player velocity.. this leads to situations where the player velo is not enough anymore when "inside" the platform and bounces back really fast..

 

the first version somehow baffles me..   if the fist body is my player he always is moving UP.. therefore no further checks are needed.. i just let him through...  BUT i honestly don't know the implications of that.. it's definitely not field tested :)

 

the moving platforms would also work with a simple tween where i tween the velocity but with my custom function and some predefined attributes (bounds, velocity) that can also be configured in tiled so every platform already knows where to move, this is more precise..

 

@rich..  if this would be somehow suitable as an example feel free to copy/adapt/rewrite the code  

 

 

a small piece of the code:

 

 game.physics.p2.setPostBroadphaseCallback(checkOverlap1, this);
function checkOverlap1(body1, body2) {    if (body1.sprite.key === 'mario' && body2.sprite.key === 'platform'){ return false; }  //for some reason if mario is body1 not body2 he is moving from below - thats all we need to find out to let him through    return true;}function checkOverlap2(body1, body2) {    if (body1.sprite.key === 'mario' && body1.velocity.y > 0 && body2.sprite.key === 'platform'|| body2.sprite.key === 'mario' && body2.velocity.y > 0 && body1.sprite.key === 'platform'){ return false; }  // this checks if mario is jumping    return true;}
Link to comment
Share on other sites

mmmm, in the demo with materials I add this game.add.tween(platformH.body.velocity).to({ x: '+100' }, 2000,Phaser.Easing.Back.Out).to({x:'-100'}, 2000,Phaser.Easing.Back.Out).yoyo().loop().start();

,I think it works well

Link to comment
Share on other sites

i do the exact same thing in this example..  

http://www.html5gamedevs.com/topic/1813-the-monthly-phaser-examples-contest/?p=31436

 

but the problem with this approach is that you can not easily define the distance the object will move..  distance is speed (tweened speed) * time   so it is hard to determine where the object will turn...

Link to comment
Share on other sites

mmm calculate the position would not have much trouble,ehh about this function "checkOverlap1" I would say that using materials or collisionGroup, would avoid making such checks, but for now I'm trying to simulate some of the methods Arcade Physics,you've tried?

Link to comment
Share on other sites

how would you use materials or collision groups to make a platform where you can jump through from below but land on from above..  i don't see any way to accomplish this..  could you lighten me up a little?

 

i am working with arcade physics too..   these platforms are easily made in arcade because you are allowed to define a custom collision handler every time you set up a new collision.. if this one returns true a collision will happen.

 

game.physics.arcade.collide(player, platform, null, customHandler);

Link to comment
Share on other sites

jejej yeah, that I know ...ehh the arcade physics is very useful and practical to start with some basic physics is well, so I'm trying to do the same but in p2 physics.mmm.. for the type of platform do not need it, but let me and I try.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...