Having a little issue with _clearcolor as related to a routine I'm using in my game project to overlay a semitransparent color over a masked sprite.
h~& is the overlay color, which has an alpha component, d& is the image handle, here I'm passing in an image surface I use for assembling graphics before putting them on the screen. Here's how my program is using it during the sprite drawing:
call clear_image
(assembly
, hue
(hue_transparent
)) _putimage(0, 0)-step(w
, h
), sprite_image
, assembly
, (x2
, y2
)-step(sprite
(s
).size.x
, sprite
(s
).size.y
)
' Overlays
if blink_cd
> 1 then call overlay
(assembly
, _rgba(255, 0, 0, 63)) ' Engine burnout call overlay
(assembly
, _rgba(255, 255, 255, int(entity
(player
).hit_flash
* 224))) ' Hit flash
So first I clear the assembly image to transparent (_rgba(0, 0, 0, 0)), then put the sprite there from a sprite sheet that's got a color keyed out with _clearcolor. Then I apply the red engine burnout overlay, which works fine. The overlay() routine should leave the background still fully transparent, using its own _clearcolor that matches the overlay color. Then the hit flash value - which ranges from 0 to 1 and decays each frame - is used to apply a white overlay that fades down to the ship's normal colors. The overlay works, the fade works.
The problem is that
only for the white overlay, the white is bleeding off the sprite and causing a rectangle around the ship while the flash happens. Only for the white, not the red burnout overlay. I've made some attempts at debugging this, tried a few different things like resetting the _clearcolor to _none at the start of overlay(), adding a second assembly surface and copying the sprite over before the white overlay. Also, the white bleed is happening whether the red overlay is used or not.
Tried to post an image of it here, but I guess this forum doesn't allow images. Looking closely, some pixels in the ship sprite are being keyed out when they shouldn't be - they're appearing black.