How do I animate rgba on GO sprites?

Defold community,
is there the functionality to manipulate/animate rgba filters on GO sprites?
Thanks,
Grify

1 Like

Yes, you need to go.set_constant()and the constant for built in sprite materials is called ‘tint’. If you want to animate it you will need to add additional e.g. self.color property to your script and animate it and in update function write go.set_constant(‘tint’, self.color). You can also check Defblend in Defold Asset Portal for some more materials for sprites :wink:

2 Likes

This gives me the following error:

ERROR:SCRIPT: /main/scene-foreground.script:16: attempt to call field 'set_constant' (a nil value)

Sorry, I was writing it too quickly on the phone! I mean sprite.set_constant


And also first argument is sprite url and then ‘tint’ and then pass a color value

1 Like

The generic alternative is go.set(component_url, property, value)

1 Like

Is there no way to use go.animate on this?

i would think the go’s color shader vector4 would be a property, and therefore animatable by go.animate(".","color",go.PLAYBACK_ONCE_FORWARD,vmath.vector4(1,1,1,0),go.EASING_INOUTEXPO,2)

Yes, you can go.set/go.animate the shader uniforms.
In the default shader, there’s only a “tint” property though. But you can add your own variable there.

4 Likes

Example time!

4 Likes