axmol/cocos2dx/include/CCGridAction.h

208 lines
7.1 KiB
C
Raw Normal View History

2010-08-17 11:43:10 +08:00
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
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 "CCIntervalAction.h"
#include "CCInstantAction.h"
namespace cocos2d
{
class CCGridBase;
2010-09-28 18:27:33 +08:00
/** @brief Base class for Grid actions */
2010-08-17 11:43:10 +08:00
class CCX_DLL CCGridAction : public CCIntervalAction
{
public:
virtual NSObject* copyWithZone(NSZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
2010-08-17 11:43:10 +08:00
virtual CCIntervalAction* reverse(void);
/** initializes the action with size and duration */
2010-08-18 16:56:27 +08:00
virtual bool initWithSize(ccGridSize gridSize, ccTime duration);
2010-08-17 11:43:10 +08:00
/** returns the grid */
2010-09-14 15:23:38 +08:00
virtual CCGridBase* getGrid(void);
2010-08-17 11:43:10 +08:00
public:
/** creates the action with size and duration */
static CCGridAction* actionWithSize(ccGridSize gridSize, ccTime duration);
protected:
ccGridSize m_sGridSize;
};
2010-09-28 18:27:33 +08:00
/**
@brief Base class for CCGrid3D actions.
2010-08-17 11:43:10 +08:00
Grid3D actions can modify a non-tiled grid.
*/
class CCX_DLL CCGrid3DAction : public CCGridAction
{
public:
2010-09-28 16:18:05 +08:00
/** returns the grid */
2010-09-14 15:23:38 +08:00
virtual CCGridBase* getGrid(void);
2010-09-28 16:18:05 +08:00
/** returns the vertex than belongs to certain position in the grid */
2010-08-17 11:43:10 +08:00
ccVertex3F vertex(ccGridSize pos);
2010-09-28 16:18:05 +08:00
/** returns the non-transformed vertex than belongs to certain position in the grid */
2010-08-17 11:43:10 +08:00
ccVertex3F originalVertex(ccGridSize pos);
2010-09-28 16:18:05 +08:00
/** sets a new vertex to a certain position of the grid */
2010-08-17 11:43:10 +08:00
void setVertex(ccGridSize pos, ccVertex3F vertex);
public:
2010-09-28 16:18:05 +08:00
/** creates the action with size and duration */
2010-08-17 11:43:10 +08:00
static CCGrid3DAction* actionWithSize(ccGridSize gridSize, ccTime duration);
};
2010-09-28 18:27:33 +08:00
/** @brief Base class for CCTiledGrid3D actions */
2010-08-17 11:43:10 +08:00
class CCX_DLL CCTiledGrid3DAction : public CCGridAction
{
public:
2010-09-28 16:18:05 +08:00
/** returns the tile that belongs to a certain position of the grid */
2010-08-17 11:43:10 +08:00
ccQuad3 tile(ccGridSize pos);
2010-09-28 16:18:05 +08:00
/** returns the non-transformed tile that belongs to a certain position of the grid */
2010-08-17 11:43:10 +08:00
ccQuad3 originalTile(ccGridSize pos);
2010-09-28 16:18:05 +08:00
/** sets a new tile to a certain position of the grid */
2010-08-17 11:43:10 +08:00
void setTile(ccGridSize pos, ccQuad3 coords);
2010-09-28 16:18:05 +08:00
/** returns the grid */
2010-09-14 15:23:38 +08:00
virtual CCGridBase* getGrid(void);
2010-08-17 11:43:10 +08:00
public:
2010-09-28 16:18:05 +08:00
/** creates the action with size and duration */
2010-08-17 11:43:10 +08:00
static CCTiledGrid3DAction* actionWithSize(ccGridSize gridSize, ccTime duration);
};
/** @brief CCAccelDeccelAmplitude action */
2010-08-17 11:43:10 +08:00
class CCX_DLL CCAccelDeccelAmplitude : public CCIntervalAction
{
public:
virtual ~CCAccelDeccelAmplitude(void);
2010-09-28 16:18:05 +08:00
/** initializes the action with an inner action that has the amplitude property, and a duration time */
2010-08-17 11:43:10 +08:00
bool initWithAction(CCAction *pAction, ccTime duration);
virtual void startWithTarget(CCNode *pTarget);
2010-08-17 11:43:10 +08:00
virtual void update(ccTime time);
virtual CCIntervalAction* reverse(void);
2010-09-29 17:39:45 +08:00
/** get amplitude rate */
2010-08-17 11:43:10 +08:00
inline float getRate(void) { return m_fRate; }
2010-09-29 17:39:45 +08:00
/** set amplitude rate */
2010-08-17 11:43:10 +08:00
inline void setRate(float fRate) { m_fRate = fRate; }
public:
2010-09-28 16:18:05 +08:00
/** creates the action with an inner action that has the amplitude property, and a duration time */
2010-08-17 11:43:10 +08:00
static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration);
protected:
float m_fRate;
CCIntervalAction *m_pOther;
};
/** @brief CCAccelAmplitude action */
2010-08-17 11:43:10 +08:00
class CCX_DLL CCAccelAmplitude : public CCIntervalAction
{
public:
~CCAccelAmplitude(void);
2010-09-28 16:18:05 +08:00
/** initializes the action with an inner action that has the amplitude property, and a duration time */
2010-08-17 11:43:10 +08:00
bool initWithAction(CCAction *pAction, ccTime duration);
2010-09-29 17:39:45 +08:00
/** get amplitude rate */
2010-09-28 16:18:05 +08:00
inline float getRate(void) { return m_fRate; }
2010-09-29 17:39:45 +08:00
/** set amplitude rate */
2010-09-28 16:18:05 +08:00
inline void setRate(float fRate) { m_fRate = fRate; }
virtual void startWithTarget(CCNode *pTarget);
2010-08-17 11:43:10 +08:00
virtual void update(ccTime time);
virtual CCIntervalAction* reverse(void);
public:
2010-09-28 16:18:05 +08:00
/** creates the action with an inner action that has the amplitude property, and a duration time */
2010-08-17 11:43:10 +08:00
static CCAccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration);
protected:
float m_fRate;
CCIntervalAction *m_pOther;
};
/** @brief CCDeccelAmplitude action */
2010-08-17 11:43:10 +08:00
class CCX_DLL CCDeccelAmplitude : public CCIntervalAction
{
public:
~CCDeccelAmplitude(void);
2010-09-28 16:18:05 +08:00
/** initializes the action with an inner action that has the amplitude property, and a duration time */
2010-08-17 11:43:10 +08:00
bool initWithAction(CCAction *pAction, ccTime duration);
2010-09-29 17:39:45 +08:00
/** get amplitude rate */
2010-09-28 16:18:05 +08:00
inline float getRate(void) { return m_fRate; }
2010-09-29 17:39:45 +08:00
/** set amplitude rate */
2010-09-28 16:18:05 +08:00
inline void setRate(float fRate) { m_fRate = fRate; }
virtual void startWithTarget(CCNode *pTarget);
2010-08-17 11:43:10 +08:00
virtual void update(ccTime time);
virtual CCIntervalAction* reverse(void);
public:
2010-09-28 16:18:05 +08:00
/** creates the action with an inner action that has the amplitude property, and a duration time */
2010-08-17 11:43:10 +08:00
static CCDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration);
protected:
float m_fRate;
CCIntervalAction *m_pOther;
};
/** @brief CCStopGrid action.
2010-09-28 18:27:33 +08:00
@warning Don't call this action if another grid action is active.
2010-08-17 11:43:10 +08:00
Call if you want to remove the the grid effect. Example:
2010-09-28 16:18:05 +08:00
CCSequence::actions(Lens::action(...), CCStopGrid::action(...), NULL);
2010-08-17 11:43:10 +08:00
*/
class CCX_DLL CCStopGrid : public CCInstantAction
{
public:
virtual void startWithTarget(CCNode *pTarget);
2010-08-17 11:43:10 +08:00
public:
2010-09-28 16:18:05 +08:00
/** Allocates and initializes the action */
2010-08-17 11:43:10 +08:00
static CCStopGrid* action(void);
};
/** @brief CCReuseGrid action */
2010-08-17 11:43:10 +08:00
class CCX_DLL CCReuseGrid : public CCInstantAction
{
public:
2010-09-28 16:18:05 +08:00
/** initializes an action with the number of times that the current grid will be reused */
2010-08-17 11:43:10 +08:00
bool initWithTimes(int times);
virtual void startWithTarget(CCNode *pTarget);
2010-08-17 11:43:10 +08:00
public:
2010-09-28 16:18:05 +08:00
/** creates an action with the number of times that the current grid will be reused */
2010-08-17 11:43:10 +08:00
static CCReuseGrid* actionWithTimes(int times);
protected:
int m_nTimes;
};
} // end of namespace cocos2d
#endif // __ACTION_CCGRID_ACTION_H__