Thanks baxslash. It took me a while to extract the example with the error, but I got there in the end. The key was fading out the sprite.
I think I understand it now. As I fade out the sprite, it is adding the previous frame, therefore it is counteracting itself. As a result, even a 100% transparent sprite is 100% opaque as it keeps adding the previous incarnation.
Here's the example code, I appreciate you confirming whether or not my interpretation of what is happening is correct. The left sprite is "normal", the right sprite uses additive blending. They are being faded out with a tween.
// Project: Additive
// Created: 2015-02-01
// set window properties
SetWindowTitle( "Additive" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
global spriteNorm
global spriteAdd
createGameBox()
SetSpritePositionByOffset(spriteNorm, 300, 200)
SetSpritePositionByOffset(spriteAdd, 500, 200)
SetSyncRate(60,0)
tween = CreateTweenSprite(2)
do
if timer()-3 > time
SetSpritePositionByOffset(spriteNorm, 300, getSpriteyByOffset(SpriteNorm) + 50)
SetSpritePositionByOffset(spriteAdd, 500, getSpriteyByOffset(SpriteAdd) + 50)
SetTweenSpriteAlpha(tween,255,0, 5)
SetTweenSpriteSizeX(tween,0,300, 8)
SetTweenSpriteSizeY(tween,0,300, 8)
PlayTweenSprite(tween,spriteNorm,0)
PlayTweenSprite(tween,spriteAdd,0)
time = timer()
endif
Print( ScreenFPS() )
UpdateAllTweens(GetFrameTime())
Sync()
loop
end
function createGameBox()
img = LoadImage("box.png")
spriteNorm = createSprite(img)
//spriteNorm = createSprite(0)
SetSpriteColor(spriteNorm,0,0,255,212)
//Create background sprite
img = loadImage("boxHighlight.png")
spriteAdd = createSprite(img)
//spriteAdd = createSprite(0)
SetSpriteColor(spriteAdd,0,0,255,212)
SetSpriteDepth(spriteAdd,8)
SetSpriteTransparency(spriteAdd,2)
endfunction
Quidquid latine dictum sit, altum sonatur