#168819 - Tommmie - Wed May 27, 2009 8:32 pm
ok, so I was coding on my game and i came across this problem: when i position a sprite on x = 300 for example i can't view it at the beginning. how can i scroll the sprite system? i mean that sprites placed on x = 0 wille disappear at a specific moment and the sprite at x = 300 will be visible?
Last edited by Tommmie on Thu May 28, 2009 3:26 pm; edited 1 time in total
#168833 - gauauu - Thu May 28, 2009 2:54 pm
To elaborate on what Emmanuel said:
The position of your sprite is always it's real screen position, not scrolled. So for your in-game characters, you should store their world position separately, and then each frame, update the sprite positions based on where the world is scrolled to.
If the character is offscreen, you'd want to make sure not to show a sprite for it. (Either hide or disable the sprite, or don't have a sprite allocated for that character).
In general, you really need to have a separate layer for logical characters than for hardware sprites, to deal with things like this.
#168835 - Tommmie - Thu May 28, 2009 3:25 pm
thanks i got it(easy, how could i be so stupid?). fast replies also, thanks gauauu and emmanuel