Class CAAT.Foundation.Actor
Defined in: Actor.js.
Constructor Attributes | Constructor Name and Description |
---|---|
CAAT.Foundation.Actor is the base animable element.
|
Field Attributes | Field Name and Description |
---|---|
<private> | |
This rectangle keeps the axis aligned bounding box in screen coords of this actor.
|
|
Transparency value.
|
|
<static> |
CAAT.Foundation.Actor.ANCHOR_BOTTOM
|
<static> |
CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT
|
<static> |
CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT
|
<static> |
CAAT.Foundation.Actor.ANCHOR_CENTER
|
<static> |
CAAT.Foundation.Actor.ANCHOR_CUSTOM
|
<static> |
CAAT.Foundation.Actor.ANCHOR_LEFT
|
<static> |
CAAT.Foundation.Actor.ANCHOR_RIGHT
|
<static> |
CAAT.Foundation.Actor.ANCHOR_TOP
|
<static> |
CAAT.Foundation.Actor.ANCHOR_TOP_LEFT
|
<static> |
CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT
|
Define this actor´s background image.
|
|
A collection of behaviors to modify this actor´s properties.
|
|
<static> |
CAAT.Foundation.Actor.CACHE_DEEP
|
<static> |
CAAT.Foundation.Actor.CACHE_NONE
|
<static> |
CAAT.Foundation.Actor.CACHE_SIMPLE
|
Caching as bitmap strategy.
|
|
Will this actor be clipped before being drawn on screen ?
|
|
If this.clip and this.clipPath===null, a rectangle will be used as clip area.
|
|
<private> |
Local matrix dirtyness flag.
|
Mark this actor as discardable.
|
|
Marks from the time this actor is going to be animated, during how much time.
|
|
Mark this actor as expired, or out of the scene time.
|
|
any canvas rendering valid fill style.
|
|
<private> | |
Is gesture recognition enabled on this actor ??
|
|
Is this actor enabled on WebGL ?
|
|
Actor's height.
|
|
Set this actor´ id so that it can be later identified easily.
|
|
Is this actor processed in the last frame ?
|
|
If dirty rects are enabled, this flag indicates the rendering engine to invalidate this
actor´s screen area.
|
|
<private> |
is this actor/container Axis aligned ? if so, much faster inverse matrices can be calculated.
|
if this actor is cached, when destroy is called, it does not call 'clean' method, which clears some
internal properties.
|
|
true to make all children transparent, false, only this actor/container will be transparent.
|
|
A collection of this Actors lifecycle observers.
|
|
actor's layout minimum size.
|
|
This actor´s affine transformation matrix.
|
|
Enable or disable input on this actor.
|
|
<private> | |
<private> | |
This actor's parent container.
|
|
actor´s layout preferred size.
|
|
Exclude this actor from automatic layout on its parent.
|
|
This actor´s rotation angle in radians.
|
|
Rotation Anchor Y.
|
|
Rotation Anchor X.
|
|
A value that corresponds to any CAAT.Foundation.Actor.ANCHOR_* value.
|
|
Scale Anchor X.
|
|
Scale Anchor Y.
|
|
ScaleX value.
|
|
ScaleY value.
|
|
debug info.
|
|
debug info.
|
|
Marks since when this actor, relative to scene time, is going to be animated/drawn.
|
|
any canvas rendering valid stroke style.
|
|
Translation x anchor.
|
|
Translation y anchor.
|
|
This actor´s scene time.
|
|
These 4 CAAT.Math.Point objects are the vertices of this actor´s non axis aligned bounding
box.
|
|
Make this actor visible or not.
|
|
<private> |
Global matrix dirtyness flag.
|
Actor's width.
|
|
This actor´s world affine transformation matrix.
|
|
x position on parent.
|
|
y position on parent.
|
Method Attributes | Method Name and Description |
---|---|
<private> |
__init()
|
<private> |
__paintActor(director, time)
for js2native
|
<private> |
__scale1To(axis, scale, duration, delay, anchorX, anchorY, interpolator)
|
<private> | |
addAnimation(name, array, time, callback)
|
|
addBehavior(behavior)
Add a Behavior to the Actor.
|
|
addListener(actorListener)
Adds an Actor's life cycle listener.
|
|
animate(director, time)
Private
This method is called by the Director instance.
|
|
cacheAsBitmap(time, stragegy)
|
|
centerAt(x, y)
Center this actor at position (x,y).
|
|
centerOn(x, y)
Center this actor at position (x,y).
|
|
clean()
|
|
contains(x, y)
Checks whether a coordinate is inside the Actor's bounding box.
|
|
create()
|
|
<private> |
destroy(time)
This method will be called internally by CAAT when an Actor is expired, and at the
same time, is flagged as discardable.
|
drawScreenBoundingBox(director, time)
Draw a bounding box with on-screen coordinates regardless of the transformations
applied to the Actor.
|
|
Removes all behaviors from an Actor.
|
|
Enables a default dragging routine for the Actor.
|
|
enableEvents(enable)
Enable or disable the event bubbling for this Actor.
|
|
endAnimate(director, time)
|
|
findActorAtPosition(point)
Private
This method does the needed point transformations across an Actor hierarchy to devise
whether the parameter point coordinate lies inside the Actor.
|
|
findActorById(id)
|
|
fireEvent(sEventType, time)
Notifies the registered Actor's life cycle listener about some event.
|
|
gestureChange(rotation, scaleX, scaleY)
|
|
gestureEnd(rotation, scaleX, scaleY)
|
|
gestureStart(rotation, scaleX, scaleY)
|
|
getAnchor(anchor)
Private.
|
|
getAnchorPercent(anchor)
|
|
getBehavior(id)
|
|
getId()
|
|
If GL is enables, get this background image's texture page, otherwise it will fail.
|
|
glNeedsFlush(director)
Test for compulsory gl flushing:
1.
|
|
glSetShader(director)
Change texture shader program parameters.
|
|
initialize(overrides)
|
|
isCached()
|
|
<private> |
isInAnimationFrame(time)
This method is called by the Director to know whether the actor is on Scene time.
|
modelToModel(point, otherActor)
Transform a local coordinate point on this Actor's coordinate system into
another point in otherActor's coordinate system.
|
|
<private> |
modelToView(point)
Transform a point or array of points in model space to view space.
|
mouseClick(mouseEvent)
Default mouseClick handler.
|
|
mouseDblClick(mouseEvent)
Default double click handler
|
|
mouseDown(mouseEvent)
default mouse press in Actor handler.
|
|
mouseDrag(mouseEvent)
default Actor mouse drag handler.
|
|
mouseEnter(mouseEvent)
Default mouse enter on Actor handler.
|
|
mouseExit(mouseEvent)
Default mouse exit on Actor handler.
|
|
mouseMove(mouseEvent)
Default mouse move inside Actor handler.
|
|
mouseOut(mouseEvent)
|
|
mouseOver(mouseEvent)
|
|
mouseUp(mouseEvent)
default mouse release in Actor handler.
|
|
moveTo(x, y, duration, delay, interpolator, callback)
Move this actor to a position.
|
|
paint(director, time)
This method should me overriden by every custom Actor.
|
|
paintActor(director, time)
|
|
paintActorGL(director, time)
Set coordinates and uv values for this actor.
|
|
playAnimation(name)
|
|
Remove a Behavior with id param as behavior identifier from this actor.
|
|
removeBehaviour(behavior)
Remove a Behavior from the Actor.
|
|
removeListener(actorListener)
Removes an Actor's life cycle listener.
|
|
Remove all transformation values for the Actor.
|
|
rotateTo(angle, duration, delay, anchorX, anchorY, interpolator)
|
|
scaleTo(scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator)
|
|
scaleXTo(scaleX, duration, delay, anchorX, anchorY, interpolator)
|
|
scaleYTo(scaleY, duration, delay, anchorX, anchorY, interpolator)
|
|
setAlpha(alpha)
Stablishes the Alpha transparency for the Actor.
|
|
Set this actor's background SpriteImage its animation sequence.
|
|
setAsButton(buttonImage, iNormal, iOver, iPress, iDisabled, fn)
Set this actor behavior as if it were a Button.
|
|
setBackgroundImage(image, adjust_size_to_image)
Set this actor's background image.
|
|
setBackgroundImageOffset(ox, oy)
Set this actor's background SpriteImage offset displacement.
|
|
setBounds(x{number}, y{number}, w{number}, h{number})
Set location and dimension of an Actor at once.
|
|
setButtonImageIndex(_normal, _over, _press, _disabled)
|
|
setCachedActor(cached)
|
|
setChangeFPS(time)
|
|
setClip(enable, clipPath)
Set this Actor's clipping area.
|
|
setDiscardable(discardable)
Set discardable property.
|
|
setExpired(time)
Sets this Actor as Expired.
|
|
setFillStyle(style)
Caches a fillStyle in the Actor.
|
|
setFrameTime(startTime, duration)
Sets the time life cycle for an Actor.
|
|
setGestureEnabled(enable)
|
|
setGLCoords(glCoords, glCoordsIndex)
TODO: set GLcoords for different image transformations.
|
|
setGlobalAlpha(global)
Set alpha composition scope.
|
|
setGlobalAnchor(ax, ay)
|
|
setId(id)
|
|
Set this background image transformation.
|
|
setLocation(x{number}, y{number})
This method sets the position of an Actor inside its parent.
|
|
setMinimumSize(pw, ph)
Set this actors minimum layout size.
|
|
Set this model view matrix if the actor is Dirty.
|
|
Puts an Actor out of time line, that is, won't be transformed nor rendered.
|
|
setPaint(paint)
|
|
setParent(parent)
Set this actor's parent.
|
|
setPosition(x, y)
|
|
setPositionAnchor(pax, pay)
|
|
setPositionAnchored(x, y, pax, pay)
|
|
setPreferredSize(pw, ph)
Set this actors preferred layout size.
|
|
Make this actor not be laid out.
|
|
setRotation(angle)
A helper method for setRotationAnchored.
|
|
setRotationAnchor(rax, ray)
|
|
setRotationAnchored(angle, rx, ry)
This method sets Actor rotation around a given position.
|
|
setScale(sx, sy)
A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER
|
|
setScaleAnchor(sax, say)
|
|
setScaleAnchored(sx, sy, anchorx, anchory)
Modify the dimensions on an Actor.
|
|
<private> |
Calculates the 2D bounding box in canvas coordinates of the Actor.
|
setSize(w, h)
Sets an Actor's dimension
|
|
setSpriteIndex(index)
Set the actor's SpriteImage index from animation sheet.
|
|
setStrokeStyle(style)
Caches a stroke style in the Actor.
|
|
setUV(uvBuffer, uvIndex)
Set UV for this actor's quad.
|
|
setVisible(visible)
Set this actor invisible.
|
|
touchEnd(e)
|
|
touchMove(e)
|
|
touchStart(e)
Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH
|
|
viewToModel(point)
Transform a point from model to view space.
|
Class Detail
CAAT.Foundation.Actor()
CAAT.Foundation.Actor is the base animable element. It is the base object for Director, Scene and
Container.
CAAT.Actor is the simplest object instance CAAT manages. Every on-screen element is an Actor instance. An Actor has entity, it has a size, position and can have input sent to it. Everything that has a visual representation is an Actor, including Director and Scene objects.
This object has functionality for:
- Set location and size on screen. Actors are always rectangular shapes, but not needed to be AABB.
- Set affine transforms (rotation, scale and translation).
- Define life cycle.
- Manage alpha transparency.
- Manage and keep track of applied Behaviors. Behaviors apply transformations via key-framing.
- Compose transformations. A container Actor will transform its children before they apply their own transformation.
- Clipping capabilities. Either rectangular or arbitrary shapes.
- The API is developed to allow method chaining when possible.
- Handle input (either mouse events, touch, multitouch, keys and accelerometer).
- Show an image.
- Show some image animations.
- etc.
Field Detail
<private>
__super
AABB
This rectangle keeps the axis aligned bounding box in screen coords of this actor.
In can be used, among other uses, to realize whether two given actors collide regardless
the affine transformation is being applied on them.
alpha
Transparency value. 0 is totally transparent, 1 is totally opaque.
<static>
CAAT.Foundation.Actor.ANCHOR_BOTTOM
<static>
CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT
<static>
CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT
<static>
CAAT.Foundation.Actor.ANCHOR_CENTER
<static>
CAAT.Foundation.Actor.ANCHOR_CUSTOM
<static>
CAAT.Foundation.Actor.ANCHOR_LEFT
<static>
CAAT.Foundation.Actor.ANCHOR_RIGHT
<static>
CAAT.Foundation.Actor.ANCHOR_TOP
<static>
CAAT.Foundation.Actor.ANCHOR_TOP_LEFT
<static>
CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT
backgroundImage
Define this actor´s background image.
See SpriteImage object.
behaviorList
A collection of behaviors to modify this actor´s properties.
<static>
CAAT.Foundation.Actor.CACHE_DEEP
<static>
CAAT.Foundation.Actor.CACHE_NONE
<static>
CAAT.Foundation.Actor.CACHE_SIMPLE
cached
Caching as bitmap strategy. Suitable to cache very complex actors.
0 : no cache.
CACHE_SIMPLE : if a container, only cache the container.
CACHE_DEEP : if a container, cache the container and recursively all of its children.
clip
Will this actor be clipped before being drawn on screen ?
clipPath
If this.clip and this.clipPath===null, a rectangle will be used as clip area. Otherwise,
clipPath contains a reference to a CAAT.PathUtil.Path object.
<private>
dirty
Local matrix dirtyness flag.
discardable
Mark this actor as discardable. If an actor is expired and mark as discardable, if will be
removed from its parent.
duration
Marks from the time this actor is going to be animated, during how much time.
Forever by default.
expired
Mark this actor as expired, or out of the scene time.
fillStyle
any canvas rendering valid fill style.
<private>
frameAlpha
gestureEnabled
Is gesture recognition enabled on this actor ??
glEnabled
Is this actor enabled on WebGL ?
height
Actor's height. In parent's local coord. system.
id
Set this actor´ id so that it can be later identified easily.
inFrame
Is this actor processed in the last frame ?
invalid
If dirty rects are enabled, this flag indicates the rendering engine to invalidate this
actor´s screen area.
<private>
isAA
is this actor/container Axis aligned ? if so, much faster inverse matrices can be calculated.
isCachedActor
if this actor is cached, when destroy is called, it does not call 'clean' method, which clears some
internal properties.
isGlobalAlpha
true to make all children transparent, false, only this actor/container will be transparent.
lifecycleListenerList
A collection of this Actors lifecycle observers.
minimumSize
actor's layout minimum size.
modelViewMatrix
This actor´s affine transformation matrix.
modelViewMatrixI
mouseEnabled
Enable or disable input on this actor. By default, all actors receive input.
See also priority lists.
see demo4 for an example of input and priority lists.
<private>
oldX
<private>
oldY
parent
This actor's parent container.
pointed
preferredSize
actor´s layout preferred size.
preventLayout
Exclude this actor from automatic layout on its parent.
rotationAngle
This actor´s rotation angle in radians.
rotationX
Rotation Anchor Y. CAAT uses different Anchors for position, rotation and scale. Value 0-1.
rotationY
Rotation Anchor X. CAAT uses different Anchors for position, rotation and scale. Value 0-1.
scaleAnchor
A value that corresponds to any CAAT.Foundation.Actor.ANCHOR_* value.
scaleTX
Scale Anchor X. Value 0-1
scaleTY
Scale Anchor Y. Value 0-1
scaleX
ScaleX value.
scaleY
ScaleY value.
size_active
debug info.
size_total
debug info.
start_time
Marks since when this actor, relative to scene time, is going to be animated/drawn.
strokeStyle
any canvas rendering valid stroke style.
tAnchorX
Translation x anchor. 0..1
tAnchorY
Translation y anchor. 0..1
time
This actor´s scene time.
viewVertices
These 4 CAAT.Math.Point objects are the vertices of this actor´s non axis aligned bounding
box. If the actor is not rotated, viewVertices and AABB define the same bounding box.
visible
Make this actor visible or not.
An invisible actor avoids making any calculation, applying any behavior on it.
<private>
wdirty
Global matrix dirtyness flag.
width
Actor's width. In parent's local coord. system.
worldModelViewMatrix
This actor´s world affine transformation matrix.
worldModelViewMatrixI
x
x position on parent. In parent's local coord. system.
y
y position on parent. In parent's local coord. system.
Method Detail
<private>
__init()
<private>
__paintActor(director, time)
for js2native
- Parameters:
- director
- time
<private>
{*}
__scale1To(axis, scale, duration, delay, anchorX, anchorY, interpolator)
- Parameters:
- axis
- {CAAT.Scale1Behavior.AXIS_X|CAAT.Scale1Behavior.AXIS_Y} scale application axis
- scale
- {number} new Y scale
- duration
- {number} time to rotate
- delay
- {=number} millis to start rotation
- anchorX
- {=number} rotation anchor x
- anchorY
- {=number} rotation anchor y
- interpolator
- {=CAAT.Bahavior.Interpolator}
- Returns:
- {*}
<private>
__validateLayout()
addAnimation(name, array, time, callback)
- Parameters:
- name
- array
- time
- callback
addBehavior(behavior)
Add a Behavior to the Actor.
An Actor accepts an undefined number of Behaviors.
- Parameters:
- behavior
- {CAAT.Behavior.BaseBehavior}
- Returns:
- this
addListener(actorListener)
Adds an Actor's life cycle listener.
The developer must ensure the actorListener is not already a listener, otherwise
it will notified more than once.
- Parameters:
- actorListener
- {object} an object with at least a method of the form:
actorLyfeCycleEvent( actor, string_event_type, long_time )
animate(director, time)
Private
This method is called by the Director instance.
It applies the list of behaviors the Actor has registered.
- Parameters:
- director
- the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
- time
- an integer indicating the Scene time when the bounding box is to be drawn.
cacheAsBitmap(time, stragegy)
- Parameters:
- time
- {Number=}
- stragegy
- {CAAT.Foundation.Actor.CACHE_SIMPLE | CAAT.Foundation.Actor.CACHE_DEEP}
- Returns:
- this
centerAt(x, y)
Center this actor at position (x,y).
- Parameters:
- x
- {number} x position
- y
- {number} y position
- Returns:
- this
centerOn(x, y)
Center this actor at position (x,y).
- Parameters:
- x
- {number} x position
- y
- {number} y position
- Returns:
- this
clean()
contains(x, y)
Checks whether a coordinate is inside the Actor's bounding box.
- Parameters:
- x
- {number} a float
- y
- {number} a float
- Returns:
- boolean indicating whether it is inside.
{*}
create()
- Returns:
- {*}
<private>
destroy(time)
This method will be called internally by CAAT when an Actor is expired, and at the
same time, is flagged as discardable.
It notifies the Actor life cycle listeners about the destruction event.
- Parameters:
- time
- an integer indicating the time at wich the Actor has been destroyed.
disableDrag()
drawScreenBoundingBox(director, time)
Draw a bounding box with on-screen coordinates regardless of the transformations
applied to the Actor.
- Parameters:
- director
- {CAAT.Foundations.Director} object instance that contains the Scene the Actor is in.
- time
- {number} integer indicating the Scene time when the bounding box is to be drawn.
emptyBehaviorList()
Removes all behaviors from an Actor.
- Returns:
- this
enableDrag()
Enables a default dragging routine for the Actor.
This default dragging routine allows to:
scale the Actor by pressing shift+drag
rotate the Actor by pressing control+drag
scale non uniformly by pressing alt+shift+drag
- Returns:
- this
enableEvents(enable)
Enable or disable the event bubbling for this Actor.
- Parameters:
- enable
- {boolean} a boolean indicating whether the event bubbling is enabled.
- Returns:
- this
endAnimate(director, time)
- Parameters:
- director
- the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
- time
- an integer indicating the Scene time when the bounding box is to be drawn.
- Returns:
- this
findActorAtPosition(point)
Private
This method does the needed point transformations across an Actor hierarchy to devise
whether the parameter point coordinate lies inside the Actor.
- Parameters:
- point
- {CAAT.Math.Point}
- Returns:
- null if the point is not inside the Actor. The Actor otherwise.
findActorById(id)
- Parameters:
- id
fireEvent(sEventType, time)
Notifies the registered Actor's life cycle listener about some event.
- Parameters:
- sEventType
- an string indicating the type of event being notified.
- time
- an integer indicating the time related to Scene's timeline when the event is being notified.
gestureChange(rotation, scaleX, scaleY)
- Parameters:
- rotation
- scaleX
- scaleY
gestureEnd(rotation, scaleX, scaleY)
- Parameters:
- rotation
- scaleX
- scaleY
gestureStart(rotation, scaleX, scaleY)
- Parameters:
- rotation
- scaleX
- scaleY
getAnchor(anchor)
Private.
Gets a given anchor position referred to the Actor.
- Parameters:
- anchor
- Returns:
- an object of the form { x: float, y: float }
getAnchorPercent(anchor)
- Parameters:
- anchor
getBehavior(id)
- Parameters:
- id
getId()
getMinimumSize()
getPreferredSize()
{CAAT.GLTexturePage}
getTextureGLPage()
If GL is enables, get this background image's texture page, otherwise it will fail.
- Returns:
- {CAAT.GLTexturePage}
glNeedsFlush(director)
Test for compulsory gl flushing:
1.- opacity has changed.
2.- texture page has changed.
- Parameters:
- director
glSetShader(director)
Change texture shader program parameters.
- Parameters:
- director
initialize(overrides)
- Parameters:
- overrides
invalidate()
invalidateLayout()
isCached()
isGestureEnabled()
<private>
isInAnimationFrame(time)
This method is called by the Director to know whether the actor is on Scene time.
In case it was necessary, this method will notify any life cycle behaviors about
an Actor expiration.
- Parameters:
- time
- {number} time indicating the Scene time.
isVisible()
modelToModel(point, otherActor)
Transform a local coordinate point on this Actor's coordinate system into
another point in otherActor's coordinate system.
- Parameters:
- point
- {CAAT.Math.Point}
- otherActor
- {CAAT.Math.Actor}
<private>
modelToView(point)
Transform a point or array of points in model space to view space.
- Parameters:
- point
- {CAAT.Math.Point|Array} an object of the form {x : float, y: float}
- Returns:
- the source transformed elements.
mouseClick(mouseEvent)
Default mouseClick handler.
Mouse click events are received after a call to mouseUp method if no dragging was in progress.
- Parameters:
- mouseEvent
- {CAAT.Event.MouseEvent}
mouseDblClick(mouseEvent)
Default double click handler
- Parameters:
- mouseEvent
- {CAAT.Event.MouseEvent}
mouseDown(mouseEvent)
default mouse press in Actor handler.
- Parameters:
- mouseEvent
- {CAAT.Event.MouseEvent}
mouseDrag(mouseEvent)
default Actor mouse drag handler.
- Parameters:
- mouseEvent
- {CAAT.Event.MouseEvent}
mouseEnter(mouseEvent)
Default mouse enter on Actor handler.
- Parameters:
- mouseEvent
- {CAAT.Event.MouseEvent}
mouseExit(mouseEvent)
Default mouse exit on Actor handler.
- Parameters:
- mouseEvent
- {CAAT.Event.MouseEvent}
mouseMove(mouseEvent)
Default mouse move inside Actor handler.
- Parameters:
- mouseEvent
- {CAAT.Event.MouseEvent}
mouseOut(mouseEvent)
- Parameters:
- mouseEvent
mouseOver(mouseEvent)
- Parameters:
- mouseEvent
mouseUp(mouseEvent)
default mouse release in Actor handler.
- Parameters:
- mouseEvent
- {CAAT.Event.MouseEvent}
moveTo(x, y, duration, delay, interpolator, callback)
Move this actor to a position.
It creates and adds a new PathBehavior.
- Parameters:
- x
- {number} new x position
- y
- {number} new y position
- duration
- {number} time to take to get to new position
- delay
- {=number} time to wait before start moving
- interpolator
- {=CAAT.Behavior.Interpolator} a CAAT.Behavior.Interpolator instance
- callback
paint(director, time)
This method should me overriden by every custom Actor.
It will be the drawing routine called by the Director to show every Actor.
- Parameters:
- director
- {CAAT.Foundation.Director} instance that contains the Scene the Actor is in.
- time
- {number} indicating the Scene time in which the drawing is performed.
paintActor(director, time)
- Parameters:
- director
- the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
- time
- an integer indicating the Scene time when the bounding box is to be drawn.
- Returns:
- boolean indicating whether the Actor isInFrameTime
paintActorGL(director, time)
Set coordinates and uv values for this actor.
This function uses Director's coords and indexCoords values.
- Parameters:
- director
- time
playAnimation(name)
- Parameters:
- name
removeBehaviorById(id)
Remove a Behavior with id param as behavior identifier from this actor.
This function will remove ALL behavior instances with the given id.
- Parameters:
- id
- {number} an integer. return this;
removeBehaviour(behavior)
Remove a Behavior from the Actor.
If the Behavior is not present at the actor behavior collection nothing happends.
- Parameters:
- behavior
- {CAAT.Behavior.BaseBehavior}
removeListener(actorListener)
Removes an Actor's life cycle listener.
It will only remove the first occurrence of the given actorListener.
- Parameters:
- actorListener
- {object} an Actor's life cycle listener.
resetAnimationTime()
resetAsButton()
resetTransform()
Remove all transformation values for the Actor.
- Returns:
- this
{*}
rotateTo(angle, duration, delay, anchorX, anchorY, interpolator)
- Parameters:
- angle
- {number} new rotation angle
- duration
- {number} time to rotate
- delay
- {number=} millis to start rotation
- anchorX
- {number=} rotation anchor x
- anchorY
- {number=} rotation anchor y
- interpolator
- {CAAT.Behavior.Interpolator=}
- Returns:
- {*}
{*}
scaleTo(scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator)
- Parameters:
- scaleX
- {number} new X scale
- scaleY
- {number} new Y scale
- duration
- {number} time to rotate
- delay
- {=number} millis to start rotation
- anchorX
- {=number} rotation anchor x
- anchorY
- {=number} rotation anchor y
- interpolator
- {=CAAT.Behavior.Interpolator}
- Returns:
- {*}
{*}
scaleXTo(scaleX, duration, delay, anchorX, anchorY, interpolator)
- Parameters:
- scaleX
- {number} new X scale
- duration
- {number} time to rotate
- delay
- {=number} millis to start rotation
- anchorX
- {=number} rotation anchor x
- anchorY
- {=number} rotation anchor y
- interpolator
- {=CAAT.Behavior.Interpolator}
- Returns:
- {*}
{*}
scaleYTo(scaleY, duration, delay, anchorX, anchorY, interpolator)
- Parameters:
- scaleY
- {number} new Y scale
- duration
- {number} time to rotate
- delay
- {=number} millis to start rotation
- anchorX
- {=number} rotation anchor x
- anchorY
- {=number} rotation anchor y
- interpolator
- {=CAAT.Behavior.Interpolator}
- Returns:
- {*}
setAlpha(alpha)
Stablishes the Alpha transparency for the Actor.
If it globalAlpha enabled, this alpha will the maximum alpha for every contained actors.
The alpha must be between 0 and 1.
- Parameters:
- alpha
- a float indicating the alpha value.
- Returns:
- this
setAnimationEndCallback(f)
- Parameters:
- f
setAnimationImageIndex(ii)
Set this actor's background SpriteImage its animation sequence.
In its simplet's form a SpriteImage treats a given image as an array of rows by columns
subimages. If you define d Sprite Image of 2x2, you'll be able to draw any of the 4 subimages.
This method defines the animation sequence so that it could be set [0,2,1,3,2,1] as the
animation sequence
- Parameters:
- ii
- {Array
} an array of integers.
setAsButton(buttonImage, iNormal, iOver, iPress, iDisabled, fn)
Set this actor behavior as if it were a Button. The actor size will be set as SpriteImage's
single size.
- Parameters:
- buttonImage
- {CAAT.Foundation.SpriteImage} sprite image with button's state images.
- iNormal
- {number} button's normal state image index
- iOver
- {number} button's mouse over state image index
- iPress
- {number} button's pressed state image index
- iDisabled
- {number} button's disabled state image index
- fn
- {function(button{CAAT.Foundation.Actor})} callback function
setBackgroundImage(image, adjust_size_to_image)
Set this actor's background image.
The need of a background image is to kept compatibility with the new CSSDirector class.
The image parameter can be either an Image/Canvas or a CAAT.Foundation.SpriteImage instance. If an image
is supplied, it will be wrapped into a CAAT.Foundation.SriteImage instance of 1 row by 1 column.
If the actor has set an image in the background, the paint method will draw the image, otherwise
and if set, will fill its background with a solid color.
If adjust_size_to_image is true, the host actor will be redimensioned to the size of one
single image from the SpriteImage (either supplied or generated because of passing an Image or
Canvas to the function). That means the size will be set to [width:SpriteImage.singleWidth,
height:singleHeight].
WARN: if using a CSS renderer, the image supplied MUST be a HTMLImageElement instance.
- Parameters:
- image
- {Image|HTMLCanvasElement|CAAT.Foundation.SpriteImage}
- adjust_size_to_image
- {boolean} whether to set this actor's size based on image parameter.
- Returns:
- this
setBackgroundImageOffset(ox, oy)
Set this actor's background SpriteImage offset displacement.
The values can be either positive or negative meaning the texture space of this background
image does not start at (0,0) but at the desired position.
- Parameters:
- ox
- {number} horizontal offset
- oy
- {number} vertical offset
- Returns:
- this
setBounds(x{number}, y{number}, w{number}, h{number})
Set location and dimension of an Actor at once.
- Parameters:
- x{number}
- a float indicating Actor's x position.
- y{number}
- a float indicating Actor's y position
- w{number}
- a float indicating Actor's width
- h{number}
- a float indicating Actor's height
- Returns:
- this
setButtonImageIndex(_normal, _over, _press, _disabled)
- Parameters:
- _normal
- _over
- _press
- _disabled
setCachedActor(cached)
- Parameters:
- cached
setChangeFPS(time)
- Parameters:
- time
setClip(enable, clipPath)
Set this Actor's clipping area.
- Parameters:
- enable
- {boolean} enable clip area.
- clipPath
- {CAAT.Path.Path=} An optional path to apply clip with. If enabled and clipPath is not set, a rectangle will be used.
setDiscardable(discardable)
Set discardable property. If an actor is discardable, upon expiration will be removed from
scene graph and hence deleted.
- Parameters:
- discardable
- {boolean} a boolean indicating whether the Actor is discardable.
- Returns:
- this
setExpired(time)
Sets this Actor as Expired.
If this is a Container, all the contained Actors won't be nor drawn nor will receive
any event. That is, expiring an Actor means totally taking it out the Scene's timeline.
- Parameters:
- time
- {number} an integer indicating the time the Actor was expired at.
- Returns:
- this.
setFillStyle(style)
Caches a fillStyle in the Actor.
- Parameters:
- style
- a valid Canvas rendering context fillStyle.
- Returns:
- this
setFrameTime(startTime, duration)
Sets the time life cycle for an Actor.
These values are related to Scene time.
- Parameters:
- startTime
- an integer indicating the time until which the Actor won't be visible on the Scene.
- duration
- an integer indicating how much the Actor will last once visible.
- Returns:
- this
setGestureEnabled(enable)
- Parameters:
- enable
setGLCoords(glCoords, glCoordsIndex)
TODO: set GLcoords for different image transformations.
- Parameters:
- glCoords
- glCoordsIndex
setGlobalAlpha(global)
Set alpha composition scope. global will mean this alpha value will be its children maximum.
If set to false, only this actor will have this alpha value.
- Parameters:
- global
- {boolean} whether the alpha value should be propagated to children.
setGlobalAnchor(ax, ay)
- Parameters:
- ax
- ay
setId(id)
- Parameters:
- id
setImageTransformation(it)
Set this background image transformation.
If GL is enabled, this parameter has no effect.
- Parameters:
- it
- any value from CAAT.Foundation.SpriteImage.TR_*
- Returns:
- this
setLocation(x{number}, y{number})
This method sets the position of an Actor inside its parent.
- Parameters:
- x{number}
- a float indicating Actor's x position
- y{number}
- a float indicating Actor's y position
- Returns:
- this
{*}
setMinimumSize(pw, ph)
Set this actors minimum layout size.
- Parameters:
- pw
- {number}
- ph
- {number}
- Returns:
- {*}
setModelViewMatrix()
Set this model view matrix if the actor is Dirty.
mm[2]+= this.x;
mm[5]+= this.y;
if ( this.rotationAngle ) {
this.modelViewMatrix.multiply( m.setTranslate( this.rotationX, this.rotationY) );
this.modelViewMatrix.multiply( m.setRotation( this.rotationAngle ) );
this.modelViewMatrix.multiply( m.setTranslate( -this.rotationX, -this.rotationY) ); c= Math.cos( this.rotationAngle );
}
if ( this.scaleX!=1 || this.scaleY!=1 && (this.scaleTX || this.scaleTY )) {
this.modelViewMatrix.multiply( m.setTranslate( this.scaleTX , this.scaleTY ) );
this.modelViewMatrix.multiply( m.setScale( this.scaleX, this.scaleY ) );
this.modelViewMatrix.multiply( m.setTranslate( -this.scaleTX , -this.scaleTY ) );
}
- Returns:
- this
setOutOfFrameTime()
Puts an Actor out of time line, that is, won't be transformed nor rendered.
- Returns:
- this
setPaint(paint)
- Parameters:
- paint
setParent(parent)
Set this actor's parent.
- Parameters:
- parent
- {CAAT.Foundation.ActorContainer}
- Returns:
- this
setPosition(x, y)
- Parameters:
- x
- y
setPositionAnchor(pax, pay)
- Parameters:
- pax
- pay
setPositionAnchored(x, y, pax, pay)
- Parameters:
- x
- y
- pax
- pay
{*}
setPreferredSize(pw, ph)
Set this actors preferred layout size.
- Parameters:
- pw
- {number}
- ph
- {number}
- Returns:
- {*}
setPreventLayout(b)
Make this actor not be laid out.
- Parameters:
- b
setRotation(angle)
A helper method for setRotationAnchored. This methods stablishes the center
of rotation to be the center of the Actor.
- Parameters:
- angle
- a float indicating the angle in radians to rotate the Actor.
- Returns:
- this
setRotationAnchor(rax, ray)
- Parameters:
- rax
- ray
setRotationAnchored(angle, rx, ry)
This method sets Actor rotation around a given position.
- Parameters:
- angle
- {number} indicating the angle in radians to rotate the Actor.
- rx
- {number} value in the range 0..1
- ry
- {number} value in the range 0..1
- Returns:
- this;
setScale(sx, sy)
A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER
- Parameters:
- sx
- a float indicating a width size multiplier.
- sy
- a float indicating a height size multiplier.
- Returns:
- this
- See:
- setScaleAnchored
setScaleAnchor(sax, say)
- Parameters:
- sax
- say
setScaleAnchored(sx, sy, anchorx, anchory)
Modify the dimensions on an Actor.
The dimension will not affect the local coordinates system in opposition
to setSize or setBounds.
- Parameters:
- sx
- {number} width scale.
- sy
- {number} height scale.
- anchorx
- {number} x anchor to perform the Scale operation.
- anchory
- {number} y anchor to perform the Scale operation.
- Returns:
- this;
<private>
setScreenBounds()
Calculates the 2D bounding box in canvas coordinates of the Actor.
This bounding box takes into account the transformations applied hierarchically for
each Scene Actor.
setSize(w, h)
Sets an Actor's dimension
- Parameters:
- w
- a float indicating Actor's width.
- h
- a float indicating Actor's height.
- Returns:
- this
setSpriteIndex(index)
Set the actor's SpriteImage index from animation sheet.
- Parameters:
- index
- {number}
- Returns:
- this
setStrokeStyle(style)
Caches a stroke style in the Actor.
- Parameters:
- style
- a valid canvas rendering context stroke style.
- Returns:
- this
setUV(uvBuffer, uvIndex)
Set UV for this actor's quad.
- Parameters:
- uvBuffer
- {Float32Array}
- uvIndex
- {number}
setVisible(visible)
Set this actor invisible.
The actor is animated but not visible.
A container won't show any of its children if set visible to false.
- Parameters:
- visible
- {boolean} set this actor visible or not.
- Returns:
- this
stopCacheAsBitmap()
touchEnd(e)
- Parameters:
- e
touchMove(e)
- Parameters:
- e
touchStart(e)
Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH
- Parameters:
- e
viewToModel(point)
Transform a point from model to view space.
WARNING: every call to this method calculates actor's world model view matrix.
- Parameters:
- point
- {CAAT.Math.Point} a point in screen space to be transformed to model space.
- Returns:
- the source point object