Jump to content

Press down to fall through platforms


z4srh
 Share

Recommended Posts

The latest Phaser tips email (http://www.photonstorm.com/phaser/phaser-coding-tips-3) made me start to think about platformer mechanics. I figured out that you can make the character jump through the bottom of some platforms by setting sprite.body.checkCollision.{up,down,left,right} appropriately. I've forked the example with this change here: http://jsbin.com/yahukuqufi/1/edit?js,output

 

My question is, how can I make it so that when the player presses down, it falls through some platform if the platform allows it. For example, when pressing down, suppose you're allowed to fall through ice platforms, but not grass platforms. I don't know that checkCollision is the right approach here, but it's unclear to me what to do. I suspect there's something I can do with the callbacks physics.arcade.collide.

Link to comment
Share on other sites

So I thought about that and doing other similar things, however it's not quite what I want - because if there's an enemy or other entity on the platform, I don't want them to fall through as well.

 

That gave me an idea though - I'll make two groups of platforms - one which I can fall through, and one which I cannot - and only check collisions against first group if the player isn't pressing down.

 

Thanks!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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