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-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup layer
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class TouchScriptHandlerEntry;
|
2012-02-07 11:43:29 +08:00
|
|
|
|
2012-02-01 16:45:23 +08:00
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
// Layer
|
2012-02-01 16:45:23 +08:00
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief Layer is a subclass of Node that implements the TouchEventsDelegate protocol.
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
All features from Node are valid, plus the following new features:
|
2012-02-01 16:45:23 +08:00
|
|
|
- It can receive iPhone Touches
|
|
|
|
- It can receive Accelerometer input
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Layer : public Node, public TouchDelegate, public KeypadDelegate
|
2012-02-01 16:45:23 +08:00
|
|
|
{
|
2013-07-26 10:06:32 +08:00
|
|
|
public:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates a fullscreen black layer */
|
|
|
|
static Layer *create(void);
|
2013-06-20 14:13:12 +08:00
|
|
|
Layer();
|
|
|
|
virtual ~Layer();
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual bool init();
|
2012-12-06 18:51:33 +08:00
|
|
|
|
2012-02-02 10:38:26 +08:00
|
|
|
// default implements are used to call script callback if exist
|
2013-07-26 07:27:24 +08:00
|
|
|
virtual bool ccTouchBegan(Touch *touch, Event *event);
|
|
|
|
virtual void ccTouchMoved(Touch *touch, Event *event);
|
|
|
|
virtual void ccTouchEnded(Touch *touch, Event *event);
|
|
|
|
virtual void ccTouchCancelled(Touch *touch, Event *event);
|
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
|
2013-07-26 07:27:24 +08:00
|
|
|
virtual void ccTouchesBegan(Set *touches, Event *event);
|
|
|
|
virtual void ccTouchesMoved(Set *touches, Event *event);
|
|
|
|
virtual void ccTouchesEnded(Set *touches, Event *event);
|
|
|
|
virtual void ccTouchesCancelled(Set *touches, Event *event);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-26 07:27:24 +08:00
|
|
|
virtual void didAccelerate(Acceleration* accelerationValue);
|
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
|
2013-06-20 14:13:12 +08:00
|
|
|
way Layer receives touch events.
|
|
|
|
( Default: TouchDispatcher::sharedDispatcher()->addStandardDelegate(this,0); )
|
2012-04-19 14:35:52 +08:00
|
|
|
Example:
|
2013-06-20 14:13:12 +08:00
|
|
|
void Layer::registerWithTouchDispatcher()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
TouchDispatcher::sharedDispatcher()->addTargetedDelegate(this,INT_MIN+1,true);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
@since v0.8.0
|
|
|
|
*/
|
|
|
|
virtual void registerWithTouchDispatcher(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
|
|
|
|
*/
|
2013-07-04 08:22:15 +08:00
|
|
|
virtual bool isTouchEnabled() const;
|
2012-11-14 18:05:15 +08:00
|
|
|
virtual void setTouchEnabled(bool value);
|
|
|
|
|
2013-07-26 07:27:24 +08:00
|
|
|
virtual void setTouchMode(Touch::DispatchMode mode);
|
|
|
|
virtual Touch::DispatchMode getTouchMode() const;
|
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);
|
2013-07-04 08:22:15 +08:00
|
|
|
virtual int getTouchPriority() const;
|
2013-07-26 15:06:35 +08:00
|
|
|
|
|
|
|
/** swallowsTouches of the touch events. Default is true */
|
2013-07-26 13:43:28 +08:00
|
|
|
virtual void setSwallowsTouches(bool swallowsTouches);
|
2013-07-26 15:21:19 +08:00
|
|
|
virtual bool isSwallowsTouches() const;
|
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
|
|
|
|
*/
|
2013-07-04 08:22:15 +08:00
|
|
|
virtual bool isAccelerometerEnabled() const;
|
2012-11-14 18:05:15 +08:00
|
|
|
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-07-01 16:48:42 +08:00
|
|
|
|
2013-07-04 08:22:15 +08:00
|
|
|
virtual bool isKeyboardEnabled() const;
|
2013-05-31 20:29:32 +08:00
|
|
|
virtual void setKeyboardEnabled(bool value);
|
2013-06-03 22:06:33 +08:00
|
|
|
virtual void keyPressed(int keyCode) {};
|
|
|
|
virtual void keyReleased(int keyCode) {};
|
2013-07-01 16:48:42 +08:00
|
|
|
|
2013-07-04 08:22:15 +08:00
|
|
|
virtual bool isKeypadEnabled() const;
|
2012-11-14 18:05:15 +08:00
|
|
|
virtual void setKeypadEnabled(bool value);
|
2012-12-02 15:17:34 +08:00
|
|
|
|
|
|
|
virtual void keyBackClicked(void);
|
|
|
|
virtual void keyMenuClicked(void);
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
|
|
|
virtual void onEnterTransitionDidFinish() override;
|
|
|
|
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _touchEnabled;
|
|
|
|
bool _accelerometerEnabled;
|
|
|
|
bool _keyboardEnabled;
|
|
|
|
bool _keypadEnabled;
|
2012-02-02 10:38:26 +08:00
|
|
|
|
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
int _touchPriority;
|
2013-07-26 07:27:24 +08:00
|
|
|
Touch::DispatchMode _touchMode;
|
2013-07-26 13:57:11 +08:00
|
|
|
bool _swallowsTouches;
|
2012-10-27 08:11:43 +08:00
|
|
|
|
2013-07-22 17:12:53 +08:00
|
|
|
int executeScriptTouchHandler(int eventType, Touch* touch);
|
|
|
|
int executeScriptTouchesHandler(int eventType, Set* touches);
|
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 -
|
2013-06-20 14:13:12 +08:00
|
|
|
#pragma mark LayerRGBA
|
2013-03-03 10:32:09 +08:00
|
|
|
#endif
|
2013-02-27 09:38:30 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** LayerRGBA is a subclass of Layer that implements the RGBAProtocol protocol using a solid color as the background.
|
2013-02-27 09:38:30 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
All features from Layer are valid, plus the following new features that propagate into children that conform to the RGBAProtocol:
|
2013-02-27 09:38:30 +08:00
|
|
|
- opacity
|
|
|
|
- RGB colors
|
|
|
|
@since 2.1
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL LayerRGBA : public Layer, public RGBAProtocol
|
2013-02-27 09:38:30 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
CREATE_FUNC(LayerRGBA);
|
2013-02-28 16:45:59 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
LayerRGBA();
|
|
|
|
virtual ~LayerRGBA();
|
2013-02-27 18:21:35 +08:00
|
|
|
|
|
|
|
virtual bool init();
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual GLubyte getOpacity() const override;
|
|
|
|
virtual GLubyte getDisplayedOpacity() const override;
|
|
|
|
virtual void setOpacity(GLubyte opacity) override;
|
|
|
|
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
|
|
|
virtual bool isCascadeOpacityEnabled() const override;
|
|
|
|
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
|
2013-02-27 18:21:35 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual const Color3B& getColor() const override;
|
|
|
|
virtual const Color3B& getDisplayedColor() const override;
|
|
|
|
virtual void setColor(const Color3B& color) override;
|
|
|
|
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
|
|
|
virtual bool isCascadeColorEnabled() const override;
|
|
|
|
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
|
2013-02-27 18:21:35 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}
|
|
|
|
virtual bool isOpacityModifyRGB() const override { return false; }
|
2013-02-27 09:38:30 +08:00
|
|
|
protected:
|
2013-02-27 18:21:35 +08:00
|
|
|
GLubyte _displayedOpacity, _realOpacity;
|
2013-07-05 16:49:22 +08:00
|
|
|
Color3B _displayedColor, _realColor;
|
2013-02-27 18:21:35 +08:00
|
|
|
bool _cascadeOpacityEnabled, _cascadeColorEnabled;
|
2013-02-27 09:38:30 +08:00
|
|
|
};
|
|
|
|
|
2012-02-01 16:45:23 +08:00
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
// LayerColor
|
2012-02-01 16:45:23 +08:00
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief LayerColor is a subclass of Layer that implements the RGBAProtocol protocol.
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
All features from Layer are valid, plus the following new features:
|
2012-02-01 16:45:23 +08:00
|
|
|
- opacity
|
|
|
|
- RGB colors
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL LayerColor : public LayerRGBA, public BlendProtocol
|
2013-04-13 05:51:29 +08:00
|
|
|
#ifdef EMSCRIPTEN
|
2013-06-20 14:13:12 +08:00
|
|
|
, public GLBufferedNode
|
2013-04-13 05:51:29 +08:00
|
|
|
#endif // EMSCRIPTEN
|
2012-02-01 16:45:23 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-29 10:02:10 +08:00
|
|
|
/** creates a fullscreen black layer */
|
2013-06-20 14:13:12 +08:00
|
|
|
static LayerColor* create();
|
|
|
|
/** creates a Layer with color, width and height in Points */
|
2013-07-05 16:49:22 +08:00
|
|
|
static LayerColor * create(const Color4B& color, GLfloat width, GLfloat height);
|
2013-06-20 14:13:12 +08:00
|
|
|
/** creates a Layer with color. Width and height are the window size. */
|
2013-07-05 16:49:22 +08:00
|
|
|
static LayerColor * create(const Color4B& color);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
LayerColor();
|
|
|
|
virtual ~LayerColor();
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool init();
|
2013-06-20 14:13:12 +08:00
|
|
|
/** initializes a Layer with color, width and height in Points */
|
2013-07-17 16:25:13 +08:00
|
|
|
bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
|
2013-06-20 14:13:12 +08:00
|
|
|
/** initializes a Layer with color. Width and height are the window size. */
|
2013-07-17 16:25:13 +08:00
|
|
|
bool initWithColor(const Color4B& color);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** 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);
|
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void draw() override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void setColor(const Color3B &color) override;
|
|
|
|
virtual void setOpacity(GLubyte opacity) override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void setContentSize(const Size & var) override;
|
2013-07-23 21:51:19 +08:00
|
|
|
/** BlendFunction. Conforms to BlendProtocol protocol */
|
|
|
|
virtual const BlendFunc& getBlendFunc() const override;
|
|
|
|
virtual void setBlendFunc(const BlendFunc& blendFunc) override;
|
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();
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2013-07-23 18:26:26 +08:00
|
|
|
BlendFunc _blendFunc;
|
2013-07-18 07:56:19 +08:00
|
|
|
Vertex2F _squareVertices[4];
|
|
|
|
Color4F _squareColors[4];
|
2012-02-01 16:45:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
// LayerGradient
|
2012-02-01 16:45:23 +08:00
|
|
|
//
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief LayerGradient is a subclass of LayerColor that draws gradients across the background.
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
All features from LayerColor are valid, plus the following new features:
|
2012-02-01 16:45:23 +08:00
|
|
|
- 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
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL LayerGradient : public LayerColor
|
2012-02-01 16:45:23 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-29 10:02:10 +08:00
|
|
|
/** Creates a fullscreen black layer */
|
|
|
|
static LayerGradient* create();
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** Creates a full-screen Layer with a gradient between start and end. */
|
2013-07-05 16:49:22 +08:00
|
|
|
static LayerGradient* create(const Color4B& start, const Color4B& end);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** Creates a full-screen Layer with a gradient between start and end in the direction of v. */
|
2013-07-05 16:49:22 +08:00
|
|
|
static LayerGradient* create(const Color4B& start, const Color4B& end, const Point& v);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2012-10-31 18:00:51 +08:00
|
|
|
virtual bool init();
|
2013-06-20 14:13:12 +08:00
|
|
|
/** Initializes the Layer with a gradient between start and end. */
|
2013-07-17 16:25:13 +08:00
|
|
|
bool initWithColor(const Color4B& start, const Color4B& end);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** Initializes the Layer with a gradient between start and end in the direction of v. */
|
2013-07-17 16:25:13 +08:00
|
|
|
bool initWithColor(const Color4B& start, const Color4B& end, const Point& v);
|
2013-07-04 12:50:17 +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
|
2013-08-01 16:39:42 +08:00
|
|
|
Default: true
|
2013-07-04 12:50:17 +08:00
|
|
|
*/
|
2013-07-20 04:16:38 +08:00
|
|
|
void setCompressedInterpolation(bool bCompressedInterpolation);
|
|
|
|
bool isCompressedInterpolation() const;
|
|
|
|
|
|
|
|
/** Sets the start color of the gradient */
|
|
|
|
void setStartColor( const Color3B& startColor );
|
|
|
|
/** Returns the start color of the gradient */
|
|
|
|
const Color3B& getStartColor() const;
|
|
|
|
|
|
|
|
/** Sets the end color of the gradient */
|
|
|
|
void setEndColor( const Color3B& endColor );
|
|
|
|
/** Returns the end color of the gradient */
|
|
|
|
const Color3B& getEndColor() const;
|
|
|
|
|
|
|
|
/** Returns the start opacity of the gradient */
|
|
|
|
void setStartOpacity( GLubyte startOpacity );
|
|
|
|
/** Returns the start opacity of the gradient */
|
|
|
|
GLubyte getStartOpacity() const;
|
|
|
|
|
|
|
|
/** Returns the end opacity of the gradient */
|
|
|
|
void setEndOpacity( GLubyte endOpacity );
|
|
|
|
/** Returns the end opacity of the gradient */
|
|
|
|
GLubyte getEndOpacity() const;
|
|
|
|
|
|
|
|
/** Sets the directional vector that will be used for the gradient.
|
|
|
|
The default value is vertical direction (0,-1).
|
|
|
|
*/
|
|
|
|
void setVector(const Point& alongVector);
|
|
|
|
/** Returns the directional vector used for the gradient */
|
|
|
|
const Point& getVector() const;
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
protected:
|
|
|
|
virtual void updateColor() override;
|
|
|
|
|
2013-07-20 04:16:38 +08:00
|
|
|
Color3B _startColor;
|
|
|
|
Color3B _endColor;
|
|
|
|
GLubyte _startOpacity;
|
|
|
|
GLubyte _endOpacity;
|
|
|
|
Point _alongVector;
|
|
|
|
bool _compressedInterpolation;
|
2012-02-01 16:45:23 +08:00
|
|
|
};
|
|
|
|
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief MultipleLayer is a Layer with the ability to multiplex it's children.
|
2012-02-01 16:45:23 +08:00
|
|
|
Features:
|
|
|
|
- It supports one or more children
|
|
|
|
- Only one children will be active a time
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL LayerMultiplex : public Layer
|
2012-02-01 16:45:23 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates and initializes a LayerMultiplex object */
|
2013-06-20 14:13:12 +08:00
|
|
|
static LayerMultiplex* create();
|
2013-07-18 07:56:19 +08:00
|
|
|
|
|
|
|
/** creates a LayerMultiplex with an array of layers.
|
2013-02-27 18:21:35 +08:00
|
|
|
@since v2.1
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static LayerMultiplex* createWithArray(Array* arrayOfLayers);
|
2012-02-01 16:45:23 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** creates a LayerMultiplex with one or more layers using a variable argument list. */
|
|
|
|
static LayerMultiplex * create(Layer* 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
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static LayerMultiplex * createWithLayer(Layer* layer);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
LayerMultiplex();
|
|
|
|
virtual ~LayerMultiplex();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-26 19:38:23 +08:00
|
|
|
virtual bool init();
|
2012-04-19 14:35:52 +08:00
|
|
|
/** initializes a MultiplexLayer with one or more layers using a variable argument list. */
|
2013-06-20 14:13:12 +08:00
|
|
|
bool initWithLayers(Layer* layer, va_list params);
|
2012-11-30 21:13:25 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** initializes a MultiplexLayer with an array of layers
|
2013-07-18 07:56:19 +08:00
|
|
|
@since v2.1
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
bool initWithArray(Array* arrayOfLayers);
|
2012-11-30 21:13:25 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
void addLayer(Layer* layer);
|
|
|
|
|
|
|
|
/** switches to a certain layer indexed by n.
|
2013-08-01 16:39:42 +08:00
|
|
|
The current (old) layer will be removed from it's parent with 'cleanup=true'.
|
2013-07-18 07:56:19 +08:00
|
|
|
*/
|
2013-09-08 11:26:38 +08:00
|
|
|
void switchTo(int n);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** release the current layer and switches to another layer indexed by n.
|
2013-08-01 16:39:42 +08:00
|
|
|
The current (old) layer will be removed from it's parent with 'cleanup=true'.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-09-08 11:26:38 +08:00
|
|
|
void switchToAndReleaseMe(int n);
|
2013-07-18 07:56:19 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
unsigned int _enabledLayer;
|
|
|
|
Array* _layers;
|
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__
|
|
|
|
|