Cocos Creator API

1.4.x

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Node

Module: cc

Class of all entities in Cocos Creator scenes.
Node also inherits from Event Target, it permits Node to dispatch events. For events supported by Node, please refer to Node.EventType

Properties

active Boolean

The local active state of this node.
Note that a Node may be inactive because a parent is not active, even if this returns true.
Use activeInHierarchy if you want to check if the Node is actually treated as active in the scene.

examples:

node.active = false;

activeInHierarchy Boolean

Indicates whether this node is active in the scene.

examples:

cc.log("activeInHierarchy: " + node.activeInHierarchy);

_components Component[] private readOnly

_prefab PrefabInfo private

The PrefabInfo object

_persistNode Boolean private

If true, the node is an persist node which won't be destroyed during scene transition. If false, the node will be destroyed automatically when loading a new scene. Default is false.

groupIndex Integer

Group index of node.
Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.

group String

Group of node.
Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.

name String

Name of node.

examples:

node.name = "New Node";
cc.log("Node Name: " + node.name);

parent Node

The parent of the node.

examples:

node.parent = newNode;

uuid String readOnly

The uuid for editor, will be stripped before building project.

examples:

cc.log("Node Uuid: " + node.uuid);

skewX Number

Skew x

examples:

node.skewX = 0;
cc.log("Node SkewX: " + node.skewX);

skewY Number

Skew y

examples:

node.skewY = 0;
cc.log("Node SkewY: " + node.skewY);

zIndex Number

Z order in depth which stands for the drawing order.

examples:

node.zIndex = 1;
cc.log("Node zIndex: " + node.zIndex);

rotation Number

Rotation of node.

examples:

node.rotation = 90;
cc.log("Node Rotation: " + node.rotation);

rotationX Number

Rotation on x axis.

examples:

node.rotationX = 45;
cc.log("Node Rotation X: " + node.rotationX);

rotationY Number

Rotation on y axis.

examples:

node.rotationY = 45;
cc.log("Node Rotation Y: " + node.rotationY);

scaleX Number

Scale on x axis.

examples:

node.scaleX = 0.5;
cc.log("Node Scale X: " + node.scaleX);

scaleY Number

Scale on y axis.

examples:

node.scaleY = 0.5;
cc.log("Node Scale Y: " + node.scaleY);

x Number

x axis position of node.

examples:

node.x = 100;
cc.log("Node Position X: " + node.x);

y Number

y axis position of node.

examples:

node.y = 100;
cc.log("Node Position Y: " + node.y);

children Node[] readOnly

All children nodes.

examples:

var children = node.children;
for (var i = 0; i < children.length; ++i) {
    cc.log("Node: " + children[i]);
}

childrenCount Number readOnly

All children nodes.

examples:

var count = node.childrenCount;
cc.log("Node Children Count: " + count);

anchorX Number

Anchor point's position on x axis.

examples:

node.anchorX = 0;

anchorY Number

Anchor point's position on y axis.

examples:

node.anchorY = 0;

width