Using tween in Starling Builder

You can add custom tween to any UI elements and test it inside the editor. Select an UI element and go to the tween tab to edit tweenData, then hit play button to test it.

In order to make DefaultTweenBuilder working properly you need to put in data in the following format. It can be either an object or an array of objects

namedescription
timetime of the tween
propertiesproperties of the tween
delta(optional)delta value of the properties to tween to
from(optional)value of the properties to tween from
fromDelta(optional)delta value of the properties to tween from

Here are some examples:

{"time":1, "properties":{"scaleX":0.9, "scaleY":0.9, "repeatCount":0, "reverse":true}}
 
[{"properties":{"repeatCount":0,"scaleY":0.9,"reverse":true,"scaleX":0.9},"time":1},{"properties":{"repeatCount":0,"alpha":0,"reverse":true},"time":0.5}]

Internally DefaultTweenBuilder sets the from value (if existed) and then call Starling.juggler.tween in the following way:

for (var name:String in tweenData.from)
  displayObject[name] = tweenData.from[name];
Starling.juggler.tween(displayObject, tweenData.time, tween.properties)

In the game, you can call UIBuilder.tweenBuilder.start() to start the tween

When you dispose the UI, make sure to call UIBuilder.tweenBuilder.stop() to stop and clean up the tween

Feel free to implement your own ITweenBuilder if you want to. To be able to support your implementation of ITweenBuilder in the editor though you need to compile your own version.

  builder/tween.txt · Last modified: 2016/04/15 20:03 by johannh
 
Powered by DokuWiki