Class cc.Control
- Defined in: CCControl.js
- Extends cc.LayerRGBA
Constructor Attributes | Constructor Name and Description |
---|---|
CCControl is inspired by the UIControl API class from the UIKit library of
CocoaTouch.
|
Method Summary
Class Detail
cc.Control()
CCControl is inspired by the UIControl API class from the UIKit library of
CocoaTouch. It provides a base class for control CCSprites such as CCButton
or CCSlider that convey user intent to the application.
The goal of CCControl is to define an interface and base implementation for
preparing action messages and initially dispatching them to their targets when
certain events occur.
To use the CCControl you have to subclass it.
Field Detail
{Boolean}
enabled
- Indicate whether the control node is enbaled
{Boolean}
highlighted
- Indicate whether the control node is highlighted
{Boolean}
selected
- Indicate whether the control node is selected
{Number}
state
- <@readonly> The current control state: cc.CONTROL_STATE_NORMAL | cc.CONTROL_STATE_HIGHLIGHTED | cc.CONTROL_STATE_DISABLED | cc.CONTROL_STATE_SELECTED | cc.CONTROL_STATE_INITIAL
Method Detail
-
addTargetWithActionForControlEvents(target, action, controlEvents)
Adds a target and action for a particular event (or events) to an internal
dispatch table.
The action message may optionally include the sender and the event as
parameters, in that order.
When you call this method, target is not retained.- Parameters:
- {Object} target
- The target object that is, the object to which the action message is sent. It cannot be nil. The target is not retained.
- {function} action
- A selector identifying an action message. It cannot be NULL.
- {Number} controlEvents
- A bitmask specifying the control events for which the action message is sent. See "CCControlEvent" for bitmask constants.
-
getTouchLocation(touch)Returns a point corresponding to the touh location converted into the control space coordinates.
- Parameters:
- {cc.Touch} touch
- A CCTouch object that represents a touch.
-
{Boolean} isTouchInside(touch)Returns a boolean value that indicates whether a touch is inside the bounds of the receiver. The given touch must be relative to the world.
- Parameters:
- {cc.Touch} touch
- A cc.Touch object that represents a touch.
- Returns:
- {Boolean} YES whether a touch is inside the receiver's rect.
-
needsLayout()Updates the control layout using its current internal state.
-
removeTargetWithActionForControlEvents(target, action, controlEvents)Removes a target and action for a particular event (or events) from an internal dispatch table.
- Parameters:
- {Object} target
- The target object that is, the object to which the action message is sent. Pass nil to remove all targets paired with action and the specified control events.
- {function} action
- A selector identifying an action message. Pass NULL to remove all action messages paired with target.
- {Number} controlEvents
- A bitmask specifying the control events associated with target and action. See "CCControlEvent" for bitmask constants.
-
sendActionsForControlEvents(controlEvents)Sends action messages for the given control events. which action messages are sent. See "CCControlEvent" for bitmask constants.
- Parameters:
- {Number} controlEvents
- A bitmask whose set flags specify the control events for
-
setEnabled(enabled)Tells whether the control is enabled
- Parameters:
- {Boolean} enabled
-
setHighlighted(highlighted)A Boolean value that determines whether the control is highlighted.
- Parameters:
- {Boolean} highlighted
-
setSelected(selected)A Boolean value that determines the control selected state.
- Parameters:
- {Boolean} selected