LoginLogin

Setting BG layer position

Root / Submissions / [.]

12Me21Created:
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
  • Layer: the layer to move
  • x,y: the location (in screen pixels) where the origin of the layer will be placed on the screen
BGOFS layer, x, y
  • Layer: the layer to move
  • 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,-1
This will move the layer to (2,2), not (1,1)! What if we use 0.5?
BGOFS 0,-0.5,-0.5
Unfortunately, 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,1
This works how you'd expect. The upper left corner of the background layer is now at (1,1) on the screen!

No posts yet (will you be the first?)