SpriteDisplay.sprites

From MiniScript Wiki
Revision as of 01:37, 14 May 2025 by FernandoNoise (talk | contribs) (Fixed method call syntax(sp) and centered the sprite for better visibility.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

SpriteDisplay.sprites is the list that contains all sprites in the display. Sprites are layered according to their order in this list, with sprites[0] at the back, and the last sprite in the list drawn on top. To add a sprite to the display, simply add it to this list; remove it from the list to remove the sprite from the display. You may reorder sprites in this list at any time to change the layering.

Example

sp = new Sprite
sp.image = file.loadImage("/sys/pics/Wumpus.png")
display(4).sprites.push sp	// add a sprite to the display

// Position the sprite in the center of the screen
sp.x = 480
sp.y = 320

key.get  // wait for a keypress
display(4).sprites.remove display(4).sprites.indexOf(sp)  // remove it