Sawyer Posted May 14, 2016 Share Posted May 14, 2016 I have a sprite sheet of my games playable character. The frames consist of all possible actions the character can do, including two different attacks. I want to change the physics bounds on different animations as my sprites positioning obviously changes with different animations. I got PhysicsEditor expecting it could handle this but as far as I can see, it only works for single images. Is there any solutions for this to help me get near pixel perfect collision? Any help is appreciated as always Link to comment Share on other sites More sharing options...
Taggrin Posted May 15, 2016 Share Posted May 15, 2016 I never tried it myself, but this is one possible solution I can come up with (if there are way better options in Phaser, please post below). You can put multiple JSON strings with different names in one file. One string for each hitbox for each frame you have within your animation. Then for each frame you can just load in a new hitbox matching the frame. Then you can set up something like this (I assumed you use P2JS): objectName.body.clearShapes(); if (currentAnimation == "walk") { objectName.body.loadPolygon(loadedJSONFileName, walkHitboxName); } else if (currentAnimation == "fight") { objectName.body.loadPolygon(loadedJSONFileName, fightHitboxName); } Of course your version will be more complicated, as you have to deal with multiple frames within one animation, but I guess this should get you going . Link to comment Share on other sites More sharing options...
Sawyer Posted May 15, 2016 Author Share Posted May 15, 2016 Thanks Taggrin, I'll give it a try! my main problem is that my walking animation is much narrower than my attack one, so it was putting collision way off when walking into walls and stuff but your way definitely sounds promising Link to comment Share on other sites More sharing options...
Recommended Posts