Class CAAT.Foundation.Director
Extends
CAAT.Foundation.ActorContainer.
Defined in: Director.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
<private> |
Calculated gesture event rotation.
|
<private> |
Calculated gesture event scale.
|
<private> |
this director´s audio manager.
|
Some browser related information.
|
|
<private> |
The canvas the Director draws on.
|
<private> |
current dirty rects.
|
Clear screen strategy:
CAAT.Foundation.Director.CLEAR_NONE : director won´t clear the background.
|
|
<static> |
CAAT.Foundation.Director.CLEAR_ALL
|
<static> |
CAAT.Foundation.Director.CLEAR_DIRTY_RECTS
|
<static> |
CAAT.Foundation.Director.CLEAR_NONE
|
<private> |
webGL vertex array
|
<private> |
webGL vertex indices.
|
This director´s canvas rendering context.
|
|
<private> |
webGL current shader opacity.
|
The current Scene.
|
|
<private> |
webGL current texture page.
|
flag indicating debug mode.
|
|
<private> |
Dirty rects cache.
|
<private> |
Dirty rects enabled ??
|
<private> |
Number of currently allocated dirty rects.
|
is input in drag mode ?
|
|
<private> |
Dirty rects count debug info.
|
Rendered frames counter.
|
|
<private> |
draw tris front_to_back or back_to_front ?
|
<private> |
3d context
|
<private> |
is WebGL enabled as renderer ?
|
<private> |
if webGL is on, CAAT will texture pack all images transparently.
|
<private> |
The only GLSL program for webGL
|
An array of JSON elements of the form { id:string, image:Image }
|
|
<private> |
if CAAT.NO_RAF is set (no request animation frame), this value is the setInterval returned
id.
|
is the left mouse button pressed ?.
|
|
director's last actor receiving input.
|
|
<private> |
mouse coordinate related to canvas 0,0 coord.
|
<private> |
Number of dirty rects.
|
<private> |
currently unused.
|
<private> |
This method will be called after rendering any director scene.
|
<private> |
This method will be called before rendering any director scene.
|
Callback when the window is resized.
|
|
<private> |
webGL projection matrix
|
<private> |
previous mouse position cache.
|
<static> |
CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS
|
<static> |
CAAT.Foundation.Director.RENDER_MODE_DIRTY
|
Set CAAT render mode.
|
|
<private> |
Window resize strategy.
|
<static> |
CAAT.Foundation.Director.RESIZE_BOTH
|
<static> |
CAAT.Foundation.Director.RESIZE_HEIGHT
|
<static> |
CAAT.Foundation.Director.RESIZE_NONE
|
<static> |
CAAT.Foundation.Director.RESIZE_PROPORTIONAL
|
<static> |
CAAT.Foundation.Director.RESIZE_WIDTH
|
This director scene collection.
|
|
<private> |
Retina display deicePixels/backingStorePixels ratio
|
<private> |
screen mouse coordinates.
|
<private> |
Currently used dirty rects.
|
statistics object
|
|
Is this director stopped ?
|
|
<private> |
director time.
|
<private> |
global director timeline.
|
<private> |
Director´s timer manager.
|
<private> |
Touches information.
|
<private> |
if CAAT.CACHE_SCENE_ON_CHANGE is set, this scene will hold a cached copy of the exiting scene.
|
<private> |
webGL uv texture indices
|
- Fields borrowed from class CAAT.Foundation.ActorContainer:
- activeChildren, addHint, boundingBox, childrenList, layoutInvalidated, layoutManager, pendingChildrenList, runion
- Fields borrowed from class CAAT.Foundation.Actor:
- __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
Method Attributes | Method Name and Description |
---|---|
<private> | |
<private> |
__gestureChange(scale, rotation)
|
<private> |
__gestureEnd(scale, rotation)
|
<private> |
__gestureStart(scale, rotation)
|
<private> |
__init()
|
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> | |
<private> |
Same as mouseDown but not preventing event.
|
<private> | |
addAudio(id, url)
Adds an audio to the cache.
|
|
addChild(scene)
Adds an scene to this Director.
|
|
addDirtyRect(rectangle)
Add a rectangle to the list of dirty screen areas which should be redrawn.
|
|
addHandlers(canvas)
|
|
addImage(id, image, noUpdateGL)
Add a new image to director's image cache.
|
|
addScene(scene)
Add a new Scene to Director's Scene list.
|
|
animate(director, time)
A director is a very special kind of actor.
|
|
audioLoop(id)
Loops an audio instance identified by the id.
|
|
audioPlay(id)
Plays the audio instance identified by the id.
|
|
cancelPlay(id)
|
|
cancelPlayByChannel(audioObject)
|
|
clean()
|
|
Creates an initializes a Scene object.
|
|
createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel)
|
|
cumulateOffset(node, parent, prop)
Acculumate dom elements position to properly offset on-screen mouse/touch events.
|
|
deleteImage(id, noUpdateGL)
|
|
easeEnd(scene, b_easeIn)
Scene easing listener.
|
|
easeIn(inSceneIndex, type, time, alpha, anchor, interpolator)
This method changes Director's current Scene to the scene index indicated by
inSceneIndex parameter.
|
|
easeInOut(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut)
This method offers full control over the process of switching between any given two Scenes.
|
|
easeInOutRandom(inIndex, outIndex, time, alpha)
This method will switch between two given Scene indexes (ie, take away scene number 2,
and bring in scene number 5).
|
|
Removes Director's scenes.
|
|
enableEvents(onElement)
|
|
enableResizeEvents(mode, onResizeCallback)
Enable window resize events and set redimension policy.
|
|
endLoop()
|
|
endSound()
|
|
findActorAtPosition(point)
|
|
Get this Director's AudioManager instance.
|
|
Return the running browser name.
|
|
Return the running browser version.
|
|
getCanvasCoord(point, e)
Normalize input event coordinates to be related to (0,0) canvas position.
|
|
Return the index of the current scene in the Director's scene list.
|
|
getImage(sId)
Gets the resource with the specified resource name.
|
|
Get the number of scenes contained in the Director.
|
|
getOffset(node)
|
|
Return the operating system name.
|
|
getScene(index)
Get a concrete director's scene.
|
|
getSceneById(id)
|
|
getSceneIndex(scene)
Return the index for a given Scene object contained in the Director.
|
|
getValueForKey(key)
|
|
glFlush()
|
|
glRender(vertex, coordsIndex, uv)
Render buffered elements.
|
|
glReset()
|
|
initialize(width, height, canvas, proxy)
This method performs Director initialization.
|
|
initializeGL(width, height, canvas, proxy)
Experimental.
|
|
loop(fps, callback, callback2)
|
|
mouseDown(mouseEvent)
|
|
mouseDrag(mouseEvent)
|
|
mouseEnter(mouseEvent)
|
|
mouseExit(mouseEvent)
|
|
mouseMove(mouseEvent)
|
|
mouseUp(mouseEvent)
|
|
musicPlay(id)
|
|
render(time)
This is the entry point for the animation system of the Director.
|
|
Starts the director animation.If no scene is explicitly selected, the current Scene will
be the first scene added to the Director.
|
|
renderToContext(ctx, scene)
This method draws an Scene to an offscreen canvas.
|
|
<private> |
Reset statistics information.
|
If the director has renderingMode: DIRTY, the timeline must be reset to register accurate frame measurement.
|
|
scheduleDirtyRect(rectangle)
This method is used when asynchronous operations must produce some dirty rectangle painting.
|
|
setAudioFormatExtensions(extensions)
|
|
setBounds(x, y, w, h)
Set this director's bounds as well as its contained scenes.
|
|
setClear(clear)
This method states whether the director must clear background before rendering
each frame.
|
|
setGLCurrentOpacity(opacity)
|
|
setGLTexturePage(tp)
|
|
setImagesCache(imagesCache, tpW, tpH)
|
|
setMusicEnabled(enabled)
|
|
setScaleProportional(w, h)
|
|
setScene(sceneIndex)
Changes (or sets) the current Director scene to the index
parameter.
|
|
setSoundEffectsEnabled(enabled)
|
|
setValueForKey(key, value)
|
|
setVolume(id, volume)
|
|
switchToNextScene(time, alpha, transition)
Sets the previous Scene in sequence as the current Scene.
|
|
switchToPrevScene(time, alpha, transition)
Sets the previous Scene in sequence as the current Scene.
|
|
switchToScene(iNewSceneIndex, time, alpha, transition)
This method will change the current Scene by the Scene indicated as parameter.
|
|
windowResized(w, h)
|
- Methods borrowed from class CAAT.Foundation.ActorContainer:
- __paintActor, __validateLayout, __validateTree, addActor, addActorImmediately, addChildAt, addChildDelayed, addChildImmediately, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorById, findChild, getChildAt, getLayout, getNumActiveChildren, getNumChildren, invalidateLayout, paintActor, paintActorGL, recalcSize, removeChild, removeChildAt, removeFirstChild, removeLastChild, setLayout, setZOrder
- Methods borrowed from class CAAT.Foundation.Actor:
- __scale1To, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, disableDrag, emptyBehaviorList, enableDrag, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, invalidate, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseOut, mouseOver, moveTo, paint, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
- Parameters:
- scale
- rotation
- Parameters:
- scale
- rotation
- Parameters:
- scale
- rotation
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- e
- Parameters:
- id
- url
- Returns:
- this
- See:
- CAAT.Module.Audio.AudioManager.addAudio
- Parameters:
- scene
- {CAAT.Foundation.Scene} a scene object.
- Parameters:
- rectangle
- {CAAT.Rectangle}
- Parameters:
- canvas
director.addImage(id,image,false)
many times and a final call with
director.addImage(id,image,true)
to finally command the director to create texture pages.
- Parameters:
- id
- {string|object} an identitifier to retrieve the image with
- image
- {Image|HTMLCanvasElement} image to add to cache
- noUpdateGL
- {!boolean} unless otherwise stated, the director will try to recreate the texture pages.
- easeIn
- easeInOut
- easeInOutRandom
- setScene
- or any of the scene switching methods
- Parameters:
- scene
- {CAAT.Foundation.Scene}
- Parameters:
- director
- {CAAT.Director} redundant reference to CAAT.Director itself
- time
- {number} director time.
- Parameters:
- id
- {object} the object used to store a sound in the audioCache.
- Returns:
- {HTMLElement|null} the value from audioManager.loop
- Parameters:
- id
- {object} the object used to store a sound in the audioCache.
- Parameters:
- id
- Parameters:
- audioObject
- Returns:
- {CAAT.Scene}
- Parameters:
- startTime
- duration
- callback_timeout
- callback_tick
- callback_cancel
- Parameters:
- node
- parent
- prop
- Parameters:
- id
- noUpdateGL
- Parameters:
- scene
- {CAAT.Foundation.Scene} the scene that has just been brought in or taken out of the director.
- b_easeIn
- {boolean} scene enters or exits ?
- Parameters:
- inSceneIndex
- integer indicating the new Scene to set as current.
- type
- integer indicating the type of transition to apply to bring the new current Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION.
- time
- integer indicating how much time in milliseconds the Scene entrance will take.
- alpha
- boolean indicating whether alpha transparency fading will be applied to the entereing Scene.
- anchor
- integer indicating the anchor to fix for Scene transition. It will be any of CAAT.Actor.prototype.ANCHOR_* values.
- interpolator
- an CAAT.Interpolator object indicating the interpolation function to apply.
- See:
The type of transition will be one of the following values defined in CAAT.Foundation.Scene.prototype:
- EASE_ROTATION
- EASE_SCALE
- EASE_TRANSLATION
The anchor will be any of these values defined in CAAT.Foundation.Actor:
- ANCHOR_CENTER
- ANCHOR_TOP
- ANCHOR_BOTTOM
- ANCHOR_LEFT
- ANCHOR_RIGHT
- ANCHOR_TOP_LEFT
- ANCHOR_TOP_RIGHT
- ANCHOR_BOTTOM_LEFT
- ANCHOR_BOTTOM_RIGHT
In example, for an entering scene performing a EASE_SCALE transition, the anchor is the point by which the scene will scaled.
- Parameters:
- inSceneIndex
- integer indicating the Scene index to bring in to the Director.
- typein
- integer indicating the type of transition to apply to the bringing in Scene.
- anchorin
- integer indicating the anchor of the bringing in Scene.
- outSceneIndex
- integer indicating the Scene index to take away from the Director.
- typeout
- integer indicating the type of transition to apply to the taking away in Scene.
- anchorout
- integer indicating the anchor of the taking away Scene.
- time
- inteter indicating the time to perform the process of switchihg between Scene object in milliseconds.
- alpha
- boolean boolean indicating whether alpha transparency fading will be applied to the scenes.
- interpolatorIn
- CAAT.Behavior.Interpolator object to apply to entering scene.
- interpolatorOut
- CAAT.Behavior.Interpolator object to apply to exiting scene.
It will randomly choose for each Scene the type of transition to apply and the anchor point of each transition type.
It will also set for different kind of transitions the following interpolators:
- EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4.
- EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4
- EASE_TRANSLATION -> BounceOutInterpolator
These are the default values, and could not be changed by now. This method in final instance delegates the process to easeInOutMethod.
- Parameters:
- inIndex
- integer indicating the entering scene index.
- outIndex
- integer indicating the exiting scene index.
- time
- integer indicating the time to take for the process of Scene in/out in milliseconds.
- alpha
- boolean indicating whether alpha transparency fading should be applied to transitions.
- See:
- easeInOutMethod.
- Parameters:
- onElement
- Parameters:
- mode
- {number} RESIZE_BOTH, RESIZE_WIDTH, RESIZE_HEIGHT, RESIZE_NONE.
- onResizeCallback
- {function(director{CAAT.Director}, width{integer}, height{integer})} a callback to notify on canvas resize.
- Parameters:
- point
- Returns:
- {CAAT.AudioManager} the AudioManager instance.
- Returns:
- {string} the browser name.
- Returns:
- {string} the browser version.
- Parameters:
- point
- {CAAT.Math.Point} canvas coordinate.
- e
- {MouseEvent} a mouse event from an input event.
- Returns:
- {number} the current scene's index.
imagesCache
where you can store a JSON of the form
[ { id: imageId, image: imageObject } ]
.
This structure will be used as a resources cache.
There's a CAAT.Module.ImagePreloader class to preload resources and
generate this structure on loading finalization.
- Parameters:
- sId
- {object} an String identifying a resource.
- Returns:
- {number} the number of scenes contained in the Director.
- Parameters:
- node
- Returns:
- {string} the os name.
- Parameters:
- index
- {number} an integer indicating the scene index.
- Returns:
- {CAAT.Foundation.Scene} a CAAT.Scene object instance or null if the index is oob.
- Parameters:
- id
- Parameters:
- scene
- {CAAT.Foundation.Scene}
- Parameters:
- key
- Parameters:
- vertex
- coordsIndex
- uv
- Parameters:
- width
- {number} a canvas width
- height
- {number} a canvas height
- canvas
- {HTMLCanvasElement=} An optional Canvas object.
- proxy
- {HTMLElement} this object can be an event proxy in case you'd like to layer different elements and want events delivered to the correct element.
- Returns:
- this
- Parameters:
- width
- height
- canvas
- proxy
- Parameters:
- fps
- callback
- callback2
- Parameters:
- mouseEvent
- Parameters:
- mouseEvent
- Parameters:
- mouseEvent
- Parameters:
- mouseEvent
- Parameters:
- mouseEvent
- Parameters:
- mouseEvent
- Parameters:
- id
- Parameters:
- time
- {number} integer indicating the elapsed time between two consecutive frames of the Director.
The fps parameter will set the animation quality. Higher values, means CAAT will try to render more frames in the same second (at the expense of cpu power at least until hardware accelerated canvas rendering context are available). A value of 60 is a high frame rate and should not be exceeded.
Until the creation of this method, both scenes where drawn while transitioning with its performance penalty since drawing two scenes could be twice as expensive than drawing only one.
Though a high performance increase, we should keep an eye on memory consumption.
- Parameters:
- ctx
- a
canvas.getContext('2d')
instnce. - scene
- {CAAT.Foundation.Scene} the scene to draw offscreen.
- Parameters:
- rectangle
- Parameters:
- extensions
- Parameters:
- x
- {number} ignored, will be 0.
- y
- {number} ignored, will be 0.
- w
- {number} director width.
- h
- {number} director height.
- Returns:
- this
- Parameters:
- clear
- {CAAT.Director.CLEAR_ALL | CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS}
- Returns:
- this.
- Parameters:
- opacity
- Parameters:
- tp
- Parameters:
- imagesCache
- tpW
- tpH
- Parameters:
- enabled
- Parameters:
- w
- h
- Parameters:
- sceneIndex
- {number} an integer indicating the index of the target Scene to be shown.
- Parameters:
- enabled
- Parameters:
- key
- value
- Parameters:
- id
- volume
- Parameters:
- time
- {number} integer indicating the time the Scene transition will take.
- alpha
- {boolean} a boolean indicating whether Scene transition should be fading.
- transition
- {boolean} a boolean indicating whether the scene change must smoothly animated.
- See:
- switchToScene.
- Parameters:
- time
- {number} integer indicating the time the Scene transition will take.
- alpha
- {boolean} a boolean indicating whether Scene transition should be fading.
- transition
- {boolean} a boolean indicating whether the scene change must smoothly animated.
- See:
- switchToScene.
- Parameters:
- iNewSceneIndex
- {number} an integer indicating the index of the new scene to run on the Director.
- time
- {number} an integer indicating the time the Scene transition will take.
- alpha
- {boolean} a boolean indicating whether Scene transition should be fading.
- transition
- {boolean} a boolean indicating whether the scene change must smoothly animated.
- See:
- easeInOutRandom
- Parameters:
- w
- h