Hi,
I’m looking for the best Phaser way to implement a game character holding a weapon:
- the character is an animated sprite.
- the chosen weapon’s position must be kept in sync with the arms.
- see below: the character’s hands are actually part of the weapon’s sprite.
I’ve seen several approaches:
-
using a Phaser.GameObjects.Container
In this case, we subclass Container, and attach its children: character and weapon sprites. The weapon and sprite move well together as they remain relative to their parents. I’ve failed to add physics properly though - flipping horizontally creates a mess so far in my attempts. -
Creating separate sprites, syncing the absolute positions
Both sprites are attached to the parent scene. The character’s sprite is smart and keeps adjusting the weapon’s position.
Physics and flipping are much easier to handle, but unless the hands/weapons wielding data isn’t fit for symmetry, the X offset is based on being flipped or not. -
TBD
Maybe there’s a series of other approaches
What would be your recommendation to solve this?