Hello.
I have a case where I need to animate a character along with the background in a cutscene (he destroys part of the background).
Since I don't want to fiddle with pixel perfect placement of background animation and character animation separately in order to make them look good together, I decided to add the background animation to the character sprites (the character animation is only used in this cutscene anyway). As a result, the character's center is now shifted and it is still quite fiddly to avoid a jump effect between the two positions.
After a bit of deliberation, I am about to play the animation as an object instead of a character, since this easier to place (top left coordinates instead of character footpoint).
So I will hide the character and replace it with an object playing the animation of character and background. After that I will swap the two so I get the character back.
Is this the best way to do it?
I was looking for ways to robustly get the top left coordinate of a character but I can't figure out how.
Character sprites are positioned using their bottom center, so all you need to do is make the animation sprites wider so the character is centered again.
Example: character sprite is 35 pixels wide. Due to the animation, you have to add 40 pixels to the right. Character is now displayed shifted 20 pixels to the left in-game. Remedy: also add 40 (completely transparent, obviously) columns of pixels to the left.
(also Objects are positioned using *bottom* left corner.)
Thanks for the quick reply.
I was thinking about doing that but was worried (probably unnecessarily) about performance issues when adding a lot of empty space for no reason (always optimizin' ;)).
Also, what about rounding? I guess I have to make sure that all sprites have either even or uneven width to avoid unwanted one-pixel offsets, right?
Edit: But what about the bottom? The background animation extends below the character and I don't want to add blank space below my regular character animation.
Just in case I want to stick with the object solution since it may fit my workflow better, is there a cleaner way to get the top left corner of an object than this one?
object[3].Y = Game.SpriteHeight[Game.GetViewFrame(17, 0, 0).Graphic];