getSpriteColour()
Purpose
Get the colour values of a sprite
Description
Gets the red, green, blue and alpha (opacity) values for a sprite
Syntax
colour = getSpriteColour( sprite )
red = sprite.r; green = sprite.g; blue = sprite.b; alpha = sprite.a
Arguments
sprite handle of the created sprite
colour vector containing the colour values { r, g, b, a }
red value of red colour of the sprite
green value of green colour of the sprite
blue value of blue colour of the sprite
alpha value of alpha (opacity) of the sprite
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, { 20, 20 } )
rv = -0.5
gv = 0.5
bv = 0
loop
clear()
sc = getSpriteColour( ship )
if sc.r > 1 or sc.r < 0 then
rv = -rv
endIf
if sc.b > 1 or sc.b < 0 then
gv = -gv
endIf
setSpriteColourSpeed( ship, { rv, gv, bv, 0 } )
updateSprites()
drawSprites()
update()
repeat
Associated Commands
getSpriteColourSpeed(), setSpriteColour(), setSpriteColourSpeed()