2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2012-09-24 21:22:20 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-04-19 14:35:52 +08:00
|
|
|
Copyright (c) 2009 On-Core
|
|
|
|
|
|
|
|
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 __ACTION_CCGRID_ACTION_H__
|
|
|
|
#define __ACTION_CCGRID_ACTION_H__
|
|
|
|
|
|
|
|
#include "CCActionInterval.h"
|
|
|
|
#include "CCActionInstant.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class GridBase;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup actions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** @brief Base class for Grid actions */
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL GridAction : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual GridAction * clone() const = 0;
|
2013-06-16 09:54:34 +08:00
|
|
|
|
|
|
|
/** returns a new reversed action.
|
2013-06-20 14:13:12 +08:00
|
|
|
The reversed action is created with the ReverseTime action.
|
2013-06-16 09:54:34 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual GridAction* reverse() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void startWithTarget(Node *pTarget);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** initializes the action with size and duration */
|
2013-07-17 16:25:13 +08:00
|
|
|
bool initWithDuration(float duration, const Size& gridSize);
|
2012-12-26 18:59:31 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns the grid */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual GridBase* getGrid(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-20 14:13:12 +08:00
|
|
|
Size _gridSize;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief Base class for Grid3D actions.
|
2012-04-18 18:43:45 +08:00
|
|
|
Grid3D actions can modify a non-tiled grid.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Grid3DAction : public GridAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual Grid3DAction * clone() const = 0;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns the grid */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual GridBase* getGrid(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns the vertex than belongs to certain position in the grid */
|
2013-07-08 15:12:06 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE Vertex3F vertex(const Point& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns the non-transformed vertex than belongs to certain position in the grid */
|
2013-07-08 15:12:06 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE Vertex3F originalVertex(const Point& position);
|
|
|
|
|
|
|
|
/** returns the vertex than belongs to certain position in the grid */
|
|
|
|
Vertex3F getVertex(const Point& position);
|
|
|
|
/** returns the non-transformed vertex than belongs to certain position in the grid */
|
|
|
|
Vertex3F getOriginalVertex(const Point& position);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** sets a new vertex to a certain position of the grid */
|
2013-07-05 16:49:22 +08:00
|
|
|
void setVertex(const Point& position, const Vertex3F& vertex);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief Base class for TiledGrid3D actions */
|
|
|
|
class CC_DLL TiledGrid3DAction : public GridAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual TiledGrid3DAction * clone() const = 0;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns the tile that belongs to a certain position of the grid */
|
2013-07-08 15:12:06 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& position);
|
|
|
|
/** returns the non-transformed tile that belongs to a certain position of the grid */
|
|
|
|
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& position);
|
|
|
|
|
|
|
|
/** returns the tile that belongs to a certain position of the grid */
|
|
|
|
Quad3 getTile(const Point& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns the non-transformed tile that belongs to a certain position of the grid */
|
2013-07-08 15:12:06 +08:00
|
|
|
Quad3 getOriginalTile(const Point& position);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** sets a new tile to a certain position of the grid */
|
2013-07-05 16:49:22 +08:00
|
|
|
void setTile(const Point& position, const Quad3& coords);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** returns the grid */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual GridBase* getGrid(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with size and duration */
|
2013-06-20 14:13:12 +08:00
|
|
|
static TiledGrid3DAction* create(float duration, const Size& gridSize);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief AccelDeccelAmplitude action */
|
|
|
|
class CC_DLL AccelDeccelAmplitude : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ~AccelDeccelAmplitude(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** initializes the action with an inner action that has the amplitude property, and a duration time */
|
2013-06-20 14:13:12 +08:00
|
|
|
bool initWithAction(Action *pAction, float duration);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual AccelDeccelAmplitude* clone() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new reversed action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual AccelDeccelAmplitude* reverse() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void startWithTarget(Node *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** get amplitude rate */
|
2013-07-07 13:01:21 +08:00
|
|
|
inline float getRate(void) const { return _rate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
/** set amplitude rate */
|
2013-06-15 14:03:30 +08:00
|
|
|
inline void setRate(float fRate) { _rate = fRate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with an inner action that has the amplitude property, and a duration time */
|
2013-06-20 14:13:12 +08:00
|
|
|
static AccelDeccelAmplitude* create(Action *pAction, float duration);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _rate;
|
2013-06-20 14:13:12 +08:00
|
|
|
ActionInterval *_other;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief AccelAmplitude action */
|
|
|
|
class CC_DLL AccelAmplitude : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
~AccelAmplitude(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** initializes the action with an inner action that has the amplitude property, and a duration time */
|
2013-06-20 14:13:12 +08:00
|
|
|
bool initWithAction(Action *pAction, float duration);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual AccelAmplitude* clone() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
|
|
|
/** returns a new reversed action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual AccelAmplitude* reverse() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** get amplitude rate */
|
2013-07-07 13:01:21 +08:00
|
|
|
inline float getRate(void) const { return _rate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
/** set amplitude rate */
|
2013-06-15 14:03:30 +08:00
|
|
|
inline void setRate(float fRate) { _rate = fRate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void startWithTarget(Node *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with an inner action that has the amplitude property, and a duration time */
|
2013-06-20 14:13:12 +08:00
|
|
|
static AccelAmplitude* create(Action *pAction, float duration);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _rate;
|
2013-06-20 14:13:12 +08:00
|
|
|
ActionInterval *_other;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief DeccelAmplitude action */
|
|
|
|
class CC_DLL DeccelAmplitude : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
~DeccelAmplitude(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** initializes the action with an inner action that has the amplitude property, and a duration time */
|
2013-06-20 14:13:12 +08:00
|
|
|
bool initWithAction(Action *pAction, float duration);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual DeccelAmplitude* clone() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
|
|
|
/** returns a new reversed action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual DeccelAmplitude* reverse() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** get amplitude rate */
|
2013-07-07 13:01:21 +08:00
|
|
|
inline float getRate(void) const { return _rate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
/** set amplitude rate */
|
2013-06-15 14:03:30 +08:00
|
|
|
inline void setRate(float fRate) { _rate = fRate; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void startWithTarget(Node *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with an inner action that has the amplitude property, and a duration time */
|
2013-06-20 14:13:12 +08:00
|
|
|
static DeccelAmplitude* create(Action *pAction, float duration);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _rate;
|
2013-06-20 14:13:12 +08:00
|
|
|
ActionInterval *_other;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief StopGrid action.
|
2012-04-18 18:43:45 +08:00
|
|
|
@warning Don't call this action if another grid action is active.
|
|
|
|
Call if you want to remove the the grid effect. Example:
|
2013-06-20 14:13:12 +08:00
|
|
|
Sequence::actions(Lens::action(...), StopGrid::action(...), NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL StopGrid : public ActionInstant
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void startWithTarget(Node *pTarget);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual StopGrid* clone() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
|
|
|
/** returns a new reversed action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual StopGrid* reverse() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
public:
|
|
|
|
/** Allocates and initializes the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
static StopGrid* create(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief ReuseGrid action */
|
|
|
|
class CC_DLL ReuseGrid : public ActionInstant
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes an action with the number of times that the current grid will be reused */
|
|
|
|
bool initWithTimes(int times);
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void startWithTarget(Node *pTarget);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ReuseGrid* clone() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
|
|
|
/** returns a new reversed action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ReuseGrid* reverse() const;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
public:
|
|
|
|
/** creates an action with the number of times that the current grid will be reused */
|
2013-06-20 14:13:12 +08:00
|
|
|
static ReuseGrid* create(int times);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
int _times;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of actions group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif // __ACTION_CCGRID_ACTION_H__
|