Class CAAT.Behavior.BaseBehavior
Defined in: BaseBehavior.js.
Constructor Attributes | Constructor Name and Description |
---|---|
The BaseBehavior is the base class of all Behavior modifiers:
|
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 ?
|
|
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 Attributes | Method Name and Description |
---|---|
<private> |
__init()
Constructor delegate function.
|
addListener(behaviorListener)
Adds an observer to this behavior.
|
|
apply(time, actor)
This method must no be called directly.
|
|
calculateKeyFrameData(time)
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> |
fireBehaviorExpiredEvent(actor, time)
Notify observers about expiration event.
|
<private> |
fireBehaviorStartedEvent(actor, time)
Notify observers the first time the behavior is applied.
|
getKeyFrameDataValues(time)
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.
|
|
isCycle()
|
|
<private> |
normalizeTime(time)
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.
|
|
setRelative(bool)
Set this behavior as relative value application to some other measures.
|
|
<private> |
setStatus(st)
Set this behavior status
|
setTimeOffset(offset)
Set this behavior offset time.
|
|
setValueApplication(apply)
Set whether this behavior will apply behavior values to a reference Actor instance.
|
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.
- Returns:
- {this}
- Parameters:
- behaviorListener
- an observer instance.
- Parameters:
- time
- the scene time the behaviro is being applied at.
- actor
- a CAAT.Actor instance the behavior is being applied to.
- Parameters:
- time
- {number}
- Parameters:
- prefix
- {string} browser vendor prefix
- name
- {string} keyframes animation name
- keyframessize
- {number} number of keyframes to generate
- 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.
- Parameters:
- actor
- a CAAT.Actor instance
- time
- an integer with the scene time the behavior was expired at.
- Parameters:
- actor
- time
- Returns:
- an integer indicating the behavior duration time in ms.
- Parameters:
- time
- {number}
- Returns:
- {String}
- Returns:
- an integer indicating the behavior start time in ms..
- Parameters:
- overrides
- 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.
- Parameters:
- time
- the scene time to be normalized. an integer.
- Parameters:
- obj
- Parameters:
- obj
- {object} an object with a behavior definition.
- Parameters:
- bool
- a boolean indicating whether the behavior is cycle.
- Returns:
- this
- Parameters:
- delay
- {number}
- duration
- {number}
- Parameters:
- actor
- {CAAT.Actor}
- time
- {integer} the scene time.
- Parameters:
- actor
- {CAAT.Actor} a CAAT.Actor instance.
- time
- {number} an integer with the 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.
- Parameters:
- id
- {object}
- Parameters:
- interpolator
- a CAAT.Interpolator instance.
- Returns:
- {*}
- Returns:
- this
- Parameters:
- bool
- Returns:
- {*}
- Parameters:
- st
- {CAAT.Behavior.BaseBehavior.Status}
- Returns:
- {*}
- Parameters:
- offset
- {number} between 0 and 1
- Returns:
- {*}
- Parameters:
- apply
- {boolean}
- Returns:
- {*}