I am currently building a game in which my main sprite is no other than… captain america! :smile:
To make him swing the enemies and walk to reck thanos(does he really?) I used a sprite sheet. So far so good, however now I want him to actually hit enemies. I was wondering how I can manage to detect the collision exactly. I can detect the bounding boxes collision with arcade physics, however I wanted to detect only when his fist hits the enemy. With pure JS I used a function to detect this pixel perfect collision, using the alpha value of each pixel. I was wondering if there was any way to do that in phaser.

(not colliding)


Thank you for your time!!

Usually, in game of this type, you must create a new hitbox (or a new Phaser Sprite) when the player execute a attack.

1 Like

How can I perform that?

Looks pretty cool. Have you looked at Physics Editor ( I think that along with matter.js can be what you need. There’s a cool example at:\physics\matterjs\advanced%20shape%20creation.js

I haven’t tried it yet, but might help you.

Take care,

Hello man. Thank you for your answer.

I actually have tried it out. It’s a nice feature, however I found myself having to change body physics all the time. I managed to do that(despite the lack of documentation and information about that), by using the setBody() function, passing as parameter the physics texture, the x and y(yea, you have to specify it too). This worked fine for texture changing, however not so great for my sprite position and gravity. Because it’s constantly modifying the x and y, the physics don’t have time to ‘act’ properly, so when I jumped with my sprite it looked a bit awkward. Moving left and right seemed to work just fine.

After that I found that I needed to also rotate my sprite body physics, because my sprite sheet only has one direction of the sprite, and when I want to rotate it on animation I just do a .setFlipX(true) and works like a charm. I was hoping there was a function like that for physics, but no, nothing. So I had to add body physics on every moving direction. More trouble… There’s when I decided to stop trying because I have a deadline for this project and if I keep messing around with this I think I will always have a stone in my shoe.

What I hope phaser creators do is to document and give more examples about this framework, because I felt like it wasn’t yet at the level of Arcade Physics and it has much more potencial.

Oh and also I hope that someone starts an opensource project like Physics Editor, because it is payed ^^

Any ideas, thoughts about this problem and experiencies with this framework are welcome to the discussion! Cheers

Hi amserra,

You say you wish for an open source editor like Physics Editor. I actually started an open source physics body editor called Physics Shaper. You can find it on GitHub here (, but you’re not able to export JSON properly yet. Right now I’m trying to figure out the format for Physics Editor, but also exploring programming my own parser. I started this project with the same frustrations for the lack of an open source 2D physics body editor. Hopefully you and others may be able to find value in the project once it’s up and going. :slight_smile: If anyone sees this thread and would like to contribute to the open source project, please feel free.

1 Like

@jaredyork such good news! That’s amazing. Definitely a project to keep an eye on. Best of luck!