I know it sounds like a cryptic question but it’s been bothering for a while now.
I’m making some game, and the player has different Images that i use to give the illusion of Animation (when he walks, I rotate between 3 images, etc).
let’s say that now my player wants to attack to the right, attacking means extending the arm of the player to whatever desired location, (really its just using an image with the dude’s arm extended), naturally, since he’s extending his arm, i am now using a wider image.
(this is an example spritesheet so you can see what i’m talking about http://spritedatabase.net/files/nes/193/Sprite/TrevorC3.png)
if the dude’s attacking to the right, the arm is extended to the right, but there’s no problem, since i draw to the canvas from the top left coordinate of the Image (x coordinate).
however, if the dude’s attacking to the left, the arm is extended to the left, but there’s a problem, since i draw to the canvas from the top left coordinate of the Image (x coordinate), now the “body” of the dude is drawn a bunch of pixels to the right instead of staying where it was, it’s as if i were to try to punch something in front of me, but as i extend my arm, i walk backwards…
I’m not sure if i explained the problem… but can i get some help on this? I can clarify further if need be.
I kind of “fixed” this issue, essentially what i did was i looked at which animation image was displaying for that particular tick, and if it was one that made it extend its arm to the left i drew the character a few x pixels to the left… but it seems like a hack to me rather than a legit fix…
Thanks!