Cocos Creator API

1.4.x

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

Layout

Extends Component
Module: cc

The Layout is a container component, use it to arrange child elements easily.

Properties

type Layout.Type

The layout type.

resizeMode Layout.ResizeMode

The are three resize modes for Layout. None, resize Container and resize children.

cellSize Size

The cell size for grid layout.

startAxis Layout.AxisDirection

The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, and then break line on demand. Choose vertical if you want to layout vertically at first .

paddingLeft Number

The left padding of layout, it only effect the layout in one direction.

paddingRight Number

The right padding of layout, it only effect the layout in one direction.

paddingTop Number

The top padding of layout, it only effect the layout in one direction.

paddingBottom Number

The bottom padding of layout, it only effect the layout in one direction.

spacingX Number

The distance in x-axis between each element in layout.

spacingY Number

The distance in y-axis between each element in layout.

verticalDirection Layout.VerticalDirection

Only take effect in Vertical layout mode. This option changes the start element's positioning.

horizontalDirection Layout.HorizontalDirection

Only take effect in Horizontal layout mode. This option changes the start element's positioning.

padding Number

The padding of layout, it effects the layout in four direction.

__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

Inherited from Component:

TODO

examples:

cc.log(_isOnLoadCalled);

_name String private

_objFlags Number private

name String

The name of the object.

examples:

obj.name = "New Obj";

isValid Boolean readOnly

Indicates whether the object is not yet destroyed.

examples:

cc.log(obj.isValid);

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

update ( )

Inherited from Component:

Update is called every frame, if the Component is enabled.

lateUpdate ( )

Inherited from Component:

LateUpdate is called every frame, if the Component is enabled.

__preload ( ) private

Inherited from Component:

__preload is called before every onLoad. It is used to initialize the builtin components internally, to avoid checking whether onLoad is called before every public method calls. This method should be removed if script priority is supported.

onLoad ( )

Inherited from Component:

When attaching to an active node or its node first activated.

start ( )

Inherited from Component: