Properties

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.

_getDependComponent

(

depended

)

returns:

on

(

type

callback

[target
]

useCapture

)

Register a callback of a specific event type on Node.
Use this method to register touch or mouse event permit propagation based on scene graph,
you can propagate the event to the parents or swallow it by calling stopPropagation on the event.
It's the recommended way to register touch/mouse event for Node,
please do not use cc.eventManager directly for Node.

When set to true, the capture argument prevents callback
from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.

Specifies whether the callback being removed was registered as a capturing callback or not.
If not specified, useCapture defaults to false. If a callback was registered twice,
one with capture and one without, each must be removed separately. Removal of a capturing callback
does not affect a non-capturing version of the same listener, and vice versa.

examples:

runAction

(

action

)

Executes an action, and returns the action that is executed.
The node becomes the action's target. Refer to cc.Action's getTarget()
Calling runAction while the node is not active won't have any effect.

returns:

examples:

Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
Composable actions are counted as 1 action. Example:
If you are running 1 Sequence of 7 actions, it will return 1.
If you are running 7 Sequences of 2 actions, it will return 7.

returns:

examples:

cc.log("Node Position: " + node.getPosition());

setPosition

(

newPosOrxValue

[yValue
]

)

Changes the position (x,y) of the node in cocos2d coordinates.
The original point (0,0) is at the left-bottom corner of screen.
Usually we use cc.v2(x,y) to compose CCVec2 object.
and Passing two numbers (x,y) is more efficient than passing CCPoint object.

examples:

Returns a copy of the anchor point.
Anchor point is the point around which all transformations and positioning manipulations take place.
It's like a pin in the node where it is "attached" to its parent.
The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
But you can use values higher than (1,1) and lower than (0,0) too.
The default anchor point is (0.5,0.5), so it starts at the center of the node.

returns:

examples:

cc.log("Node AnchorPoint: " + node.getAnchorPoint());

setAnchorPoint

(

point

[y
]

)

Sets the anchor point in percent.
anchor point is the point around which all transformations and positioning manipulations take place.
It's like a pin in the node where it is "attached" to its parent.
The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
But you can use values higher than (1,1) and lower than (0,0) too.
The default anchor point is (0.5,0.5), so it starts at the center of the node.

returns:

examples:

getContentSize

(

[ignoreSizeProvider
=false]

)

Returns a copy the untransformed size of the node.
The contentSize remains the same no matter the node is scaled or rotated.
All nodes has a size. Layer and Scene has the same size of the screen by default.

[localZOrder
]

[tag
]

)

An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string)

examples:

node.addChild(newNode, 1, 1001);

removeFromParent

(

[cleanup
=true]

)

Remove itself from its parent node. If cleanup is true, then also remove all actions and callbacks.
If the cleanup parameter is not passed, it will force a cleanup.
If the node orphan, then nothing happens.

returns:

examples:

Returns the displayed opacity of Node,
the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled.