SecondBASIC Documentation v3

Home / Command Reference / LinkSprite

LinkSprite

Description: Changes the order (link) in which the VDP draws the sprites to the display.

Syntax:

LinkSprite <Sprite>, <LinkNumber>

Part Description
<Sprite> Required. <Sprite> is the variable you prepared with AddSprite().
<LinkNumber> Required. This tells the VPD which sprite to draw next. To stop drawing all sprites after the current sprite, set this argument to 0. You can use other <Sprite>'s in this argument as well.

Example:

    SpriteA = AddSprite(1,1)
    PropSprite SpriteA,1,0
    SpriteB = AddSprite(1,1)
    PropSprite SpriteB,2,0
    SpriteC = AddSprite(1,1)
    PropSprite SpriteC,3,0
    SpriteD = AddSprite(1,1)
    PropSprite SpriteD,3,0
    Palettes Pal,0,0,16
    LoadTiles Tiles,3,1
    MoveSprite SpriteA,130,130
    MoveSprite SpriteB,134,134
    MoveSprite SpriteC,138,138
    MoveSprite SpriteD,200,200
 
    Sleep 100
 
    ' SpriteA's LinkID = 0
    ' SpriteB's LinkID = 1
    ' SpriteC's LinkID = 2
    LinkSprite SpriteA,SpriteC    ' Set SpriteC to be drawn after SpriteA
    LinkSprite SpriteC,SpriteB    ' Set SpriteB to be drawn after SpriteC
    LinkSprite SpriteB,0        ' Tell the VDP to stop drawing sprites
 
Pal:
    DataInt $0000,$0EEE,$0AAA,$0888,$0000,$0000,$0000,$0000
    DataInt $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
 
Tiles:
    DataLong $22222222
    DataLong $22222222
    DataLong $22222222
    DataLong $22222222
    DataLong $22222222
    DataLong $22222222
    DataLong $22222222
    DataLong $22222222
Tile2:
    DataLong $11111111
    DataLong $11111111
    DataLong $11111111
    DataLong $11111111
    DataLong $11111111
    DataLong $11111111
    DataLong $11111111
    DataLong $11111111
Tile3:
    DataLong $33333333
    DataLong $33333333
    DataLong $33333333
    DataLong $33333333
    DataLong $33333333
    DataLong $33333333
    DataLong $33333333
    DataLong $33333333