Class Index | File Index

Classes


Class CAAT.Behavior.BaseBehavior


Defined in: BaseBehavior.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
The BaseBehavior is the base class of all Behavior modifiers:
  • AlphaBehabior
  • RotateBehavior
  • ScaleBehavior
  • Scale1Behavior
  • PathBehavior
  • GenericBehavior
  • ContainerBehavior Behavior base class.
  • Field Summary
    Field Attributes Field Name and Description
    <private>  
    The actor this behavior will be applied to.
    <private>  
    Behavior application duration time related to scene time.
    <private>  
    Behavior application start time related to scene time.
    <private>  
    Will this behavior apply for ever in a loop ?
    <private>  
    if true, this behavior will be removed from the this.actor instance when it expires.
     
    Apply the behavior, or just calculate the values ?
     
    id
    An id to identify this behavior.
    <private>  
    An interpolator object to apply behaviors using easing functions, etc.
     
    does this behavior apply relative values ??
    <private>  
    Behavior lifecycle observer list.
    <private>  
    Is this behavior solved ? When called setDelayTime, this flag identifies whether the behavior is in time relative to the scene.
    <private>  
    behavior status.
    <private>  
    Initial offset to apply this behavior the first time.
    Method Summary
    Method Attributes Method Name and Description
    <private>  
    Constructor delegate function.
     
    addListener(behaviorListener)
    Adds an observer to this behavior.
     
    apply(time, actor)
    This method must no be called directly.
     
    Calculate a CSS3 @key-frame for this behavior at the given time.
     
    calculateKeyFramesData(prefix, name, keyframessize)
    Calculate a complete CSS3 @key-frame set for this behavior.
     
    Remove all registered listeners to the behavior.
    <private>  
    fireBehaviorAppliedEvent(actor, time, normalizedTime, value)
    Notify observers about behavior being applied.
    <private>  
    Notify observers about expiration event.
    <private>  
    Notify observers the first time the behavior is applied.
     
     
    Calculate a CSS3 @key-frame data values instead of building a CSS3 @key-frame value.
     
    Get this behaviors CSS property name application.
     
     
    initialize(overrides)
     
    isBehaviorInTime(time, actor)
    Chekcs whether the behaviour is in scene time.
     
    <private>  
    Convert scene time into something more manageable for the behavior.
    <static>  
    CAAT.Behavior.BaseBehavior.parse(obj)
     
    parse(obj)
    Parse a behavior of this type.
     
    setCycle(bool)
    Sets the behavior to cycle, ie apply forever.
     
    Sets the default interpolator to a linear ramp, that is, behavior will be applied linearly.
     
    setDelayTime(delay, duration)
    Sets behavior start time and duration.
    <private>  
    setExpired(actor, time)
    Sets the behavior as expired.
    <private>  
    setForTime(actor, time)
    This method must be overriden for every Behavior breed.
     
    setFrameTime(startTime, duration)
    Sets behavior start time and duration.
     
    setId(id)
    Sets this behavior id.
     
    setInterpolator(interpolator)
    Changes behavior default interpolator to another instance of CAAT.Interpolator.
     
    Make this behavior not applicable.
     
    Sets default interpolator to be linear from 0.
     
    Set this behavior as relative value application to some other measures.
     
    <private>  
    Set this behavior status
     
    setTimeOffset(offset)
    Set this behavior offset time.
     
    Set whether this behavior will apply behavior values to a reference Actor instance.
    Class Detail
    CAAT.Behavior.BaseBehavior()
    The BaseBehavior is the base class of all Behavior modifiers:
  • AlphaBehabior
  • RotateBehavior
  • ScaleBehavior
  • Scale1Behavior
  • PathBehavior
  • GenericBehavior
  • ContainerBehavior Behavior base class.

    A behavior is defined by a frame time (behavior duration) and a behavior application function called interpolator. In its default form, a behaviour is applied linearly, that is, the same amount of behavior is applied every same time interval.

    A concrete Behavior, a rotateBehavior in example, will change a concrete Actor's rotationAngle during the specified period.

    A behavior is guaranteed to notify (if any observer is registered) on behavior expiration.

    A behavior can keep an unlimited observers. Observers are objects of the form:

    { behaviorExpired : function( behavior, time, actor); behaviorApplied : function( behavior, time, normalizedTime, actor, value); }

    behaviorExpired: function( behavior, time, actor). This method will be called for any registered observer when the scene time is greater than behavior's startTime+duration. This method will be called regardless of the time granurality.

    behaviorApplied : function( behavior, time, normalizedTime, actor, value). This method will be called once per frame while the behavior is not expired and is in frame time (behavior startTime>=scene time). This method can be called multiple times.

    Every behavior is applied to a concrete Actor. Every actor must at least define an start and end value. The behavior will set start-value at behaviorStartTime and is guaranteed to apply end-value when scene time= behaviorStartTime+behaviorDuration.

    You can set behaviors to apply forever that is cyclically. When a behavior is cycle=true, won't notify behaviorExpired to its registered observers.

    Other Behaviors simply must supply with the method setForTime(time, actor) overriden.

  • Field Detail
    <private> actor
    The actor this behavior will be applied to.

    <private> behaviorDuration
    Behavior application duration time related to scene time.

    <private> behaviorStartTime
    Behavior application start time related to scene time.

    <private> cycleBehavior
    Will this behavior apply for ever in a loop ?

    <private> discardable
    if true, this behavior will be removed from the this.actor instance when it expires.

    doValueApplication
    Apply the behavior, or just calculate the values ?

    id
    An id to identify this behavior.

    <private> interpolator
    An interpolator object to apply behaviors using easing functions, etc. Unless otherwise specified, it will be linearly applied.

    isRelative
    does this behavior apply relative values ??

    <private> lifecycleListenerList
    Behavior lifecycle observer list.

    <private> solved
    Is this behavior solved ? When called setDelayTime, this flag identifies whether the behavior is in time relative to the scene.

    <private> status
    behavior status.

    <private> timeOffset
    Initial offset to apply this behavior the first time.
    Method Detail
    <private> {this} __init()
    Constructor delegate function.
    Returns:
    {this}

    addListener(behaviorListener)
    Adds an observer to this behavior.
    Parameters:
    behaviorListener
    an observer instance.

    apply(time, actor)
    This method must no be called directly. The director loop will call this method in orther to apply actor behaviors.
    Parameters:
    time
    the scene time the behaviro is being applied at.
    actor
    a CAAT.Actor instance the behavior is being applied to.

    calculateKeyFrameData(time)
    Calculate a CSS3 @key-frame for this behavior at the given time.
    Parameters:
    time
    {number}

    calculateKeyFramesData(prefix, name, keyframessize)
    Calculate a complete CSS3 @key-frame set for this behavior.
    Parameters:
    prefix
    {string} browser vendor prefix
    name
    {string} keyframes animation name
    keyframessize
    {number} number of keyframes to generate

    emptyListenerList()
    Remove all registered listeners to the behavior.

    <private> fireBehaviorAppliedEvent(actor, time, normalizedTime, value)
    Notify observers about behavior being applied.
    Parameters:
    actor
    a CAAT.Actor instance the behavior is being applied to.
    time
    the scene time of behavior application.
    normalizedTime
    the normalized time (0..1) considering 0 behavior start time and 1 behaviorStartTime+behaviorDuration.
    value
    the value being set for actor properties. each behavior will supply with its own value version.

    <private> fireBehaviorExpiredEvent(actor, time)
    Notify observers about expiration event.
    Parameters:
    actor
    a CAAT.Actor instance
    time
    an integer with the scene time the behavior was expired at.

    <private> fireBehaviorStartedEvent(actor, time)
    Notify observers the first time the behavior is applied.
    Parameters:
    actor
    time

    getDuration()
    Returns:
    an integer indicating the behavior duration time in ms.

    getKeyFrameDataValues(time)
    Calculate a CSS3 @key-frame data values instead of building a CSS3 @key-frame value.
    Parameters:
    time
    {number}

    {String} getPropertyName()
    Get this behaviors CSS property name application.
    Returns:
    {String}

    getStartTime()
    Returns:
    an integer indicating the behavior start time in ms..

    initialize(overrides)
    Parameters:
    overrides

    isBehaviorInTime(time, actor)
    Chekcs whether the behaviour is in scene time. In case it gets out of scene time, and has not been tagged as expired, the behavior is expired and observers are notified about that fact.
    Parameters:
    time
    the scene time to check the behavior against.
    actor
    the actor the behavior is being applied to.
    Returns:
    a boolean indicating whether the behavior is in scene time.

    isCycle()

    <private> normalizeTime(time)
    Convert scene time into something more manageable for the behavior. behaviorStartTime will be 0 and behaviorStartTime+behaviorDuration will be 1. the time parameter will be proportional to those values.
    Parameters:
    time
    the scene time to be normalized. an integer.

    <static> CAAT.Behavior.BaseBehavior.parse(obj)
    Parameters:
    obj

    parse(obj)
    Parse a behavior of this type.
    Parameters:
    obj
    {object} an object with a behavior definition.

    setCycle(bool)
    Sets the behavior to cycle, ie apply forever.
    Parameters:
    bool
    a boolean indicating whether the behavior is cycle.

    setDefaultInterpolator()
    Sets the default interpolator to a linear ramp, that is, behavior will be applied linearly.
    Returns:
    this

    setDelayTime(delay, duration)
    Sets behavior start time and duration. Start time is relative to scene time. a call to setFrameTime( scene.time, duration ) is equivalent to setDelayTime( 0, duration )
    Parameters:
    delay
    {number}
    duration
    {number}

    <private> setExpired(actor, time)
    Sets the behavior as expired. This method must not be called directly. It is an auxiliary method to isBehaviorInTime method.
    Parameters:
    actor
    {CAAT.Actor}
    time
    {integer} the scene time.

    <private> setForTime(actor, time)
    This method must be overriden for every Behavior breed. Must not be called directly.
    Parameters:
    actor
    {CAAT.Actor} a CAAT.Actor instance.
    time
    {number} an integer with the scene time.

    setFrameTime(startTime, duration)
    Sets behavior start time and duration. Start time is set absolutely relative to scene time.
    Parameters:
    startTime
    {number} an integer indicating behavior start time in scene time in ms..
    duration
    {number} an integer indicating behavior duration in ms.

    setId(id)
    Sets this behavior id.
    Parameters:
    id
    {object}

    setInterpolator(interpolator)
    Changes behavior default interpolator to another instance of CAAT.Interpolator. If the behavior is not defined by CAAT.Interpolator factory methods, the interpolation function must return its values in the range 0..1. The behavior will only apply for such value range.
    Parameters:
    interpolator
    a CAAT.Interpolator instance.

    {*} setOutOfFrameTime()
    Make this behavior not applicable.
    Returns:
    {*}

    setPingPong()
    Sets default interpolator to be linear from 0..1 and from 1..0.
    Returns:
    this

    {*} setRelative(bool)
    Set this behavior as relative value application to some other measures. Each Behavior will define its own.
    Parameters:
    bool
    Returns:
    {*}

    setRelativeValues()

    <private> {*} setStatus(st)
    Set this behavior status
    Parameters:
    st
    {CAAT.Behavior.BaseBehavior.Status}
    Returns:
    {*}

    {*} setTimeOffset(offset)
    Set this behavior offset time. This method is intended to make a behavior start applying (the first) time from a different start time.
    Parameters:
    offset
    {number} between 0 and 1
    Returns:
    {*}

    {*} setValueApplication(apply)
    Set whether this behavior will apply behavior values to a reference Actor instance.
    Parameters:
    apply
    {boolean}
    Returns:
    {*}

    Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT)