2012-02-01 16:45:23 +08:00
|
|
|
/****************************************************************************
|
2012-06-08 14:50:41 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-02-01 16:45:23 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
Copyright (c) 2011 Zynga Inc.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCLAYER_H__
|
|
|
|
#define __CCLAYER_H__
|
|
|
|
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "base_nodes/CCNode.h"
|
2012-02-01 16:45:23 +08:00
|
|
|
#include "CCProtocols.h"
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "touch_dispatcher/CCTouchDelegateProtocol.h"
|
|
|
|
#include "platform/CCAccelerometerDelegate.h"
|
|
|
|
#include "keypad_dispatcher/CCKeypadDelegate.h"
|
|
|
|
#include "cocoa/CCArray.h"
|
2013-04-13 05:51:29 +08:00
|
|
|
#ifdef EMSCRIPTEN
|
|
|
|
#include "base_nodes/CCGLBufferedNode.h"
|
|
|
|
#endif // EMSCRIPTEN
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_BEGIN
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-10-27 08:11:43 +08:00
|
|
|
typedef enum {
|
|
|
|
kCCTouchesAllAtOnce,
|
|
|
|
kCCTouchesOneByOne,
|
|
|
|
} ccTouchesMode;
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup layer
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-02-07 11:43:29 +08:00
|
|
|
class CCTouchScriptHandlerEntry;
|
|
|
|
|
2012-02-01 16:45:23 +08:00
|
|
|
//
|
|
|
|
// CCLayer
|
|
|
|
//
|
|
|
|
/** @brief CCLayer is a subclass of CCNode that implements the TouchEventsDelegate protocol.
|
|
|
|
|
|
|
|
All features from CCNode are valid, plus the following new features:
|
|
|
|
- It can receive iPhone Touches
|
|
|
|
- It can receive Accelerometer input
|
|
|
|
*/
|
2013-06-02 10:11:43 +08:00
|
|
|
class CC_DLL CCLayer : public CCNode, public CCTouchDelegate, public CCAccelerometerDelegate, public CCKeypadDelegate
|
2012-02-01 16:45:23 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayer();
|
|
|
|
virtual ~CCLayer();
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual bool init();
|
2012-12-06 18:51:33 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
/** create one layer */
|
|
|
|
static CCLayer *create(void);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
2012-02-01 16:45:23 +08:00
|
|
|
virtual void onEnterTransitionDidFinish();
|
2012-02-02 10:38:26 +08:00
|
|
|
|
|
|
|
// default implements are used to call script callback if exist
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
|
2012-02-02 10:38:26 +08:00
|
|
|
virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);
|
|
|
|
virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);
|
|
|
|
virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// default implements are used to call script callback if exist
|
|
|
|
virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
|
|
|
|
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
|
|
|
|
virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);
|
|
|
|
virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent);
|
|
|
|
|
2012-10-27 08:11:43 +08:00
|
|
|
virtual void didAccelerate(CCAcceleration* pAccelerationValue);
|
2012-12-02 15:17:34 +08:00
|
|
|
void registerScriptAccelerateHandler(int nHandler);
|
|
|
|
void unregisterScriptAccelerateHandler(void);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** If isTouchEnabled, this method is called onEnter. Override it to change the
|
|
|
|
way CCLayer receives touch events.
|
|
|
|
( Default: CCTouchDispatcher::sharedDispatcher()->addStandardDelegate(this,0); )
|
|
|
|
Example:
|
|
|
|
void CCLayer::registerWithTouchDispatcher()
|
|
|
|
{
|
|
|
|
CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this,INT_MIN+1,true);
|
|
|
|
}
|
|
|
|
@since v0.8.0
|
|
|
|
*/
|
|
|
|
virtual void registerWithTouchDispatcher(void);
|
2012-02-02 10:38:26 +08:00
|
|
|
|
|
|
|
/** Register script touch events handler */
|
2012-11-14 18:05:15 +08:00
|
|
|
virtual void registerScriptTouchHandler(int nHandler, bool bIsMultiTouches = false, int nPriority = INT_MIN, bool bSwallowsTouches = false);
|
2012-02-02 10:38:26 +08:00
|
|
|
/** Unregister script touch events handler */
|
2012-11-14 18:05:15 +08:00
|
|
|
virtual void unregisterScriptTouchHandler(void);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** 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.
|
|
|
|
@since v0.8.1
|
|
|
|
*/
|
2012-11-14 18:05:15 +08:00
|
|
|
virtual bool isTouchEnabled();
|
|
|
|
virtual void setTouchEnabled(bool value);
|
|
|
|
|
|
|
|
virtual void setTouchMode(ccTouchesMode mode);
|
|
|
|
virtual int getTouchMode();
|
2012-10-27 08:11:43 +08:00
|
|
|
|
2012-11-14 18:05:15 +08:00
|
|
|
/** priority of the touch events. Default is 0 */
|
|
|
|
virtual void setTouchPriority(int priority);
|
|
|
|
virtual int getTouchPriority();
|
2012-10-27 08:11:43 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** whether or not it will receive Accelerometer events
|
|
|
|
You can enable / disable accelerometer events with this property.
|
|
|
|
@since v0.8.1
|
|
|
|
*/
|
2012-11-14 18:05:15 +08:00
|
|
|
virtual bool isAccelerometerEnabled();
|
|
|
|
virtual void setAccelerometerEnabled(bool value);
|
|
|
|
virtual void setAccelerometerInterval(double interval);
|
2012-10-27 08:11:43 +08:00
|
|
|
|
2013-05-31 20:29:32 +08:00
|
|
|
/** whether or not it will receive keyboard or keypad events
|
2012-02-01 16:45:23 +08:00
|
|
|
You can enable / disable accelerometer events with this property.
|
|
|
|
it's new in cocos2d-x
|
|
|
|
*/
|
2013-06-02 10:11:43 +08:00
|
|
|
#ifdef KEYBOARD_SUPPORT
|
2013-05-31 20:29:32 +08:00
|
|
|
virtual bool isKeyboardEnabled();
|
|
|
|
virtual void setKeyboardEnabled(bool value);
|
2013-06-03 22:06:33 +08:00
|
|
|
virtual void keyPressed(int keyCode) {};
|
|
|
|
virtual void keyReleased(int keyCode) {};
|
2013-06-02 10:11:43 +08:00
|
|
|
#endif
|
2012-11-14 18:05:15 +08:00
|
|
|
virtual bool isKeypadEnabled();
|
|
|
|
virtual void setKeypadEnabled(bool value);
|
2012-12-02 15:17:34 +08:00
|
|
|
|
|
|
|
/** Register keypad events handler */
|
|
|
|
void registerScriptKeypadHandler(int nHandler);
|
|
|
|
/** Unregister keypad events handler */
|
|
|
|
void unregisterScriptKeypadHandler(void);
|
|
|
|
|
|
|
|
virtual void keyBackClicked(void);
|
|
|
|
virtual void keyMenuClicked(void);
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
inline CCTouchScriptHandlerEntry* getScriptTouchHandlerEntry() { return _scriptTouchHandlerEntry; };
|
|
|
|
inline CCScriptHandlerEntry* getScriptKeypadHandlerEntry() { return _scriptKeypadHandlerEntry; };
|
|
|
|
inline CCScriptHandlerEntry* getScriptAccelerateHandlerEntry() { return _scriptAccelerateHandlerEntry; };
|
2012-06-15 15:10:40 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _touchEnabled;
|
|
|
|
bool _accelerometerEnabled;
|
2013-06-02 10:11:43 +08:00
|
|
|
#ifdef KEYBOARD_SUPPORT
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _keyboardEnabled;
|
2013-06-02 10:11:43 +08:00
|
|
|
#endif
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _keypadEnabled;
|
2012-02-02 10:38:26 +08:00
|
|
|
|
|
|
|
private:
|
2012-02-07 11:43:29 +08:00
|
|
|
// Script touch events handler
|
2013-06-15 14:03:30 +08:00
|
|
|
CCTouchScriptHandlerEntry* _scriptTouchHandlerEntry;
|
|
|
|
CCScriptHandlerEntry* _scriptKeypadHandlerEntry;
|
|
|
|
CCScriptHandlerEntry* _scriptAccelerateHandlerEntry;
|
2012-10-27 08:11:43 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
int _touchPriority;
|
|
|
|
ccTouchesMode _touchMode;
|
2012-10-27 08:11:43 +08:00
|
|
|
|
2012-02-07 11:43:29 +08:00
|
|
|
int excuteScriptTouchHandler(int nEventType, CCTouch *pTouch);
|
|
|
|
int excuteScriptTouchHandler(int nEventType, CCSet *pTouches);
|
2012-02-01 16:45:23 +08:00
|
|
|
};
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2013-03-03 10:32:09 +08:00
|
|
|
#ifdef __apple__
|
2013-02-27 09:38:30 +08:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark CCLayerRGBA
|
2013-03-03 10:32:09 +08:00
|
|
|
#endif
|
2013-02-27 09:38:30 +08:00
|
|
|
|
|
|
|
/** CCLayerRGBA is a subclass of CCLayer that implements the CCRGBAProtocol protocol using a solid color as the background.
|
|
|
|
|
|
|
|
All features from CCLayer are valid, plus the following new features that propagate into children that conform to the CCRGBAProtocol:
|
|
|
|
- opacity
|
|
|
|
- RGB colors
|
|
|
|
@since 2.1
|
|
|
|
*/
|
|
|
|
class CC_DLL CCLayerRGBA : public CCLayer, public CCRGBAProtocol
|
|
|
|
{
|
|
|
|
public:
|
2013-02-28 16:45:59 +08:00
|
|
|
CREATE_FUNC(CCLayerRGBA);
|
|
|
|
|
2013-02-27 18:21:35 +08:00
|
|
|
CCLayerRGBA();
|
|
|
|
virtual ~CCLayerRGBA();
|
|
|
|
|
|
|
|
virtual bool init();
|
|
|
|
|
|
|
|
virtual GLubyte getOpacity();
|
|
|
|
virtual GLubyte getDisplayedOpacity();
|
|
|
|
virtual void setOpacity(GLubyte opacity);
|
|
|
|
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
|
|
|
|
virtual bool isCascadeOpacityEnabled();
|
|
|
|
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
|
|
|
|
|
|
|
virtual const ccColor3B& getColor();
|
|
|
|
virtual const ccColor3B& getDisplayedColor();
|
|
|
|
virtual void setColor(const ccColor3B& color);
|
|
|
|
virtual void updateDisplayedColor(const ccColor3B& parentColor);
|
|
|
|
virtual bool isCascadeColorEnabled();
|
|
|
|
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
virtual void setOpacityModifyRGB(bool bValue) {}
|
|
|
|
virtual bool isOpacityModifyRGB() { return false; }
|
2013-02-27 09:38:30 +08:00
|
|
|
protected:
|
2013-02-27 18:21:35 +08:00
|
|
|
GLubyte _displayedOpacity, _realOpacity;
|
|
|
|
ccColor3B _displayedColor, _realColor;
|
|
|
|
bool _cascadeOpacityEnabled, _cascadeColorEnabled;
|
2013-02-27 09:38:30 +08:00
|
|
|
};
|
|
|
|
|
2012-02-01 16:45:23 +08:00
|
|
|
//
|
|
|
|
// CCLayerColor
|
|
|
|
//
|
|
|
|
/** @brief CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
|
|
|
|
|
|
|
|
All features from CCLayer are valid, plus the following new features:
|
|
|
|
- opacity
|
|
|
|
- RGB colors
|
|
|
|
*/
|
2013-02-27 09:38:30 +08:00
|
|
|
class CC_DLL CCLayerColor : public CCLayerRGBA, public CCBlendProtocol
|
2013-04-13 05:51:29 +08:00
|
|
|
#ifdef EMSCRIPTEN
|
|
|
|
, public CCGLBufferedNode
|
|
|
|
#endif // EMSCRIPTEN
|
2012-02-01 16:45:23 +08:00
|
|
|
{
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
ccVertex2F _squareVertices[4];
|
|
|
|
ccColor4F _squareColors[4];
|
2012-02-01 16:45:23 +08:00
|
|
|
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayerColor();
|
|
|
|
virtual ~CCLayerColor();
|
|
|
|
|
|
|
|
virtual void draw();
|
2012-07-27 16:57:56 +08:00
|
|
|
virtual void setContentSize(const CCSize & var);
|
2012-11-01 22:17:12 +08:00
|
|
|
|
|
|
|
static CCLayerColor* create();
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates a CCLayer with color, width and height in Points */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCLayerColor * create(const ccColor4B& color, GLfloat width, GLfloat height);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates a CCLayer with color. Width and height are the window size. */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCLayerColor * create(const ccColor4B& color);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual bool init();
|
|
|
|
/** initializes a CCLayer with color, width and height in Points */
|
|
|
|
virtual bool initWithColor(const ccColor4B& color, GLfloat width, GLfloat height);
|
|
|
|
/** initializes a CCLayer with color. Width and height are the window size. */
|
|
|
|
virtual bool initWithColor(const ccColor4B& color);
|
|
|
|
|
|
|
|
/** change width in Points*/
|
|
|
|
void changeWidth(GLfloat w);
|
|
|
|
/** change height in Points*/
|
|
|
|
void changeHeight(GLfloat h);
|
|
|
|
/** change width and height in Points
|
|
|
|
@since v0.8
|
|
|
|
*/
|
|
|
|
void changeWidthAndHeight(GLfloat w ,GLfloat h);
|
|
|
|
|
|
|
|
/** BlendFunction. Conforms to CCBlendProtocol protocol */
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_PROPERTY(ccBlendFunc, _blendFunc, BlendFunc)
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-15 15:10:40 +08:00
|
|
|
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
|
|
|
|
virtual bool isOpacityModifyRGB(void) { return false;}
|
2013-02-27 18:21:35 +08:00
|
|
|
virtual void setColor(const ccColor3B &color);
|
|
|
|
virtual void setOpacity(GLubyte opacity);
|
2012-11-01 22:17:12 +08:00
|
|
|
|
2012-02-01 16:45:23 +08:00
|
|
|
protected:
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void updateColor();
|
2012-02-01 16:45:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// CCLayerGradient
|
|
|
|
//
|
2012-11-25 23:13:41 +08:00
|
|
|
/** @brief CCLayerGradient is a subclass of CCLayerColor that draws gradients across the background.
|
2012-02-01 16:45:23 +08:00
|
|
|
|
|
|
|
All features from CCLayerColor are valid, plus the following new features:
|
|
|
|
- direction
|
|
|
|
- final color
|
|
|
|
- interpolation mode
|
|
|
|
|
|
|
|
Color is interpolated between the startColor and endColor along the given
|
|
|
|
vector (starting at the origin, ending at the terminus). If no vector is
|
|
|
|
supplied, it defaults to (0, -1) -- a fade from top to bottom.
|
|
|
|
|
|
|
|
If 'compressedInterpolation' is disabled, you will not see either the start or end color for
|
|
|
|
non-cardinal vectors; a smooth gradient implying both end points will be still
|
|
|
|
be drawn, however.
|
|
|
|
|
|
|
|
If ' compressedInterpolation' is enabled (default mode) you will see both the start and end colors of the gradient.
|
|
|
|
|
|
|
|
@since v0.99.5
|
|
|
|
*/
|
|
|
|
class CC_DLL CCLayerGradient : public CCLayerColor
|
|
|
|
{
|
|
|
|
public:
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2012-02-01 16:45:23 +08:00
|
|
|
/** Creates a full-screen CCLayer with a gradient between start and end. */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCLayerGradient* create(const ccColor4B& start, const ccColor4B& end);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
|
|
|
/** Creates a full-screen CCLayer with a gradient between start and end in the direction of v. */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCLayerGradient* create(const ccColor4B& start, const ccColor4B& end, const CCPoint& v);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-10-31 18:00:51 +08:00
|
|
|
virtual bool init();
|
2012-02-01 16:45:23 +08:00
|
|
|
/** Initializes the CCLayer with a gradient between start and end. */
|
|
|
|
virtual bool initWithColor(const ccColor4B& start, const ccColor4B& end);
|
|
|
|
|
|
|
|
/** Initializes the CCLayer with a gradient between start and end in the direction of v. */
|
|
|
|
virtual bool initWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v);
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_PROPERTY_PASS_BY_REF(ccColor3B, _startColor, StartColor)
|
|
|
|
CC_PROPERTY_PASS_BY_REF(ccColor3B, _endColor, EndColor)
|
|
|
|
CC_PROPERTY(GLubyte, _startOpacity, StartOpacity)
|
|
|
|
CC_PROPERTY(GLubyte, _endOpacity, EndOpacity)
|
|
|
|
CC_PROPERTY_PASS_BY_REF(CCPoint, _alongVector, Vector)
|
2012-02-01 16:45:23 +08:00
|
|
|
|
|
|
|
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
|
|
|
|
Default: YES
|
|
|
|
*/
|
2012-06-15 16:47:30 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _compressedInterpolation;
|
2012-06-15 16:47:30 +08:00
|
|
|
public:
|
|
|
|
virtual void setCompressedInterpolation(bool bCompressedInterpolation);
|
|
|
|
virtual bool isCompressedInterpolation();
|
2012-11-01 22:17:12 +08:00
|
|
|
|
|
|
|
static CCLayerGradient* create();
|
|
|
|
|
2012-02-01 16:45:23 +08:00
|
|
|
protected:
|
|
|
|
virtual void updateColor();
|
|
|
|
};
|
|
|
|
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2012-02-01 16:45:23 +08:00
|
|
|
/** @brief CCMultipleLayer is a CCLayer with the ability to multiplex it's children.
|
|
|
|
Features:
|
|
|
|
- It supports one or more children
|
|
|
|
- Only one children will be active a time
|
|
|
|
*/
|
|
|
|
class CC_DLL CCLayerMultiplex : public CCLayer
|
|
|
|
{
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
unsigned int _enabledLayer;
|
|
|
|
CCArray* _layers;
|
2012-02-01 16:45:23 +08:00
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayerMultiplex();
|
|
|
|
virtual ~CCLayerMultiplex();
|
2013-02-27 18:21:35 +08:00
|
|
|
|
|
|
|
static CCLayerMultiplex* create();
|
|
|
|
|
|
|
|
/** creates a CCMultiplexLayer with an array of layers.
|
|
|
|
@since v2.1
|
|
|
|
*/
|
|
|
|
static CCLayerMultiplex* createWithArray(CCArray* arrayOfLayers);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates a CCLayerMultiplex with one or more layers using a variable argument list. */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCLayerMultiplex * create(CCLayer* layer, ... );
|
2012-02-01 16:45:23 +08:00
|
|
|
|
|
|
|
/**
|
2012-04-19 14:35:52 +08:00
|
|
|
* lua script can not init with undetermined number of variables
|
2012-09-17 15:02:24 +08:00
|
|
|
* so add these functions to be used with lua.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2012-06-14 17:18:05 +08:00
|
|
|
static CCLayerMultiplex * createWithLayer(CCLayer* layer);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void addLayer(CCLayer* layer);
|
|
|
|
|
|
|
|
/** initializes a MultiplexLayer with one or more layers using a variable argument list. */
|
|
|
|
bool initWithLayers(CCLayer* layer, va_list params);
|
|
|
|
/** switches to a certain layer indexed by n.
|
|
|
|
The current (old) layer will be removed from it's parent with 'cleanup:YES'.
|
|
|
|
*/
|
2012-11-30 21:13:25 +08:00
|
|
|
|
2012-12-02 15:17:34 +08:00
|
|
|
/** initializes a CCMultiplexLayer with an array of layers
|
|
|
|
@since v2.1
|
|
|
|
*/
|
2012-11-30 21:13:25 +08:00
|
|
|
bool initWithArray(CCArray* arrayOfLayers);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void switchTo(unsigned int n);
|
|
|
|
/** release the current layer and switches to another layer indexed by n.
|
|
|
|
The current (old) layer will be removed from it's parent with 'cleanup:YES'.
|
|
|
|
*/
|
|
|
|
void switchToAndReleaseMe(unsigned int n);
|
2012-02-01 16:45:23 +08:00
|
|
|
};
|
|
|
|
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of layer group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|
2012-02-01 16:45:23 +08:00
|
|
|
|
|
|
|
#endif // __CCLAYER_H__
|
|
|
|
|