Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

setSpriteImage()

Purpose

Change the image associated with a sprite

Description

Set the sprites image to the one specified

Syntax

setSpriteImage( sprite, image )

sprite.image = image

Arguments

sprite handle of the sprite

image handle of the image

Example

image = []
image[1] = loadImage( "Untied Games/Enemy A", false )
image[2] = loadImage( "Untied Games/Enemy B", false )
enemy = createSprite()
setSpriteImage( enemy, image[1] )
setSpriteAnimation( enemy, 0, 4, 20 )
lastpos = { gWidth() / 2, gHeight() / 2 }
setSpriteLocation( enemy, lastpos )
setSpriteScale( enemy, { 8, 8 } )
current = 1
last = 1

loop
    clear()
    c = controls( 0 )
    printAt( 0, 0, "Press A for image 1 and B for image 2" )
    if c.a then 
        current = 1 
    endIf
    if c.b then 
        current = 2 
    endIf
    if current != last then
        setSpriteImage( enemy, image[current] )
        setSpriteAnimation( enemy, 0, 4, 20 )
        last = current
    endIf
    updateSprites()
    drawSprites()
    update()
repeat

Associated Commands

createSprite(), getSpriteImage(), getSpriteImageSize(), setSpriteText()

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.