? Setting BG layer position ● SmileBASIC Source

Sign In

*Usernames are case-sensitive
Forgot my password
Space-Restriction Challenge QSP Phase Ends on March 26!

Setting BG layer position

You would expect that moving a BG layer works the same as moving a sprite. However, due to a bad decision by smileboom, this is not the case.

Use BGHOME to set the position of a background layer!

BGHOME layer, x, y
  1. Layer: the layer to move
  2. x,y: the location (in screen pixels) where the origin of the layer will be placed on the screen
BGOFS layer, x, y
  1. Layer: the layer to move
  2. x,y: the location (in BG pixels) of the origin on the bg layer
Most importantly, BGOFS cannot be used to precisely move a scaled BG layer! For example, say we scale it to 2x scale, and want to move the layer to (1,1) on the screen: ACLS BGPUT 0,0,1 BGSCALE 0,2,2 BGOFS 0,-1,-1This will move the layer to (2,2), not (1,1)! What if we use 0.5? BGOFS 0,-0.5,-0.5Unfortunately, this won't work either, because BGOFS only works with whole numbers. -0.5 is rounded to 0. Let's try BGHOME instead: BGHOME 0,1,1This works how you'd expect. The upper left corner of the background layer is now at (1,1) on the screen!
1 vote
0 Comment(s)