Skip to content
nhmkdev edited this page Jan 15, 2014 · 14 revisions

Definition

An Animation Object is common in the framework for specifying the animation settings for a variety of entities.

Data Format

The format of an Animation Object expands upon the base defined below depending on the type of entity. All of the settings below directly map to parameters required to create an animation in ImpactJS. Further information can be found in the ImpactJS documentation.

Basic Format

ao: // animation object
{
    i:'redflag', // image name ('media/' is prepended and .png is appended)
    w:16, // width of frame
    h:16, // height of frame
    g:1, // gravity factor (applies to entity once on load of animation object)
    a: // animation states
    [
        { 
            n:'collect', // state name
            ft:1, // frametime
            seq:[0] // sequence
            s:true, // stop (after playing anim) (default: false)
            g:1, // gravity factor (applies to entity when state is set)
        },           
        {
            n:'idle', // state name
            ft:1, // frametime
            seq:[1], // sequence
            s:true, // stop (after playing anim) (default: false)
            g:1, // gravity factor (applies to entity when state is set)
        }
    ]
}

State Driven Format

In the state driven format there are extra fields used to determine what state should apply based on the Save flag state. See Requirements for more information. All states are checked until the Requirements of one are met (or is null) when updating the animation state. Due to the fact that the ao.a object is an array you can create default cases with no Requirements if all prior states fail by simply entering them at the end of the array.

Below is a sample animation state within an ao object:

{
	c:'FIXED' // The type of collision for this state (see ig.Entity.COLLIDES values) (default: 'NEVER')
	b: { x:2, y: 32}, // bounds for collision (default: the entire image bounds)
	bo: {x: 2, y: 2}, // bounds offset for collision (default: {x:0, y:0})
	r:null // requirements for this state to become active (default: null)

	// standard animation state fields
	n:'closed',
	ft:1, // frametime
	seq:[1] // sequence
	s:false // stop anim
}
Clone this wiki locally