An easy but effective way to achieve 2D scrolling, is the use of 'Origin' command.
Origin x,y sets an x,y offset where the subsequent graphic commands will be drawn with.
In more detail, if you have a sprite that attempt to move after the upper left edge of the screen, then you could:
- draw the sprite at 0,0
- use origin command, and set the new offset for the next drawing commands; the amount of the x,y offset, is given by the x,y speed that you want to use to move your sprite - which is the same speed the backround would move at.
- draw the other stuff, for example background, and the other sprites; their drawing position will be automatically affected by the offsets set with the Origin command; that means, they will be translated in relation to the main sprite.
Hope this helps,
Sergio.
Origin x,y sets an x,y offset where the subsequent graphic commands will be drawn with.
In more detail, if you have a sprite that attempt to move after the upper left edge of the screen, then you could:
- draw the sprite at 0,0
- use origin command, and set the new offset for the next drawing commands; the amount of the x,y offset, is given by the x,y speed that you want to use to move your sprite - which is the same speed the backround would move at.
- draw the other stuff, for example background, and the other sprites; their drawing position will be automatically affected by the offsets set with the Origin command; that means, they will be translated in relation to the main sprite.
Hope this helps,
Sergio.