doodle.createSprite

Description:

Sprite (id:string) :Sprite

Inherits

  1. Node
  2. Emitter
  3. Objectw

Parameters

  1. id:string – [optional] Name or initialization function.

Returns

  • Sprite – A sprite object.

Throws

  • SyntaxError – Invalid parameters.

Properties

context :CanvasRenderingContext2D

drawing context to use

Returns

  • CanvasRenderingContext2D –
height :number

Indicates the height of the sprite, in pixels.

Returns

  • number –

Throws

  • TypeError –
width :number

Indicates the width of the sprite, in pixels.

Returns

  • number –

Throws

  • TypeError –
alpha :number

Returns

  • number –
children :Array

Returns

  • Array –
debug.boundingBox :boolean

Returns

  • boolean –
id :string

Returns

  • string –
parent :Node

Returns

  • Node –
root :Display

Returns

  • Display –
rotation :number

Returns

  • number –
rotation :number

Returns

  • number –

Throws

  • TypeError –
transform :Matrix

Returns

  • Matrix –
visible :boolean

Returns

  • boolean –
x :number

Returns

  • number –
y :number

Returns

  • number –
graphics :Graphics

The graphics object contains drawing operations to be stored in draw_commands. Objects and Arrays are passed by reference, so these will be modified

Returns

  • Graphics –

Methods

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

  1. type:string –
  2. 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

  1. type:string –
  2. listener:Function –

Throws

  • TypeError –
appendTo () :Node

Adds this node to the given node's children.

Returns

  • Node –

Throws

  • TypeError –
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

  1. child:Node –
  2. index: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

  1. 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

  1. type:string –

Returns

  • boolean –

Throws

  • TypeError –
contains (node:Node) :boolean

Determine if node is among it's children, grandchildren, etc.

Parameters

  1. 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

  1. 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

  1. 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

  1. event:doodle.events.Event –

Returns

  • boolean – true if node has listeners of event type.

Throws

  • TypeError –
addChildAt (node:Node, index:number) :Node

Parameters

  1. node:Node –
  2. index:number –

Returns

  • Node –

Throws

  • TypeError –
addChild (node:Node) :Node

Parameters

  1. node:Node –

Returns

  • Node –

Throws

  • TypeError –
createNode () :void

createSprite () :void

getBounds (targetCoordSpace:Node) :Rectangle

Parameters

  1. targetCoordSpace:Node –

Returns

  • Rectangle –

Throws

  • TypeError –
getChildById (id:string) :Node|undefined

Parameters

  1. id:string –

Returns

  • Node|undefined –

Throws

  • TypeError –
globalToLocal (pt:Point) :Point

Parameters

  1. pt:Point –

Returns

  • Point –

Throws

  • TypeError –
hitTestObject (node:Node) :boolean

Parameters

  1. node:Node –

Returns

  • boolean –

Throws

  • TypeError –
hitTestPoint (pt:Point) :boolean

Parameters

  1. pt:Point –

Returns

  • boolean –

Throws

  • TypeError –
localToGlobal (pt:Point) :Point

Parameters

  1. pt:Point –

Returns

  • Point –

Throws

  • TypeError –
removeAllChildren () :void

Throws

  • TypeError –
removeChildAt (index:number) :Node

Parameters

  1. index:number –

Returns

  • Node – Removed child node.

Throws

  • TypeError –
  • RangeError –
removeChildById (id:string) :Node

Parameters

  1. id:string –

Returns

  • Node – Removed child node.

Throws

  • TypeError –
removeChild (node:Node) :Node

Parameters

  1. node:Node –

Returns

  • Node – Removed child node.

Throws

  • TypeError –
  • ReferenceError –
rotate (deg:number) :number

Parameters

  1. deg:number –

Returns

  • number –
scaleX (sx:number) :number

Parameters

  1. sx:number –

Returns

  • number –
scaleY (sy:number) :number

Parameters

  1. sy:number –

Returns

  • number –
swapChildren (node1:Node, node2:Node) :void

Parameters

  1. node1:Node –
  2. 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

  1. type:string –
  2. listener:Function –

Throws

  • TypeError –
removeListener (type:string, listener:Function) :void

Removes a listener from the Emitter object.

Parameters

  1. type:string –
  2. listener:Function –

Throws

  • TypeError –
removeAllListeners (type:string) :void

Removes all listeners from the Emitter for the specified event.

Parameters

  1. type:string –

Throws

  • TypeError –
listeners (type:string) :array

Returns an array of listeners for the specified event.

Parameters

  1. type:string –

Returns

  • array –
toString () :string

Returns the string representation of the specified object.

Returns

  • string –
swapDepthAt (index:number) :void

Swap positions with another node at a given index in the parents child list.

Parameters

  1. index:number –

Throws

  • TypeError –
  • RangeError –
swapDepths (node:Node) :void

Swap positions with a sibling node.

Parameters

  1. node:Node –

Throws

  • TypeError –
  • ReferenceError –
swapChildrenAt (index1:number, index2:number) :void

Swaps the child nodes at the two specified index positions in the child list.

Parameters

  1. index1:number –
  2. index2:number –

Throws

  • TypeError –
  • RangeError –
compose (x:number, y:number, w:number, h:number) :Sprite

Updates the position and size of this sprite.

Parameters

  1. x:number –
  2. y:number –
  3. w:number –
  4. h:number –

Returns

  • Sprite –

Throws

  • TypeError –

Class Functions

isSprite (obj:Object) :boolean

Test if an object is a Sprite or inherits from one.

Parameters

  1. obj:Object –

Returns

  • boolean –