I'm having trouble making an image "slightly bluer" or "slightly less blue" without ruining its alpha transparency.
Basically I need a sprite that changes color over time and eventually fades away. The sprite does not take up the entire square; it's a typical run-of-the-mill PNG 'outside the sprite shape is painted with the alpha transparent color' image.
For the sake of demonstrating my code, I'm including a generic explosion graphic, but the sprites I intend to eventually use this code on are a lot more complicated.
Direct/naive attempt:
SetWindowTitle( "Example Set Sprite Color" )
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
ResetTimer()
Boomer = CreateSprite(LoadImage("boom.png"))
SetSpriteSize(Boomer,50,50)
SetSpritePosition(Boomer,200,200)
Do
For i=0 to 255
SetSpriteColorBlue(Boomer,i)
Sync()
Next i
If Timer()>15 Then Exit
Loop
End
Overlay code (mostly from Tone Dialer's SetSpriteColor example)
SetWindowTitle( "Example Set Sprite Color" )
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
ResetTimer()
Boomer = CreateSprite(LoadImage("boom.png"))
SetSpriteSize(Boomer,50,50)
SetSpritePosition(Boomer,200,200)
id=CreateSprite(0)
SetSpriteSize(id,50,50)
SetSpritePosition(id,200,200)
SetSpriteColor(id,0,0,0,255)
SetSpriteColorAlpha(id,128)
Do
For i=0 to 255
SetSpriteColorBlue(id,i)
SetSpriteColorAlpha(id,128)
Sync()
Next i
If Timer()>15 Then Exit
Loop
End
Also tried to use an image negative -- got the sprite to change color, but now its negative is opaque
SetWindowTitle( "Example Set Sprite Color" )
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
ResetTimer()
id=CreateSprite(0)
SetSpriteSize(id,256,256)
SetSpritePosition(id,200,200)
SetSpriteColor(id,0,0,0,255)
SetSpriteColorAlpha(id,255)
BoomerUnderlay = CreateSprite(LoadImage("boom_negative.png"))
SetSpriteSize(BoomerUnderlay,256,256)
SetSpritePosition(BoomerUnderlay,200,200)
Boomer = CreateSprite(LoadImage("boom.png"))
SetSpriteSize(Boomer,256,256)
SetSpritePosition(Boomer,200,200)
Do
For i=0 to 255
SetSpriteColorAlpha(Boomer,255-i)
SetSpriteColorBlue(id,i)
Sync()
Next i
If Timer()>15 Then Exit
Loop
End
That method could work if there was some way to "take the pixel by pixel alpha transparency settings from image A, and apply them to image B."
It's mean time. *averages*