How to update an Arcade body?

Recommended Posts

Hello, I'm doing a fighting videogame and I'm using Arcade Physics. since it's not possible to use multiple bodies with Arcade I'm trying to figure out how to update the bodies of my charecter (for complex positions I'll use more than 1 body to make it) once a key is down and when is up go back to the idle body.

One of the possibilities I had in count and I tryied witout success is checking the current frame animation and adding some new invisible sprites like collliders and destroying it after the next frame. The first problem I had with it is that working on Update function it creates me a lot more extra sprites that waste resources, and had no success deletting it once the frame changes, I used this code:

 if ( == 'attack') {
            this.p = game.add.sprite(,, 'feet');

        if (this.p != undefined && != "ataque_1"){


The second possibility but I did not try is adding all the sprites I need to the player group and when I need it "activate" it with some property and check collisions with those invisible sprites, but I think will require a lot of resources that are no need it because there are a lot of animations and almost each animation needs +2 sprites for it, or if it can be another more efficent way to do this I don't know it yet.


If anyone can help contributing another technique I could usem any idea or any help to do what I got in mind I'll be glad for it.


Share this post

Link to post
Share on other sites

You don't need to add sprites during update for that. You can try adding the relevant child sprites during create, then enable their physics bodies for some frame:

You could do the same using A group.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.