doodle.createDisplay
Description:
- Display (element:HTMLElement, options:object) :Display
-
Inherits
- ElementNode
- Node
- Emitter
- Object
Parameters
- element:HTMLElement – [optional]
- options:object – [optional]
Returns
- Display –
Throws
- TypeError – Must be a block style element.
- SyntaxError –
Examples
-
var display = doodle.createDisplay;
display.width = 400; -
var display = doodle.createDisplay(function () {
this.width = 400;
});
Properties
- parent :null
-
A Display has no parent.
Returns
- null –
- allChildren :Array
-
All descendants of the display, in scene graph order.
Returns
- Array – [read-only]
- debug.boundingBox :string
-
Color of the bounding box outline for nodes on the display. Display a particular node's bounds with node.debug.boundingBox = true
Returns
- string –
- frameRate :number|false
-
Determines the interval to dispatch the event type Event.ENTER_FRAME. This event is dispatched simultaneously to all display objects listenting for this event. It does not go through a "capture phase" and is dispatched directly to the target, whether the target is on the display list or not.
Returns
- number|false –
Throws
- TypeError –
- RangeError –
- root :Display
-
Display always returns itself as root.
Returns
- Display –
- height :number
-
Display height. Setting this affects all it's children layers.
Returns
- number –
Throws
- TypeError –
- width :number
-
Display width. Setting this affects all it's children layers.
Returns
- number –
Throws
- TypeError –
- context :CanvasRenderingContext2D
-
drawing context to use
Returns
- CanvasRenderingContext2D –
- mouseX :number
-
Mouse x position on display.
Returns
- number – [read-only]
- mouseY :number
-
Mouse y position on display.
Returns
- number – [read-only]
- alpha :number
-
Returns
- number –
Throws
- TypeError –
- backgroundColor :Color
-
Returns
- Color –
- backgroundImage :HTMLImageElement
-
Returns
- HTMLImageElement –
Throws
- TypeError –
- backgroundRepeat :string
-
Returns
- string –
Throws
- TypeError –
- SyntaxError –
- children :Array
-
Returns
- Array –
- clearBitmap :boolean
-
Returns
- boolean –
Throws
- TypeError –
- element :HTMLElement
-
Returns
- HTMLElement –
- id :string
-
Returns
- string –
Throws
- TypeError –
- rotation :number
-
Returns
- number –
- transform :Matrix
-
Returns
- Matrix –
- visible :boolean
-
Returns
- boolean –
Throws
- TypeError –
- x :number
-
Returns
- number –
- y :number
-
Returns
- number –
- debug.stats :Stats|boolean
-
Overlay a stats meter on the display. See http://github.com/mrdoob/stats.js for more info. To include in a compiled build, use ./build/make-doodle -S
Returns
- Stats|boolean –
Throws
- TypeError –
- toString :string
-
Returns the string representation of the specified object.
Returns
- string –
Methods
- addChildAt (layer:Layer, index:number) :Layer
-
Add a layer to the display's children at the given array position. Layer inherits the dimensions of the display.
Parameters
- layer:Layer –
- index:number –
Returns
- Layer –
Throws
- TypeError –
- createLayer () :Layer
-
Add a new layer to the display's children.
Returns
- Layer –
Throws
- TypeError –
- on (type:string, listener:Function) :void
-
Adds an event listener on an Emitter object. This is convenience alias for Emitter.addListener(type, listener, useCapture=false).
Parameters
- type:string –
- listener:Function –
Throws
- TypeError –
- once (type:string, listener:Function) :void
-
Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.
Parameters
- type:string –
- listener:Function –
Throws
- TypeError –
- appendTo () :Node
-
Adds this node to the given node's children.
Returns
- Node –
Throws
- TypeError –
- layers () :array
-
Alias for display.children, since every child is a Layer.
Returns
- array –
- setChildIndex (child:Node, index:number) :void
-
Changes the position of an existing child in the node's children array. This affects the layering of child objects.
Parameters
- child:Node –
- index:number –
Throws
- TypeError –
- swapChildrenAt (idx1:number, idx2:number) :void
-
Change the display order of two child layers at the given index.
Parameters
- idx1:number –
- idx2:number –
Throws
- TypeError –
- willTrigger (type:string) :boolean
-
Checks whether an event listener is registered with this Emitter object or any of its ancestors for the specified event type. The difference between the hasListener() and the willTrigger() methods is that hasListener() examines only the object to which it belongs, whereas the willTrigger() method examines the entire event flow for the event specified by the type parameter.
Parameters
- type:string – The type of event.
Returns
- boolean –
Throws
- TypeError –
- hasListener (type:string) :boolean
-
Checks whether the Emitter object has any listeners registered for a specific type of event.
Parameters
- type:string –
Returns
- boolean –
Throws
- TypeError –
- contains (node:Node) :boolean
-
Determine if node is among it's children, grandchildren, etc.
Parameters
- node:Node –
Returns
- boolean –
Throws
- TypeError –
- emit (event:doodle.events.Event) :boolean
-
Dispatches an event into the event flow. The event target is the Emitter object upon which the emit() method is called.
Parameters
- event:doodle.events.Event –
Returns
- boolean – true if the event was successfully dispatched.
Throws
- TypeError –
- broadcast (event:doodle.events.Event) :boolean
-
Dispatches an event to every object with an active listener. Ignores propagation path, objects come from
Parameters
- event:doodle.events.Event –
Returns
- boolean – True if the event was successfully dispatched.
Throws
- TypeError –
- Error –
- handleEvent (event:doodle.events.Event) :boolean
-
Lookup and call listener if registered for specific event type.
Parameters
- event:doodle.events.Event –
Returns
- boolean – true if node has listeners of event type.
Throws
- TypeError –
- addChild (node:Node) :Node
-
Parameters
- node:Node –
Returns
- Node –
Throws
- TypeError –
- createNode () :void
-
- createSprite () :void
-
- getChildById (id:string) :Node|undefined
-
Parameters
- id:string –
Returns
- Node|undefined –
Throws
- TypeError –
- globalToLocal (pt:Point) :Point
-
Parameters
- pt:Point –
Returns
- Point –
Throws
- TypeError –
- localToGlobal (pt:Point) :Point
-
Parameters
- pt:Point –
Returns
- Point –
Throws
- TypeError –
- removeAllChildren () :void
-
Throws
- TypeError –
- removeChildById (id:string) :Node
-
Parameters
- id:string –
Returns
- Node – Removed child node.
Throws
- TypeError –
- removeChild (node:Node) :Node
-
Parameters
- node:Node –
Returns
- Node – Removed child node.
Throws
- TypeError –
- ReferenceError –
- rotate (deg:number) :number
-
Parameters
- deg:number –
Returns
- number –
- scaleX (sx:number) :number
-
Parameters
- sx:number –
Returns
- number –
- scaleY (sy:number) :number
-
Parameters
- sy:number –
Returns
- number –
- swapChildren (node1:Node, node2:Node) :void
-
Parameters
- node1:Node –
- node2:Node –
Throws
- TypeError –
- addListener (type:string, listener:Function) :void
-
Registers an event listener object with an Emitter object so that the listener receives notification of an event.
Parameters
- type:string –
- listener:Function –
Throws
- TypeError –
- removeChildAt (index:number) :void
-
Remove a layer from the display's children at the given array position.
Parameters
- index:number –
Throws
- TypeError –
- removeLayer (id:string) :void
-
Remove a layer with a given name from the display's children.
Parameters
- id:string –
Throws
- TypeError –
- removeListener (type:string, listener:Function) :void
-
Removes a listener from the Emitter object.
Parameters
- type:string –
- listener:Function –
Throws
- TypeError –
- removeAllListeners (type:string) :void
-
Removes all listeners from the Emitter for the specified event.
Parameters
- type:string –
Throws
- TypeError –
- getNodesUnderPoint (point:Point) :Array
-
Returns a list of nodes under a given display position.
Parameters
- point:Point –
Returns
- Array –
Throws
- TypeError –
- listeners (type:string) :array
-
Returns an array of listeners for the specified event.
Parameters
- type:string –
Returns
- array –
- swapDepthAt (index:number) :void
-
Swap positions with another node at a given index in the parents child list.
Parameters
- index:number –
Throws
- TypeError –
- RangeError –
- swapDepths (node:Node) :void
-
Swap positions with a sibling node.
Parameters
- node:Node –
Throws
- TypeError –
- ReferenceError –
- getBounds (targetCoordSpace:Node) :Rectangle|null
-
The bounding box of a Node is a union of all it's child Sprite's bounds.
Parameters
- targetCoordSpace:Node –
Returns
- Rectangle|null –
Class Functions
- isDisplay (obj:Object) :boolean
-
Test if an object is a Display.
Parameters
- obj:Object –
Returns
- boolean – True if object is a Doodle Display.