Defold community,
is there the functionality to manipulate/animate rgba filters on GO sprites?
Thanks,
Grify
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
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
The generic alternative is go.set(component_url, property, value)
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.
Example time!