Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

setSpriteDepth()

Purpose

Set a sprites depth

Description

Sets the visual depth of the sprite. For drawing, sprites will automatically be sorted by their depth from negative (earliest drawing) to positive (latest drawing).

Syntax

setSpriteDepth( sprite, depth )

sprite.depth = depth

Arguments

sprite The handle of the created sprite

depth The visual depth of the sprite

Example

image = loadImage( "Untied Games/Enemy small top C", false )
ship = []
for i = 0 to 2 loop
    ship[i] = createSprite()
    setSpriteImage( ship[i], image )
    setSpriteScale( ship[i], { 5, 5 } )
    setSpriteDepth( ship[i], i ) 
repeat

setSpriteRotation( ship[0], 270 )
setSpriteLocation( ship[0], { 0, gHeight() /2 } )
setSpriteLocation( ship[1], { gWidth()/ 2, 0 } )
setSpriteSpeed( ship[0], { 240, 0 } )
setSpriteSpeed( ship[1], { 0, 120 } )
setSpriteColour( ship[1], { 0, 0, 1, 1 } )

while ship[0].x < gwidth() loop
  clear()
  printAt( 0, 0, "Blue ship is drawn first so red ship passes over it" )
  updateSprites()
  drawSprites()
  update()
repeat

Associated Commands

getSpriteDepth()

logo

©2019 FUZE Technologies Ltd. FUZE is a registered trademark of FUZE Technologies Ltd. All rights reserved.

Useful links

  • Fuze Main Site
  • Fuze Arena on Twitter
  • Fuze Arena on Youtube
  • Download Buyer

Contact Information

  • FUZE Technologies Ltd
    15 Clearfields Farm
    Wotton Underwood
    Aylesbury, Buckinghamshire
    ​England, HP18 0RS

  • +44 (0) 1844 239 432

  • contact@fuze.co.uk

© Copyright FUZE Technologies Ltd. All rights reserved.