setSpriteColour()
Purpose
Set the colour of a sprite
Description
Sets the red, green, blue and opacity (alpha) values for a sprite
Syntax
setSpriteColour ( sprite, colour )
setSpriteColour ( sprite, red, green, blue, alpha )
sprite.r = red; sprite.g = green; sprite.b = blue; sprite.a = alpha
Arguments
sprite The handle of the created sprite
colour named colour or vector { r, g, b, a }
red red value between 0 and 1
green green value between 0 and 1
red blue value between 0 and 1
alpha opacity value between 0 and 1
Example
image = loadImage( "Untied Games/Enemy small top C", false )
ship = createSprite()
setSpriteImage( ship, image )
lastpos = { gWidth() / 2, gHeight() / 2 }
setSpriteLocation( ship, lastpos )
setSpriteScale( ship, { 10, 10 } )
loop
clear()
r = random( 101 ) / 100
g = random( 101 ) / 100
b = random( 101 ) / 100
setSpriteColour( ship, { r, g, b, 1 } )
updateSprites()
drawSprites()
update()
sleep( 0.1 )
repeat
Associated Commands
getSpriteColour(), getSpriteColourSpeed(), setSpriteColourSpeed()