Cocos2D JavaScript (v0.2.0-beta) API Documentation

Class: Node

Module
cocos.nodes
Defined In
nodes/Node.js
Subclasses
BatchNode
Label
Layer
MenuItem
ProgressBar
RenderTexture
Scene
Sprite
TMXTiledMap
Extends
BObject
The base class all visual elements extend from

Public Properties

Property Defined By
Expand anchorPoint anchorPoint : geometry.Point
Anchor point for scaling and rotation. 0x0 is top left and 1x1 is bottom right
Node
Expand anchorPointInPixels anchorPointInPixels : geometry.Point
Anchor point for scaling and rotation in pixels from top left
Node
Expand boundingBox boundingBox : geometry.Rect <read-only> Node
Expand children children : cocos.nodes.Node[]
The child Nodes
Node
Expand contentSize contentSize : geometry.Size
Size of the node
Node
Expand id id : Integer <read-only>
Unique ID for this object
BObject
Expand opacity opacity : Float
Opacity of the Node. 0 is totally transparent, 255 is totally opaque
Node
Expand parent parent : cocos.nodes.Node
Parent node
Node
Expand position position : geometry.Point
Position relative to parent node
Node
Expand rotation rotation : Float
Rotation angle in degrees
Node
Expand scale scale : Float Node
Expand scaleX scaleX : Float
X scale factor
Node
Expand scaleY scaleY : Float
Y scale factor
Node
Expand tag tag : *
Unique tag to identify the node
Node
Expand visible visible : boolean
Is the node visible
Node
Expand visibleRect visibleRect : geometry.Rect <read-only>
The area of the node currently visible on screen. Returns an rect even if visible is false.
Node
Expand worldBoundingBox worldBoundingBox : geometry.Rect <read-only> Node
Expand zOrder zOrder : Integer
Nodes Z index. i.e. draw order
Node

Public Methods

Method Defined By
Expand Node new Node () : cocos.nodes.Node <constructor>

Returns

Node
Expand addChild addChild ({child:cocos.nodes.Node,[z:Integer],[tag:Integer/String]}) : cocos.nodes.Node
Add a child Node

Named Arguments

  • The child node to add
  • z : Integer (Optional)
    Z Index for the child
  • tag : Integer/String (Optional)
    A tag to reference the child with

Returns

Node
Expand bindTo bindTo (key:String,target:BOject,[targetKey:String],[noNotify:Boolean]) : void
Bind the value of a property on this object to that of another object so they always have the same value. Setting the value on either object will update the other too.

Arguments

  1. key : String
    Name of the property on this object that should be bound
  2. target : BOject
    Object to bind to
  3. targetKey : String (Optional)
    Key on the target object to bind to
  4. noNotify : Boolean (Optional)
    Set to true to prevent this object's property triggering a 'changed' event when adding the binding

Returns

  • void
BObject
Expand changed changed (key:*) : void

Arguments

  1. key :

Returns

  • void
BObject
Expand cleanup cleanup () : void

Returns

  • void
Node
Expand convertToNodeSpace convertToNodeSpace (worldPoint:*) : void

Arguments

  1. worldPoint :

Returns

  • void
Node
Expand detatchChild detatchChild (opts:*) : void

Arguments

  1. opts :

Returns

  • void
Node
Expand draw draw (context:CanvasRenderingContext2D/WebGLRenderingContext,rect:geometry.Rect) : void
Draws the node. Override to do custom drawing. If it's less efficient to draw only the area inside the rect then don't bother. The result will be clipped to that area anyway.

Arguments

  1. context : CanvasRenderingContext2D/WebGLRenderingContext
    Canvas rendering context
  2. Rectangular region that needs redrawing. Limit drawing to this area only if it's more efficient to do so.

Returns

  • void
Node
Expand get get (key:String) : *
Get a property from the object. Always use this instead of trying to access the property directly. This will ensure all bindings, setters and getters work correctly.

Arguments

  1. key : String
    Name of property to get or dot (.) separated path to a property

Returns

  • *
    Value of the property
BObject
Expand getAction getAction (opts:*) : void

Arguments

  1. opts :

Returns

  • void
Node
Expand getChild getChild (opts:*) : void

Arguments

  1. opts :

Returns

  • void
Node
Expand nodeToParentTransform nodeToParentTransform () : void

Returns

  • void
Node
Expand nodeToWorldTransform nodeToWorldTransform () : void

Returns

  • void
Node
Expand parentToNodeTransform parentToNodeTransform () : void

Returns

  • void
Node
Expand pauseSchedulerAndActions pauseSchedulerAndActions () : void

Returns

  • void
Node
Expand removeChild removeChild (opts:*) : void

Arguments

  1. opts :

Returns

  • void
Node
Expand removeChildren removeChildren (opts:*) : void

Arguments

  1. opts :

Returns

  • void
Node
Expand reorderChild reorderChild (opts:*) : void

Arguments

  1. opts :

Returns

  • void
Node
Expand resumeSchedulerAndActions resumeSchedulerAndActions () : void

Returns

  • void
Node
Expand runAction runAction (action:*) : void

Arguments

  1. action :

Returns

  • void
Node
Expand schedule schedule ({method:String/Function,[interval:Float]}) : void
Schedules a custom method with an interval time in seconds. If time is 0 it will be ticked every frame. If time is 0, it is recommended to use 'scheduleUpdate' instead. If the method is already scheduled, then the interval parameter will be updated without scheduling it again.

Named Arguments

  • method : String/Function
    Function of method name to schedule
  • interval : Float (Optional)
    Interval in seconds

Returns

  • void
Node
Expand scheduleUpdate scheduleUpdate (opts:*) : void

Arguments

  1. opts :

Returns

  • void
Node
Expand set set (key:String,value:*) : void
Set a property on the object. Always use this instead of trying to access the property directly. This will ensure all bindings, setters and getters work correctly.

Arguments

  1. key : String
    Name of property to get
  2. value : *
    New value for the property

Returns

  • void
BObject
Expand setValues setValues (kvp:Object) : void
Set multiple propertys in one go

Arguments

  1. kvp : Object
    An Object where the key is a property name and the value is the value to assign to the property

Returns

  • void
BObject
Expand stopAllActions stopAllActions () : void

Returns

  • void
Node
Expand transform transform (context:*) : void

Arguments

  1. context :

Returns

  • void
Node
Expand unbind unbind (key:String) : void
Remove binding from a property which set setup using BObject#bindTo.

Arguments

  1. key : String
    Name of the property on this object to unbind

Returns

  • void
BObject
Expand unbindAll unbindAll () : void
Remove all bindings on this object

Returns

  • void
BObject
Expand unschedule unschedule (method:String/Function) : void
Unschedules a custom method

Arguments

  1. method : String/Function

Returns

  • void
Node
Expand unscheduleAllSelectors unscheduleAllSelectors () : void

Returns

  • void
Node
Expand unscheduleSelector unscheduleSelector (selector:*) : void

Arguments

  1. selector :

Returns

  • void
Node
Expand visit visit (context:*,rect:*) : void

Arguments

  1. context :
  2. rect :

Returns

  • void
Node
Expand worldToNodeTransform worldToNodeTransform () : void

Returns

  • void
Node

Public Events

Event Defined By
Expand onEnter onEnter () : void
Triggered when the node is added to a scene

Returns

  • void
Node
Expand onExit onExit () : void
Triggered when the node is removed from a scene

Returns

  • void
Node

Private Members

This class has no private members.