z4srh Posted January 25, 2015 Share Posted January 25, 2015 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 More sharing options...
tips4design Posted January 25, 2015 Share Posted January 25, 2015 Note, I never used Phaser before. I think you can do that by setting body.enable = false; to your platform group while the down arrow is pressed. (or just to the closest platform)http://docs.phaser.io/Phaser.Physics.Arcade.Body.html#embedded z4srh 1 Link to comment Share on other sites More sharing options...
z4srh Posted January 26, 2015 Author Share Posted January 26, 2015 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 More sharing options...
Recommended Posts