defold icon indicating copy to clipboard operation
defold copied to clipboard

Allow for sprite's Blend Mode to be updated programmatically

Open koenbollen opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? I would like to change the Blend Mode of sprites programmatically.

Context: We have a lot of decals in our game, that we place using our custom level loader and I now have a "Decal" type, a "Screen Decal" type and a "Multiply Decal" type. Instead of a decal type with a Blend Mode property.

I can also imagine sprites changing Blend Mode based on game logics (e.g. Ghosts in Pacman changing appearance).

Describe the solution you'd like: I would like to be able to change the Blend Mode of an instance of the sprite component of a game object:

msg.post(sprite_url, "blend_mode", sprite.BLEND_MULTIPLY)

or:

sprite.set_blend_mode(sprite_url, sprite.BLEND_SCREEN) -- like gui.set_blend_mode

Thanks!

koenbollen avatar Aug 12 '24 09:08 koenbollen

I don't recall if blend mode can be changed programmatically on any other component. If blend mode is exposed as a property for sprites, along with a msg.post() and sprite.set_blend_mode() interface, should the same thing maybe be done for other components that have a blend mode?

VowSoftware avatar Oct 08 '24 19:10 VowSoftware

I would like to be able to change the Blend Mode of an instance of the sprite component of a game object:

msg.post(sprite_url, "blend_mode", sprite.BLEND_MULTIPLY)

or:

sprite.set_blend_mode(sprite_url, sprite.BLEND_SCREEN) -- like gui.set_blend_mode

A third option would be go.set("#sprite", "blend_mode", sprite.BLEND_SCREEN)

britzl avatar Oct 09 '24 05:10 britzl

Looking through the current sprite API, none of the properties have a function wrapper like sprite.set_blend_mode(), so I don't think that should be added unless wrappers were added for the others too.

I do notice though that most of the sprite's internals are exposed as properties that can be accessed with msg.post(), go.get(), or go.set(). Blend mode is an exception. I don't see any complications with exposing yet, so I'll try to do that.

VowSoftware avatar Oct 09 '24 06:10 VowSoftware