There is a way to animate the alpha(color) in a GO or only to GUI?
go.property("color", vmath.vector4(0, 0, 0, 0))
...
local function anim_born(self)
pprint(self.color)
go.animate(go.get_id(), hash("color"), go.PLAYBACK_ONCE_FORWARD, vmath.vector4(0,0,0,1), go.EASING_INBOUNCE, 0, 0)
pprint(self.color)
end
error:
DEBUG:SCRIPT: vmath.vector4(0, 0, 0, 0)
ERROR:SCRIPT: dino/dino.script:28: '[main:/instance2]' does not have any property called 'color'
stack traceback:
[C]: in function 'animate'
dino/dino.script:28: in function 'anim_born'
dino/dino.script:35: in function <dino/dino.script:34>
[C]: in function 'create'
dino/dino_factory.script:9: in function 'create'
dino/dino_factory.script:15: in function <dino/dino_factory.script:13>
ERROR:GAMEOBJECT: Could not initialize when spawning /dino/dino.goc.
ERROR:GAMEOBJECT: Could not spawn an instance of prototype /dino/dino.goc.
(this is because GO’s sprites already have a colour, and all you can do is “tint” the colour that it already has! You draw a GUI element yourself, so you have to provide the “colour” rather than just tinting it).
The go.animate() obviously fade the alpha to 50% instead of directly changing it. Note also that you can set/animate the individual values as well, for instance “tint.w” for alpha.