How to move sprite and his body?

I think it’s not…

in heroe.js : import meleeWeapons from '../objects/meleeWeapons'

Edit : I try, nothing have changed :frowning:

Hi @Nik0w,
After some tests, i have found a solution:
In your class Heroe add this preUpdate method:

preUpdate(){
    this.weapon.updatePosition(this);
  }

So, now in your class melleWeapon you don’t need the listeners for “pointermove” and “update” events.
Seems it was a timing problem with inputs or physics, I’m not sure.
Regards.

2 Likes

OH GOD !

It’s workinnnnnng !!!
Thank you so much !!!

How do you find this solution ??

This is my logic:
The updatePosition() worked when called from the ‘pointermove’ listener (run in preupdate), whereas when called from the update() of the Hero class while sprite was moving, it didn’t. So I assumed that the new hero position was being calculated in the postupdate and the updatePosition() was receiving old data.
But maybe it was just lucky. :grinning:

1 Like

I will never find myself so big thanks again !!

Now I have my player’s animations doesn’t work but I will try to fix it … :wink:

For the animation on a extended sprite class you need:

preUpdate(time, delta) {
    super.preUpdate(time, delta);
}
1 Like

Perfect ! Thank you !!
I will show you the result :wink:

Have a nice day and great thanks