Cocos Creator API

1.4.x

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

Widget

Extends Component
Module: cc

Stores and manipulate the anchoring based on its parent. Widget are used for GUI but can also be used for other things. Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call updateAlignment manually.

Properties

target Node

Specifies an alignment target that can only be one of the parent nodes of the current node. The default value is null, and when null, indicates the current parent.

isAlignTop Boolean

Whether to align the top.

isAlignVerticalCenter Boolean

Vertically aligns the midpoint, This will open the other vertical alignment options cancel.

isAlignBottom Boolean

Whether to align the bottom.

isAlignLeft Boolean

Whether to align the left.

isAlignHorizontalCenter Boolean

Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.

isAlignRight Boolean

Whether to align the right.

isStretchWidth Boolean readOnly

Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, the width setting is invalid (read only).

isStretchHeight Boolean readOnly

Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, then height setting is invalid (read only)

top Number

The margins between the top of this node and the top of parent node, the value can be negative, Only available in 'isAlignTop' open.

bottom Number

The margins between the bottom of this node and the bottom of parent node, the value can be negative, Only available in 'isAlignBottom' open.

left Number

The margins between the left of this node and the left of parent node, the value can be negative, Only available in 'isAlignLeft' open.

right Number

The margins between the right of this node and the right of parent node, the value can be negative, Only available in 'isAlignRight' open.

horizontalCenter Number

Horizontal aligns the midpoint offset value, the value can be negative, Only available in 'isAlignHorizontalCenter' open.

verticalCenter Number

Vertical aligns the midpoint offset value, the value can be negative, Only available in 'isAlignVerticalCenter' open.

isAbsoluteHorizontalCenter Boolean

If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.

isAbsoluteVerticalCenter Boolean

If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.

isAbsoluteTop Boolean

If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.

isAbsoluteBottom Boolean

If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.

isAbsoluteLeft Boolean

If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.

isAbsoluteRight Boolean

If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.

isAlignOnce Boolean

TODO

_alignFlags Number private

__eventTargets Array private

Inherited from Component:

Register all related EventTargets, all event callbacks will be removed in _onPreDestroy

node Node

Inherited from Component:

The node this component is attached to. A component is always attached to a node.

examples:

cc.log(comp.node);

uuid String readOnly

Inherited from Component:

The uuid for editor.

examples:

cc.log(comp.uuid);

_enabled Boolean private

Inherited from Component:

enabled Boolean

Inherited from Component:

indicates whether this component is enabled or not.

examples:

comp.enabled = true;
cc.log(comp.enabled);

enabledInHierarchy Boolean readOnly

Inherited from Component:

indicates whether this component is enabled and its node is also active in the hierarchy.

examples:

cc.log(comp.enabledInHierarchy);

_isOnLoadCalled Boolean readOnly