PDG engine v0.9.5
 All Classes Namespaces Functions Variables Groups Pages
Classes | Variables
Animation

Things related to animation. More...

Collaboration diagram for Animation:

Classes

class  Animated
 something that can be automatically moved, spun or resized over time. More...
 
class  IAnimationHelper
 helper for add-on or complex motion during animation More...
 
class  Offset
 offset within a 2D coordinate system More...
 
class  Point
 point for 2D coordinate system More...
 
class  Quad
 4 point polygon in 2D system More...
 
class  Rect
 Rectangle for 2D coordinate system. More...
 
class  RotatedRect
 rectangle with rotation for 2D coordinate system. More...
 
class  Sprite
 animated, moving image that is automatically moved, animated, and drawn More...
 
struct  SpriteAnimateEvent
 a Sprite did some animation (Optional) More...
 
class  SpriteLayer
 creates and tracks collections of sprites More...
 
class  Vector
 vector (magnitude and direction) within a 2D coordinate system. More...
 

Variables

const action_AnimationComplete = 47
 eventType_SpriteLayer action: all animations for every SpriteLayer have completed More...
 
const action_AnimationEnd = 9
 eventType_SpriteAnimate action: a sprite animation has completed More...
 
const action_AnimationLoop = 8
 eventType_SpriteAnimate action: a sprite animation has completed and is looping back to the start More...
 
const action_AnimationStart = 44
 eventType_SpriteLayer action: starting animations for all SpriteLayers More...
 
const action_ExitLayer = 4
 eventType_SpriteAnimate action: a sprite has moved outside the layer boundaries. More...
 
const action_FadeComplete = 10
 eventType_SpriteAnimate action: a sprite fadeTo() has completed More...
 
const action_FadeInComplete = 11
 eventType_SpriteAnimate action: a sprite fade-in has completed More...
 
const action_FadeOutComplete = 12
 eventType_SpriteAnimate action: a sprite fade-out has completed More...
 
const action_LayerFadeInComplete = 49
 eventType_SpriteLayer action: the fade-in of a layer has been completed More...
 
const action_LayerFadeOutComplete = 50
 eventType_SpriteLayer action: the fade-out of a layer has been completed More...
 
const action_Offscreen = 2
 eventType_SpriteAnimate action: a sprite has gone completely offscreen (GUI Only) More...
 
const action_Onscreen = 3
 eventType_SpriteAnimate action: a sprite that was off screen has moved onscreen (GUI Only) More...
 
const action_PostAnimateLayer = 46
 eventType_SpriteLayer action: all animations for a particular SpriteLayer have completed More...
 
const action_PreAnimateLayer = 45
 eventType_SpriteLayer action: about to start animations for a particular SpriteLayer More...
 
const action_ZoomComplete = 48
 eventType_SpriteLayer action: zooming a particular sprite layer is complete More...
 

Detailed Description

Things related to animation.


Class Documentation

class pdg::IAnimationHelper

helper for add-on or complex motion during animation

Warning
API Stability: 1 - Experimental. This API was introduced recently and gotten little or no real use. It may change or be removed in future versions. It may not be completely implemented and may be missing important pieces of functionality. Please try it out and provide feedback.

Implement this interface to do extra animation stuff for a specific Animated object then add by calling the object's addAnimationHelper() method. You can have multiple Animation Helpers attached to the same object. Your helper will then be called every time movement for the object is calculated.

To create a helper:

var myHelper = new pdg.IAnimationHelper(function(what, msElapsed) {
console.log("in my animation helper for " + what + " after " + msElapsed + "ms" );
return true; // not done, keep helping
});
myAnimatedObj.addAnimationHelper(myHelper);

If you need something more complex, you can also use classify to create a new Javascript class that derives from pdg.IAnimationHelper, and it will call the animated() method of your class. For example:

classify(pdg.IAnimationHelper, 'MyAnimationHelperClass', function() {
def('animate', function(what, msElapsed) {
console.log("MyAnimationHelper.animate(" + what + ", " + msElapsed + "ms)" );
return false; // all done, delete the helper
});
});
myAnimatedObj.addAnimationHelper( new MyAnimationHelperClass() );

Your Custom Function:

As you can see from the examples above, your Animation Helper function (or animate() method) will be called with two parameters, and return a boolean:

Parameters
whatthe Animated object that is being animated
msElapsedthe number of milliseconds that have elapsed since the last time this object's movement was calculated
Returns
true if the helper should continue to be called; or false if it is done and should be removed from this Animated object.
struct pdg::SpriteAnimateEvent

a Sprite did some animation (Optional)

A Sprite will generate one of these events when it completes an animation including fades (opacity animations), and moving on/offscreen or outside of the layer.

For frame based animations – that is, calls to Sprite.startFrameAnimation() – if it reaches the last frame and is not set to loop, action will be action_AnimationEnd. For looping animations action_AnimationLoop will be received each time the animation completes and starts over with the first frame.

For fades, one of three action types are possible: action_FadeComplete for calls to Sprite.fadeTo(), action_FadeInComplete for calls to Sprite.fadeIn(), and action_FadeOutComplete for calls to Sprite.fadeOut().

When a Sprite has setWantsOffscreenEvents(true), action_Offscreen and action_Onscreen events will be generated for that sprite whenever it enters or departs the visible area of the port the layer is being rendered into.

When a Sprite has setWantsCollideWallEvents(true), action_ExitLayer events will be generated for that sprite whenever it moves completely outside the boundaries of the layer. (It will also get a SpriteCollideEvent when hits the boundary).

{
    emitter: {},            // the emitter that generated this event
    eventType: 17,          // the event type (eventType_SpriteAnimate)
    action: 0,              // what happened (action_AnimationEnd/Loop or action_Fade/In/OutComplete)
    actingSprite: {},       // the Sprite that was animating
    inLayer: {}             // the SpriteLayer that contains the Sprite
}
Note
At this time other kinds of animations such as calls to Sprite.startAnimation() do not generate any events.
See Also
eventType_SpriteAnimate
Sprite.startFrameAnimation()
Sprite.fadeTo()
Sprite.fadeIn()
Sprite.fadeOut()
Sprite.setWantsOffscreenEvents()
Sprite.setWantsCollideWallEvents()

Variable Documentation

action_AnimationComplete = 47

eventType_SpriteLayer action: all animations for every SpriteLayer have completed

Emitted once per animation step, after all animation has completed.

See Also
action_AnimationComplete
eventType_SpriteLayer
action_AnimationEnd = 9

eventType_SpriteAnimate action: a sprite animation has completed

See Also
Sprite.setWantsAnimEndEvents()
Sprite.startFrameAnimation()
action_AnimationLoop
eventType_SpriteAnimate
action_AnimationLoop = 8

eventType_SpriteAnimate action: a sprite animation has completed and is looping back to the start

See Also
Sprite.setWantsAnimLoopEvents()
Sprite.startFrameAnimation()
action_AnimationEnd
eventType_SpriteAnimate
action_AnimationStart = 44

eventType_SpriteLayer action: starting animations for all SpriteLayers

Emitted once per animation step, before any animation is done.

See Also
action_AnimationComplete
eventType_SpriteLayer
action_ExitLayer = 4

eventType_SpriteAnimate action: a sprite has moved outside the layer boundaries.

These events are only generated for sprites that have setWantsCollideWallEvents(true) called for them, and that the SpriteLayer that holds the sprite has had its size explicitly set.

See Also
Sprite.setWantsCollideWallEvents()
SpriteLayer.setSize()
eventType_SpriteAnimate
action_Offscreen
action_Onscreen
action_FadeComplete = 10

eventType_SpriteAnimate action: a sprite fadeTo() has completed

See Also
Sprite.fadeTo()
action_FadeInComplete
action_FadeOutComplete
eventType_SpriteAnimate
action_FadeInComplete = 11

eventType_SpriteAnimate action: a sprite fade-in has completed

See Also
Sprite.fadeIn()
action_FadeComplete
action_FadeOutComplete
eventType_SpriteAnimate
SpriteAnimateEvent
action_FadeOutComplete = 12

eventType_SpriteAnimate action: a sprite fade-out has completed

See Also
Sprite.fadeOut()
action_FadeComplete
action_FadeInComplete
eventType_SpriteAnimate
SpriteAnimateEvent
action_LayerFadeInComplete = 49

eventType_SpriteLayer action: the fade-in of a layer has been completed

See Also
SpriteLayer.fadeIn()
action_LayerFadeOutComplete
eventType_SpriteLayer
action_LayerFadeOutComplete = 50

eventType_SpriteLayer action: the fade-out of a layer has been completed

See Also
SpriteLayer.fadeOut()
action_LayerFadeInComplete
eventType_SpriteLayer
action_Offscreen = 2

eventType_SpriteAnimate action: a sprite has gone completely offscreen (GUI Only)

This event is only generated for sprites that have setWantsOffscreenEvents(true) called.

See Also
Sprite.setWantsOffscreenEvents()
eventType_SpriteAnimate
action_Onscreen
action_Onscreen = 3

eventType_SpriteAnimate action: a sprite that was off screen has moved onscreen (GUI Only)

These events are only generated for sprites that have setWantsOffscreenEvents(true) called for them.

See Also
Sprite.setWantsOffscreenEvents()
eventType_SpriteAnimate
action_Offscreen
action_PostAnimateLayer = 46

eventType_SpriteLayer action: all animations for a particular SpriteLayer have completed

Emitted once per layer per animation step, after all animation for the layer is complete.

See Also
action_AnimationComplete
action_PreAnimateLayer
eventType_SpriteLayer
action_PreAnimateLayer = 45

eventType_SpriteLayer action: about to start animations for a particular SpriteLayer

Emitted once per layer per animation step, before any animation for that layer is performed.

See Also
action_AnimationStart
action_PostAnimateLayer
eventType_SpriteLayer
action_ZoomComplete = 48

eventType_SpriteLayer action: zooming a particular sprite layer is complete

See Also
SpriteLayer.zoom()
eventType_SpriteLayer

User Comments