Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@rwaldron 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

This comment has been minimized.

Copy link

@rwaldron 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

This comment has been minimized.

Copy link
Owner Author

@mzgoddard mzgoddard commented Dec 6, 2011

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

@mzgoddard

This comment has been minimized.

Copy link
Owner Author

@mzgoddard mzgoddard commented Dec 6, 2011

@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