Skip to content

Instantly share code, notes, and snippets.

@mzgoddard
Created December 6, 2011 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzgoddard/1439822 to your computer and use it in GitHub Desktop.
Save mzgoddard/1439822 to your computer and use it in GitHub Desktop.
Animation State API
function Animation( options ) {}
Animation.prototype = {
start: function( target ) { /* start new AnimationState */; return state; }
// move reset to state
// data related functions
sample: function( target, time ) { return this; }
}
function AnimationState( { animation: animation, target: target, timer: timer || undefined } ) {}
AnimationState.prototype = {
// startAt - start at time in animation now
start: function( startAt || undefined ) { return this; }
// stopAt - stop at time when the animation reaches it
stop: function( stopAt || undefined ) { return this; }
reset: function() { return this; } // necessary? could just be start?
step: function( timerData ) { return null; }
}
function Layer() {}
Layer.prototype = {
sample: function( animation, target, time, state || undefined ) { return null; }
}
LayerState is just an object that stores values set by Layer.sample

Animation

AnimationState

Stores a reference to an animation, a target for that animation and a Abacus.timer object which will call AnimationState.step. On instantiation the timer object will be created if not provided.

Parameters:

  • options - dictionary with the following values
    • animation <Abacus.animation>
    • target <object>
    • timer <Abacus.timer> [optional]

Layer

Layer.sample

Sample an animation at time time onto target.

Parameters:

  • animation - parent animation objet
  • target - target object
  • time <number> - time value to sample
  • state [optional] - state object for things like speeding up frame lookup
@rwaldron
Copy link

rwaldron commented Dec 6, 2011

function AnimationState( { animation: animation, target: target, timer: timer || undefined } ) {} are you sure you mean that?

To be honest, I have no idea what you're trying to illustrate here. Sorry.

@rwaldron
Copy link

rwaldron commented Dec 6, 2011

sample: function( animation, target, time, state || undefined ) { return null; }

I'm not sure if this is some kind of Z proprietary shorthand?

@mzgoddard
Copy link
Author

hmm. I'm never really certain how to write example APIs ...

@mzgoddard
Copy link
Author

@rwldrn does this rst blurb help explain what I am getting at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment