FANDOM



ExampleEdit

var a = new CustomAnimation(1, bgFadeUpdate);

a.duration = 700;
a.startValue = myText.bgOpacity;
a.endValue = 100;

animator.start(a);

function bgFadeUpdate()
{
  var now = animator.milliseconds;
  var t = Math.max(0, now - this.startTime);
  var pct = t / this.duration;
  
  if (pct >= 1.0) {
    myText.bgOpacity = this.endValue;
    return false;
  } else {
    myText.bgOpacity = animator.ease(this.startValue,
                                     this.endValue,
                                     pct, animator.kEaseInOut);
    return true;
  }
}

Notice that the function bgFadeUpdate() uses this.startTime even though it was never defined. Don't worry, it is set when the animation is started.


We can also make our own generic Animations

HeightAnimation Edit

function HeightAnimation(object,toHeight,duration,easeType,doneFunc){
  var UpdateMe = function () {
    var t       = animator.milliseconds - this.startTime;
    var percent = t / this.duration;
    
    if (percent >= 1) {
      this.object.height = this.toHeight;
      return false;
    }
    this.object.height = animator.ease(this.startHeight,this.toHeight,percent,this.easeType);
    return true;
  }
      
  var a = new CustomAnimation(1,UpdateMe,doneFunc);
  a.object      = object;
  a.startHeight = object.height;
  a.toHeight    = toHeight;
  a.duration    = duration;
  a.easeType    = easeType;

  return a;
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.