Class cc.Layer

Class Summary
Constructor Attributes Constructor Name and Description
 
cc.Layer is a subclass of cc.Node that implements the TouchEventsDelegate protocol.

Method Summary

Class Detail

cc.Layer()
cc.Layer is a subclass of cc.Node that implements the TouchEventsDelegate protocol.
All features from cc.Node are valid, plus the following new features:
It can receive iPhone Touches
It can receive Accelerometer input

Method Detail

  • <static> {cc.Layer|Null} cc.Layer.create()
    creates a layer
    // Example
    var myLayer = cc.Layer.create();
    //Yes! it's that simple
    Returns:
    {cc.Layer|Null}
  • {Number} getTouchMode()
    returns the touch mode.
    Returns:
    {Number}
  • {Number} getTouchPriority()
    returns the priority of the touch event handler
    Returns:
    {Number}
  • {Boolean} init()
    Returns:
    {Boolean}
  • {Boolean} isAccelerometerEnabled()
    whether or not it will receive Accelerometer events
    You can enable / disable accelerometer events with this property.
    Returns:
    {Boolean}
  • {Boolean} isKeyboardEnabled()
    whether or not it will receive keyboard events
    You can enable / disable accelerometer events with this property.
    it's new in cocos2d-x
    Returns:
    {Boolean}
  • {Boolean} isTouchEnabled()
    whether or not it will receive Touch events.
    You can enable / disable touch events with this property.
    Only the touches of this node will be affected. This "method" is not propagated to it's children.
    Returns:
    {Boolean}
  • onEnter()
    This is run when ever a layer just become visible
  • onEnterTransitionDidFinish()
    this is called when ever a layer is a child of a scene that just finished a transition
  • onExit()
  • onKeyDown(keyCode)
    Call back when a key is pressed down
    // example
    if(keyCode == cc.KEY.w){}
    Parameters:
    {Number} keyCode
  • onKeyUp(keyCode)
    Call back when a key is released
    // example
    if(keyCode == cc.KEY.w){}
    Parameters:
    {Number} keyCode
  • {Boolean} onMouseDown(event)

    called when the "mouseDown" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onMouseDragged(event)

    called when the "mouseDragged" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onMouseEntered(theEvent)

    called when the "mouseEntered" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    theEvent
    Returns:
    {Boolean}
  • {Boolean} onMouseExited(theEvent)

    called when the "mouseExited" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    theEvent
    Returns:
    {Boolean}
  • {Boolean} onMouseMoved(event)

    called when the "mouseMoved" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onMouseUp(event)

    called when the "mouseUp" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onOtherMouseDown(event)

    called when the "otherMouseDown" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onOtherMouseDragged(event)

    called when the "otherMouseDragged" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onOtherMouseUp(event)

    called when the "otherMouseUp" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onRightMouseDown(event)

    called when the "rightMouseDown" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onRightMouseDragged(event)

    called when the "rightMouseDragged" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onRightMouseUp(event)

    called when the "rightMouseUp" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onScrollWheel(event)

    called when the "scrollWheel" event is received.
    Return YES to avoid propagating the event to other delegates.

    Parameters:
    event
    Returns:
    {Boolean}
  • {Boolean} onTouchBegan(touch, event)
    default implements are used to call script callback if exist
    you must override these touch functions if you wish to utilize them
    Parameters:
    {cc.Touch} touch
    {event} event
    Returns:
    {Boolean}
  • onTouchCancelled(touch, event)
    Parameters:
    {cc.Touch} touch
    {event} event
  • onTouchEnded(touch, event)
    callback when a touch event finished
    Parameters:
    {cc.Touch} touch
    {event} event
  • onTouchesBegan(touch, event)
    Touches is the same as Touch, except this one can handle multi-touch
    Parameters:
    {cc.Touch} touch
    {event} event
  • onTouchesCancelled(touch, event)
    Parameters:
    touch
    event
  • onTouchesEnded(touch, event)
    when a touch finished
    Parameters:
    {cc.Touch} touch
    {event} event
  • onTouchesMoved(touch, event)
    when a touch moved
    Parameters:
    {cc.Touch} touch
    {event} event
  • onTouchMoved(touch, event)
    callback when a touch event moved
    Parameters:
    {cc.Touch} touch
    {event} event
  • registerWithTouchDispatcher()
    If isTouchEnabled, this method is called onEnter.
  • setAccelerometerEnabled(enabled)
    isAccelerometerEnabled setter
    Parameters:
    {Boolean} enabled
  • setAccelerometerInterval(interval)
    accelerometerInterval setter
    Parameters:
    {Number} interval
  • setKeyboardEnabled(enabled)
    Enable Keyboard interaction
    Parameters:
    {Boolean} enabled
  • setTouchEnabled(enabled)
    Enable touch events
    Parameters:
    {Boolean} enabled
  • setTouchMode(mode)
    Sets the touch mode.
    Parameters:
    {Number} mode
  • setTouchPriority(priority)
    Sets the touch event handler priority. Default is 0.
    Parameters:
    {Number} priority