setSpriteColourSpeed()
Purpose
Set the colour speeds of a sprite
Description
Set the rates of change of the colours of a sprite. These are the amounts that the sprite colours are changed by when updatesprites is called
Syntax
setSpriteColourSpeed( sprite, rgbaSpeed )
setSpriteColourSpeed( sprite, rSpeed, gSpeed, bSpeed, aSpeed )
sprite.r_speed = rspeed; sprite.g_speed = gspeed; sprite.b_speed = bspeed; sprite.a_speed = aspeed
Arguments
sprite handle of the created sprite
rgbaSpeed amount to add to the red, green, blue and opacity of the sprite at each updatesprites call
rSpeed amount to add to the red colour of the sprite at each updatesprites call
gSpeed amount to add to the blue colour of the sprite at each updatesprites call
bSpeed amount to add to the green colour of the sprite at each updatesprites call
aSpeed amount to add to the opacity of the sprite at each updatesprites call
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
getSpriteColour(), getSpriteColourSpeed(), setSpriteColour()