Animate Multiple Properties at Once?

How would I animate two properties simultaneously using go.animate()? I want a sprite to be scaling up and rotating at the same time…

For example, in Corona SDK, this is done like so:

transition.to(gameOverGraphic, {time=1000, xScale=1, yScale=1,rotation=360})

Thanks!
Bryan

Did it not work to just animate them separately using two go.animate invocations?

Wouldn’t the second go.animate() cancel the first one?

No, you can animate each property separately just fine.

Hmm…not sure why this code:

go.set("game_over#game_overSprite", "euler", vmath.vector3(0,0,90))
go.set("game_over#game_overSprite", "scale", vmath.vector3(.1,.1,.1))
go.set("game_over#game_overSprite", "tint", vmath.vector4(1,1,1,0))

Is generating this error:

'game_over#game_overSprite' does not have any property called 'euler'

Same thing if I use ‘rotation’ rather than ‘euler’ (no property called ‘rotation’ error). I’m also getting the same error on go.animate() for rotation. The ‘scale’ and ‘tint’ properties are being set just fine, so I know my GO url is correct…

Thanks!
Bryan

Try euler.x, euler.y, euler.z

Tried that, and:

'game_over#game_overSprite' does not have any property called 'euler.z'

Don’t animate the sprite you need to animate the game object.

The documentation says there is a ‘euler’ property, and that you supply it with a vector3, which is what I’m doing, sooooo really confused. :slight_smile:

Ah,so ‘scale’ and ‘tint’ apply to the sprite, but ‘rotation’ to the GO…

go.animate is for properties of a game object. You can make new properties and then apply their values to other things though. I’m not sure if it works for components but if it does for some things directly then great.

Yeah, it worked for scale on the sprite component of my GO, but I changed the code to target the GO itself to avoid confusion. Thanks for your help!

Bryan

go.animate works for any runtime properties, different things have different properties. E.g. a sprite component has scale and size, as can be seen here: http://www.defold.com/ref/sprite/. If you add properties to a script, like so:

go.property("my_property", 1.0)

You can animate that as well, as long as its numeric.

The same goes for shader constants. The default material for sprites has a shader constant called “tint”, and the sprite component implicitly defines the shader constants as properties. This means that if you make your own material with other shader constants, and uses that material for your sprite, you can animate these values too. A great way to create cool lighting effects etc.

Just realised everything I said was already described here. :slight_smile:

As @Ragnar_Svensson wrote, there are different properties on the different components, as well as user defined properties and the ones on the actual game object. In the case of the euler property it exists on the game object and not on the sprite so you should do like this

go.set("game_over", "euler", vmath.vector3(0,0,90))