Difference between revisions of "SpriteDisplay.sprites"

From MiniScript Wiki
Jump to navigation Jump to search
m
(Fixed method call syntax(sp) and centered the sprite for better visibility.)
 
Line 11: Line 11:
 
sp.image = file.loadImage("/sys/pics/Wumpus.png")
 
sp.image = file.loadImage("/sys/pics/Wumpus.png")
 
display(4).sprites.push sp // add a sprite to the display
 
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
 
key.get  // wait for a keypress
display(4).sprites.remove display(4).sprites.indexOf sp  // remove it</ms>
+
display(4).sprites.remove display(4).sprites.indexOf(sp) // remove it</ms>
  
 
[[Category:Mini Micro]]
 
[[Category:Mini Micro]]

Latest revision as of 01:37, 14 May 2025

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