LinkSprite

Last Modified: 1/4/2021

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

Arguments

NameTypeRequiredDescription
Sprite Integer Yes Sprite is the variable you prepared with AddSprite().
LinkId Integer Yes This tells the VPD which sprite to draw next.

Example

Syntax: LinkSprite <Sprite>, <LinkId>
    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

Remarks

To stop drawing all sprites after the current Sprite, set LinkId to 0. You can use aS Sprite in the LinkId as well.

See Also

FreeSprite, FreeAllSprites, HideSprite, MoveSprite, PropSprite, ResizeSprite, ShiftSprite, AddSprite(), SpritePosX(), SpritePosY()