{"id":811,"date":"2010-12-14T04:04:10","date_gmt":"2010-12-14T04:04:10","guid":{"rendered":"http:\/\/pixelplacement.com\/?p=334"},"modified":"2017-01-12T04:48:53","modified_gmt":"2017-01-12T04:48:53","slug":"changing-itweens-defaults","status":"publish","type":"post","link":"https:\/\/www.pixelplacement.com\/site\/2010\/12\/14\/changing-itweens-defaults\/","title":{"rendered":"Changing iTween defaults"},"content":{"rendered":"<p>I was recently asked whether the default easing type in iTween could be changed so it didn&#8217;t have to be set to what was desired in every hash created. The simple answer is &#8220;Yes!&#8221;, the better answer is &#8220;Not just the easing type!&#8221;. 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):<!--more--><\/p>\n<ul class=\"list\">\n<li>time = 1<\/li>\n<li>delay = 0<\/li>\n<li>loopType = LoopType.none<\/li>\n<li>easeType = iTween.EaseType.easeOutExpo<\/li>\n<li>lookSpeed = 3<\/li>\n<li>isLocal = false<\/li>\n<li>space = Space.Self<\/li>\n<li>orientToPath = false<\/li>\n<li>lookAhead = .05<\/li>\n<li>useRealTime = false<\/li>\n<\/ul>\n<p>For example you can easily change the default easing type iTween uses to &#8220;linear&#8221;:<\/p>\n<pre>iTween.Defaults.easeType = iTween.EaseType.linear;<\/pre>\n<p>Need every animation to take 7 seconds and don&#8217;t want to have to set it for every call? Change the default for &#8220;time&#8221; and you can leave &#8220;time&#8221; out of your hash since every call will rely on the default value:<\/p>\n<pre>iTween.Defaults.time = 7;\r\niTween.MoveTo(gameObject, iTween.Hash(\"x\",5)); \/\/this animation will run for 7 seconds\r\niTween.RotateBy(gameObject, iTween.Hash(\"y\",2)); \/\/this animation will also run for 7 seconds\r\n<\/pre>\n<p>Using and modifying iTween&#8217;s defaults will allow you to make even shorter hash tables while allowing multiple animations to be adjusted globally.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was recently asked whether the default easing type in iTween could be changed so it didn&#8217;t have to be set to what was desired in every hash created. The simple answer is &#8220;Yes!&#8221;, the better answer is &#8220;Not just the easing type!&#8221;. iTween has a handful of defaults you can override at any time [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1465,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[16,28,46,48],"_links":{"self":[{"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/posts\/811"}],"collection":[{"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/comments?post=811"}],"version-history":[{"count":2,"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/posts\/811\/revisions"}],"predecessor-version":[{"id":1501,"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/posts\/811\/revisions\/1501"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/media\/1465"}],"wp:attachment":[{"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/media?parent=811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/categories?post=811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pixelplacement.com\/site\/wp-json\/wp\/v2\/tags?post=811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}