Changing iTween defaults

I was recently asked whether the default easing type in iTween could be changed so it didn’t have to be set to what was desired in every hash created. The simple answer is “Yes!”, the better answer is “Not just the easing type!”. iTween has a handful of defaults you can override at any time to help remove repetition from you calls and ensure your animations are consistent throughout your project (only the most useful are shown here):

  • time = 1
  • delay = 0
  • loopType = LoopType.none
  • easeType = iTween.EaseType.easeOutExpo
  • lookSpeed = 3
  • isLocal = false
  • space = Space.Self
  • orientToPath = false
  • lookAhead = .05
  • useRealTime = false

For example you can easily change the default easing type iTween uses to “linear”:

iTween.Defaults.easeType = iTween.EaseType.linear;

Need every animation to take 7 seconds and don’t want to have to set it for every call? Change the default for “time” and you can leave “time” out of your hash since every call will rely on the default value:

iTween.Defaults.time = 7;
iTween.MoveTo(gameObject, iTween.Hash("x",5)); //this animation will run for 7 seconds
iTween.RotateBy(gameObject, iTween.Hash("y",2)); //this animation will also run for 7 seconds

Using and modifying iTween’s defaults will allow you to make even shorter hash tables while allowing multiple animations to be adjusted globally.


  1. Blenderificus
    December 14, 2010

    thanks for the info. iTween is beyond useful!

    Question, should the defaults be overridden in the actual iTween.cs file, or as overrides in some form(say sent from a persistant game manager class), or are both possible/preferable?

    Or is the iTween.cs file, being static, not allow for any overrides/virtuals/etc…?

    • December 14, 2010

      Just use the default override calls from anywhere just as you do iTween.

  2. December 14, 2010

    Thanks for taking the time to post this, Bob!

    I’ll be pushing iTween to the limit in the upcoming Ludum Dare 48 challenge this weekend, wish me luck!


    • December 17, 2010

      Good luck! Make sure you share what you accomplish!