LoginLogin
Might make SBS readonly: thread

SPLINK

Root / Documentation / [.]

Created:
Link a sprite to a parent, set link flags, and check link relationships. A sprite can be linked to any sprite with an ID less than its own. This sprite is now the "child" of the other sprite (which makes the other sprite the parent.) A child can only belong to one parent, but a parent can have multiple children. The coordinate system of the children (including the Z coordinate) is now relative to the parent's (specifically the parent sprite's SPHOME.) For example, given the below code, sprite 1 is actually at 20,20 on-screen, because sprite 0 is at 10,10.
'create sprites
SPSET 0,0
SPSET 1,1
'make 1 a child of 0
SPLINK 1,0
'move the sprites
SPOFS 0,10,10
SPOFS 1,10,10
The child coordinate system is also affected by the parent's SPSCALE and SPROT. For example, SPSCALE 0,2,2 causes the child to be twice as far away from the parent, and SPSCALE 0,45 causes the child to rotate 45 degrees around the parent. By default, these coordinate system transformations do not affect the actual display properties of the children, just their position. By setting link flags, children can inherit their show/hide state, rotation, scale, color, and layer from their parent.

Link

Link a child to a parent, optionally setting link flags.
SPLINK childID%, parentID% {, linkFlags% }
InputDescription
childID%ID of the child sprite. 0-4095.
parentID%ID of the parent sprite. 0-4095. parentID% must be less than childID%.
linkFlags%Optional bitset specifying properties to inherit from the parent.
BitDescription
1SPSHOW/SPHIDE/SPCLR
2SPROT
4SPSCALE
8SPCOLOR
16SPLAYER
If the SPSHOW flag is set, then the child sprite will be cleared the frame after the parent is cleared with SPCLR.

Check

Check the link relationships of a sprite, or link flags.
SPLINK spriteID%, linkType% OUT linkValue%
InputDescription
spriteID%ID of the target sprite.
linkType%Type of link information to get. Optional, default 0.
TypeDescription
0ID of parent sprite.
1ID of first child sprite.
2ID of next sibling sprite.
3Link flags of this sprite.
OutputDescription
linkValue%Link information. If parent, child, or sibling were checked, the appropriate sprite ID (or -1 if there is no link relationship) is returned. If link flags were checked, the link flags of the target sprite (or 0 if unset) are returned.

Examples

'link sprite 1 to sprite 0
SPLINK 1,0
'get the parent of sprite 1, and the first child of sprite 0
PRINT SPLINK(1)
PRINT SPLINK(0,0)

No posts yet (will you be the first?)