Pixelguy Posted July 11, 2014 Share Posted July 11, 2014 Hey guys! It's been a while but I finally have some free time on my hand and decided to give Phaser another go.So with all the new fancy an new possibilities regarding physics I have a question for you guys. I am currently building a simple platformer. Current stage is mostly drawing assets designing levels etc. but I even did some prototyping today and ended up with my Top1 awkward platformer problem: As you might suspect I am using the arcarde physics and my player model (black thingie) is a simple sprite that gets stuck at the edge of the platform while moving up. So here is the Question:Should I stick with arcade all the way and slice my player into 2 smaller boxes (top and bottom part) that move along together (in case that's not a big no-no already) or should I use the new p2 physics for my player collision? All I want is to get rid of the awkward hitbox that comes with the sprite. The player will otherwise only collide with other enemy/item sprites where Arcade physic are more appropriate. :/ I did some research, checked the p2 examples and found this thread among others but couldn't find any examples that allowed me to get a arcade/p2 hybrid platformer running where the player collides with sprites handled by the arcade physics. I tried some approaches but it ended up not working.http://www.html5gamedevs.com/topic/4518-explaining-phaser-2s-multiple-physics-systems/ Do you have a hint or even a snipped for me on how to approach this problem? Greetings and thanks! Link to comment Share on other sites More sharing options...
lewster32 Posted July 11, 2014 Share Posted July 11, 2014 A good tradeoff may be to reduce the size of your hitbox so it only covers the tall middle part of the sprite, though it's not perfect - a triangular sprite like this is always gonna have issues with AABB collision. Link to comment Share on other sites More sharing options...
Pixelguy Posted July 11, 2014 Author Share Posted July 11, 2014 Good idea but that leads to some unexpected behaviour while standing on edges and looks somewhat strange overall. Link to comment Share on other sites More sharing options...
lewster32 Posted July 11, 2014 Share Posted July 11, 2014 I've never tried overlaying two bodies in a sprite before (you'd do this by using addChild to create two more null sprites inside the main sprite and use body.setSize on each to create probably a wide short rectangle to cover the 'feet' and then a tall one to cover the 'body') but I can't imagine Phaser would handle it well. I think your only realistic option is P2... Link to comment Share on other sites More sharing options...
Pixelguy Posted July 11, 2014 Author Share Posted July 11, 2014 But then I need to use p2 for each object I want the player to collide with right? Which is basically everything I spawn :/ Link to comment Share on other sites More sharing options...
Recommended Posts