Cocos Creator API

1.4.x

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

Toggle

Extends Button
Module: cc

The toggle component is a CheckBox, when it used together with a ToggleGroup, it could be treated as a RadioButton.

Properties

isChecked Boolean

When this value is true, the check mark component will be enabled, otherwise the check mark component will be disabled.

toggleGroup ToggleGroup

The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. Otherwise, the toggle is a RadioButton.

checkMark Sprite

The image used for the checkmark.

checkEvents Component.EventHandler[]

If Toggle is clicked, it will trigger event's handler

interactable Boolean

Inherited from Button:

Whether the Button is disabled. If true, the Button will trigger event and do transition.

enableAutoGrayEffect Boolean

Inherited from Button:

When this flag is true, Button target sprite will turn gray when interactable is false.

transition Button.Transition

Inherited from Button:

Transition type

normalColor Color

Inherited from Button:

Normal state color.

pressedColor Color

Inherited from Button:

Pressed state color

hoverColor Color

Inherited from Button:

Hover state color

disabledColor Color

Inherited from Button:

Disabled state color

duration Number

Inherited from Button:

Color and Scale transition duration

zoomScale Number

Inherited from Button:

When user press the button, the button will zoom to a scale. The final scale of the button equals (button original scale * zoomScale)

normalSprite SpriteFrame

Inherited from Button:

Normal state sprite

pressedSprite SpriteFrame

Inherited from Button:

Pressed state sprite

hoverSprite SpriteFrame

Inherited from Button:

Hover state sprite

disabledSprite SpriteFrame

Inherited from Button:

Disabled state sprite

target Node

Inherited from Button:

Transition target. When Button state changed: If Transition type is Button.Transition.NONE, Button will do nothing If Transition type is Button.Transition.COLOR, Button will change target's color If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite

clickEvents Component.EventHandler[]

Inherited from Button:

If Button is clicked, it will trigger event's handler

__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