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) 2008-2011 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 __ACTION_CCINTERVAL_ACTION_H__
|
|
|
|
#define __ACTION_CCINTERVAL_ACTION_H__
|
|
|
|
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "base_nodes/CCNode.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "CCAction.h"
|
|
|
|
#include "CCProtocols.h"
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "sprite_nodes/CCSpriteFrame.h"
|
|
|
|
#include "sprite_nodes/CCAnimation.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup actions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/**
|
|
|
|
@brief An interval action is an action that takes place within a certain period of time.
|
2010-08-06 10:51:40 +08:00
|
|
|
It has an start time, and a finish time. The finish time is the parameter
|
|
|
|
duration plus the start time.
|
|
|
|
|
2010-12-22 15:43:54 +08:00
|
|
|
These CCActionInterval actions have some interesting properties, like:
|
2012-04-19 14:35:52 +08:00
|
|
|
- They can run normally (default)
|
|
|
|
- They can run reversed with the reverse method
|
|
|
|
- They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
For example, you can simulate a Ping Pong effect running the action normally and
|
|
|
|
then running it again in Reverse mode.
|
|
|
|
|
|
|
|
Example:
|
2010-09-28 16:18:05 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAction *pingPongAction = CCSequence::actions(action, action->reverse(), NULL);
|
|
|
|
*/
|
|
|
|
class CC_DLL CCActionInterval : public CCFiniteTimeAction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** how many seconds had elapsed since the actions started to run. */
|
2012-06-08 13:55:28 +08:00
|
|
|
inline float getElapsed(void) { return m_elapsed; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** initializes the action */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float d);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** returns true if the action has finished */
|
|
|
|
virtual bool isDone(void);
|
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void step(float dt);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
/** returns a reversed action */
|
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCActionInterval* create(float d);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
//extension in CCGridAction
|
2012-08-01 15:30:12 +08:00
|
|
|
void setAmplitudeRate(float amp);
|
|
|
|
float getAmplitudeRate(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2012-06-08 13:55:28 +08:00
|
|
|
float m_elapsed;
|
2012-04-19 14:35:52 +08:00
|
|
|
bool m_bFirstTick;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Runs actions sequentially, one after another
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCSequence : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCSequence(void);
|
|
|
|
|
|
|
|
/** initializes the action */
|
2012-07-23 22:49:11 +08:00
|
|
|
bool initWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual void stop(void);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float t);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** helper constructor to create an array of sequenceable actions */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...);
|
2012-09-17 15:02:24 +08:00
|
|
|
/** helper constructor to create an array of sequenceable actions given an array */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCFiniteTimeAction* create(CCArray *arrayOfActions);
|
2012-11-15 17:16:51 +08:00
|
|
|
/** helper constructor to create an array of sequence-able actions */
|
|
|
|
static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, va_list args);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action */
|
2012-07-23 22:49:11 +08:00
|
|
|
static CCSequence* createWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
CCFiniteTimeAction *m_pActions[2];
|
2012-06-08 13:55:28 +08:00
|
|
|
float m_split;
|
2012-04-19 14:35:52 +08:00
|
|
|
int m_last;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Repeats an action a number of times.
|
2010-08-06 10:51:40 +08:00
|
|
|
* To repeat an action forever use the CCRepeatForever action.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCRepeat : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCRepeat(void);
|
|
|
|
|
|
|
|
/** initializes a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
|
|
|
|
bool initWithAction(CCFiniteTimeAction *pAction, unsigned int times);
|
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual void stop(void);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float dt);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool isDone(void);
|
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
inline void setInnerAction(CCFiniteTimeAction *pAction)
|
|
|
|
{
|
|
|
|
if (m_pInnerAction != pAction)
|
|
|
|
{
|
|
|
|
CC_SAFE_RETAIN(pAction);
|
|
|
|
CC_SAFE_RELEASE(m_pInnerAction);
|
|
|
|
m_pInnerAction = pAction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline CCFiniteTimeAction* getInnerAction()
|
|
|
|
{
|
|
|
|
return m_pInnerAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
/** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
|
|
|
|
static CCRepeat* create(CCFiniteTimeAction *pAction, unsigned int times);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
unsigned int m_uTimes;
|
|
|
|
unsigned int m_uTotal;
|
2012-06-08 13:55:28 +08:00
|
|
|
float m_fNextDt;
|
2012-04-19 14:35:52 +08:00
|
|
|
bool m_bActionInstant;
|
|
|
|
/** Inner action */
|
|
|
|
CCFiniteTimeAction *m_pInnerAction;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Repeats an action for ever.
|
2010-08-28 18:00:38 +08:00
|
|
|
To repeat the an action for a limited number of times use the Repeat action.
|
|
|
|
@warning This action can't be Sequenceable because it is not an IntervalAction
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCRepeatForever : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCRepeatForever()
|
|
|
|
: m_pInnerAction(NULL)
|
|
|
|
{}
|
|
|
|
virtual ~CCRepeatForever();
|
|
|
|
|
|
|
|
/** initializes the action */
|
|
|
|
bool initWithAction(CCActionInterval *pAction);
|
|
|
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
|
|
|
virtual void startWithTarget(CCNode* pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void step(float dt);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool isDone(void);
|
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
inline void setInnerAction(CCActionInterval *pAction)
|
|
|
|
{
|
|
|
|
if (m_pInnerAction != pAction)
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(m_pInnerAction);
|
|
|
|
m_pInnerAction = pAction;
|
|
|
|
CC_SAFE_RETAIN(m_pInnerAction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline CCActionInterval* getInnerAction()
|
|
|
|
{
|
|
|
|
return m_pInnerAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-12-06 18:51:33 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCRepeatForever* create(CCActionInterval *pAction);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
/** Inner action */
|
|
|
|
CCActionInterval *m_pInnerAction;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Spawn a new action immediately
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCSpawn : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCSpawn(void);
|
|
|
|
|
|
|
|
/** initializes the Spawn action with the 2 actions to spawn */
|
2012-07-23 22:49:11 +08:00
|
|
|
bool initWithTwoActions(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual void stop(void);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** helper constructor to create an array of spawned actions */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...);
|
2012-11-15 17:16:51 +08:00
|
|
|
|
|
|
|
/** helper constructor to create an array of spawned actions */
|
|
|
|
static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, va_list args);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
/** helper constructor to create an array of spawned actions given an array */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCFiniteTimeAction* create(CCArray *arrayOfActions);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** creates the Spawn action */
|
2012-07-23 22:49:11 +08:00
|
|
|
static CCSpawn* createWithTwoActions(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CCFiniteTimeAction *m_pOne;
|
|
|
|
CCFiniteTimeAction *m_pTwo;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Rotates a CCNode object to a certain angle by modifying it's
|
2010-08-06 10:51:40 +08:00
|
|
|
rotation attribute.
|
|
|
|
The direction will be decided by the shortest angle.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCRotateTo : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
2012-11-15 17:16:51 +08:00
|
|
|
/** creates the action */
|
|
|
|
static CCRotateTo* create(float fDuration, float fDeltaAngle);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** initializes the action */
|
2012-11-15 17:16:51 +08:00
|
|
|
bool initWithDuration(float fDuration, float fDeltaAngle);
|
|
|
|
|
|
|
|
/** creates the action with separate rotation angles */
|
|
|
|
static CCRotateTo* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
|
|
|
|
virtual bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-11-15 17:16:51 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
2012-11-15 17:16:51 +08:00
|
|
|
float m_fDstAngleX;
|
|
|
|
float m_fStartAngleX;
|
|
|
|
float m_fDiffAngleX;
|
|
|
|
|
|
|
|
float m_fDstAngleY;
|
|
|
|
float m_fStartAngleY;
|
|
|
|
float m_fDiffAngleY;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Rotates a CCNode object clockwise a number of degrees by modifying it's rotation attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCRotateBy : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
2012-11-15 17:16:51 +08:00
|
|
|
/** creates the action */
|
|
|
|
static CCRotateBy* create(float fDuration, float fDeltaAngle);
|
2012-04-19 14:35:52 +08:00
|
|
|
/** initializes the action */
|
2012-11-15 17:16:51 +08:00
|
|
|
bool initWithDuration(float fDuration, float fDeltaAngle);
|
|
|
|
|
|
|
|
static CCRotateBy* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
|
|
|
|
bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2012-11-15 17:16:51 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
2012-11-15 17:16:51 +08:00
|
|
|
float m_fAngleX;
|
|
|
|
float m_fStartAngleX;
|
|
|
|
float m_fAngleY;
|
|
|
|
float m_fStartAngleY;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Moves a CCNode object to the position x,y. x and y are absolute coordinates by modifying it's position attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCMoveTo : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, const CCPoint& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *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 */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCMoveTo* create(float duration, const CCPoint& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
CCPoint m_endPosition;
|
|
|
|
CCPoint m_startPosition;
|
|
|
|
CCPoint m_delta;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Moves a CCNode object x,y pixels by modifying it's position attribute.
|
2010-08-06 10:51:40 +08:00
|
|
|
x and y are relative to the position of the object.
|
|
|
|
Duration is is seconds.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCMoveBy : public CCMoveTo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, const CCPoint& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCMoveBy* create(float duration, const CCPoint& position);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Skews a CCNode object to given angles by modifying it's skewX and skewY attributes
|
|
|
|
@since v1.0
|
|
|
|
*/
|
|
|
|
class CC_DLL CCSkewTo : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCSkewTo();
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual bool initWithDuration(float t, float sx, float sy);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
/** creates the action */
|
|
|
|
static CCSkewTo* create(float t, float sx, float sy);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
float m_fSkewX;
|
|
|
|
float m_fSkewY;
|
|
|
|
float m_fStartSkewX;
|
|
|
|
float m_fStartSkewY;
|
|
|
|
float m_fEndSkewX;
|
|
|
|
float m_fEndSkewY;
|
|
|
|
float m_fDeltaX;
|
|
|
|
float m_fDeltaY;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Skews a CCNode object by skewX and skewY degrees
|
|
|
|
@since v1.0
|
|
|
|
*/
|
|
|
|
class CC_DLL CCSkewBy : public CCSkewTo
|
|
|
|
{
|
|
|
|
public:
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual bool initWithDuration(float t, float sx, float sy);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
2012-12-06 18:51:33 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
/** creates the action */
|
|
|
|
static CCSkewBy* create(float t, float deltaSkewX, float deltaSkewY);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCJumpBy : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCJumpBy* create(float duration, const CCPoint& position, float height, unsigned int jumps);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
CCPoint m_startPosition;
|
|
|
|
CCPoint m_delta;
|
2012-06-08 13:55:28 +08:00
|
|
|
float m_height;
|
2012-04-19 14:35:52 +08:00
|
|
|
unsigned int m_nJumps;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Moves a CCNode object to a parabolic position simulating a jump movement by modifying it's position attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCJumpTo : public CCJumpBy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCJumpTo* create(float duration, const CCPoint& position, float height, int jumps);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/** @typedef bezier configuration structure
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
|
|
|
typedef struct _ccBezierConfig {
|
2012-04-19 14:35:52 +08:00
|
|
|
//! end position of the bezier
|
|
|
|
CCPoint endPosition;
|
|
|
|
//! Bezier control point 1
|
|
|
|
CCPoint controlPoint_1;
|
|
|
|
//! Bezier control point 2
|
|
|
|
CCPoint controlPoint_2;
|
|
|
|
} ccBezierConfig;
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief An action that moves the target with a cubic Bezier curve by a certain distance.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCBezierBy : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with a duration and a bezier configuration */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float t, const ccBezierConfig& c);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with a duration and a bezier configuration */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCBezierBy* create(float t, const ccBezierConfig& c);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
ccBezierConfig m_sConfig;
|
|
|
|
CCPoint m_startPosition;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief An action that moves the target with a cubic Bezier curve to a destination point.
|
2010-08-06 10:51:40 +08:00
|
|
|
@since v0.8.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCBezierTo : public CCBezierBy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action with a duration and a bezier configuration */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCBezierTo* create(float t, const ccBezierConfig& c);
|
2012-11-15 17:16:51 +08:00
|
|
|
bool initWithDuration(float t, const ccBezierConfig &c);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ccBezierConfig m_sToConfig;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Scales a CCNode object to a zoom factor by modifying it's scale attribute.
|
2010-08-06 10:51:40 +08:00
|
|
|
@warning This action doesn't support "reverse"
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCScaleTo : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with the same scale factor for X and Y */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, float s);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** initializes the action with and X factor and a Y factor */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, float sx, float sy);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action with the same scale factor for X and Y */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCScaleTo* create(float duration, float s);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** creates the action with and X factor and a Y factor */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCScaleTo* create(float duration, float sx, float sy);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
float m_fScaleX;
|
|
|
|
float m_fScaleY;
|
|
|
|
float m_fStartScaleX;
|
2012-11-15 17:16:51 +08:00
|
|
|
float m_fStartScaleY;
|
2012-04-19 14:35:52 +08:00
|
|
|
float m_fEndScaleX;
|
|
|
|
float m_fEndScaleY;
|
|
|
|
float m_fDeltaX;
|
|
|
|
float m_fDeltaY;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Scales a CCNode object a zoom factor by modifying it's scale attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCScaleBy : public CCScaleTo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action with the same scale factor for X and Y */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCScaleBy* create(float duration, float s);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** creates the action with and X factor and a Y factor */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCScaleBy* create(float duration, float sx, float sy);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Blinks a CCNode object by modifying it's visible attribute
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCBlink : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, unsigned int uBlinks);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
2012-12-06 18:51:33 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCBlink* create(float duration, unsigned int uBlinks);
|
2012-11-15 17:16:51 +08:00
|
|
|
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual void stop();
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
unsigned int m_nTimes;
|
2012-11-15 17:16:51 +08:00
|
|
|
bool m_bOriginalState;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Fades In an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 0 to 255.
|
2010-08-06 10:51:40 +08:00
|
|
|
The "reverse" of this action is FadeOut
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCFadeIn : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCFadeIn* create(float d);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Fades Out an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 255 to 0.
|
2010-08-06 10:51:40 +08:00
|
|
|
The "reverse" of this action is FadeIn
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCFadeOut : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCFadeOut* create(float d);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
|
2010-08-06 10:51:40 +08:00
|
|
|
@warning This action doesn't support "reverse"
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCFadeTo : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with duration and opacity */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, GLubyte opacity);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates an action with duration and opacity */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCFadeTo* create(float duration, GLubyte opacity);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
GLubyte m_toOpacity;
|
|
|
|
GLubyte m_fromOpacity;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Tints a CCNode that implements the CCNodeRGB protocol from current tint to a custom one.
|
2010-08-06 10:51:40 +08:00
|
|
|
@warning This action doesn't support "reverse"
|
|
|
|
@since v0.7.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCTintTo : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with duration and color */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates an action with duration and color */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCTintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
ccColor3B m_to;
|
|
|
|
ccColor3B m_from;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Tints a CCNode that implements the CCNodeRGB protocol from current tint to a custom one.
|
2010-08-06 10:51:40 +08:00
|
|
|
@since v0.7.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCTintBy : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with duration and color */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates an action with duration and color */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCTintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
GLshort m_deltaR;
|
|
|
|
GLshort m_deltaG;
|
|
|
|
GLshort m_deltaB;
|
|
|
|
|
|
|
|
GLshort m_fromR;
|
|
|
|
GLshort m_fromG;
|
|
|
|
GLshort m_fromB;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Delays the action a certain amount of seconds
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCDelayTime : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCDelayTime* create(float d);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Executes an action in reverse order, from time=duration to time=0
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
@warning Use this action carefully. This action is not
|
|
|
|
sequenceable. Use it as the default "reversed" method
|
|
|
|
of your own actions, but using it outside the "reversed"
|
|
|
|
scope is not recommended.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
class CC_DLL CCReverseTime : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCReverseTime(void);
|
|
|
|
CCReverseTime();
|
|
|
|
|
|
|
|
/** initializes the action */
|
|
|
|
bool initWithAction(CCFiniteTimeAction *pAction);
|
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual void stop(void);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCReverseTime* create(CCFiniteTimeAction *pAction);
|
2012-04-19 14:35:52 +08:00
|
|
|
protected:
|
|
|
|
CCFiniteTimeAction *m_pOther;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CCTexture2D;
|
|
|
|
/** @brief Animates a sprite given the name of an Animation */
|
|
|
|
class CC_DLL CCAnimate : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCAnimate();
|
|
|
|
~CCAnimate();
|
|
|
|
|
|
|
|
/** initializes the action with an Animation and will restore the original frame when the animation is over */
|
|
|
|
bool initWithAnimation(CCAnimation *pAnimation);
|
|
|
|
|
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual void stop(void);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float t);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with an Animation and will restore the original frame when the animation is over */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCAnimate* create(CCAnimation *pAnimation);
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SYNTHESIZE_RETAIN(CCAnimation*, m_pAnimation, Animation)
|
|
|
|
protected:
|
|
|
|
std::vector<float>* m_pSplitTimes;
|
|
|
|
int m_nNextFrame;
|
|
|
|
CCSpriteFrame* m_pOrigFrame;
|
|
|
|
unsigned int m_uExecutedLoops;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Overrides the target of an action so that it always runs on the target
|
|
|
|
* specified at action creation rather than the one specified by runAction.
|
|
|
|
*/
|
|
|
|
class CC_DLL CCTargetedAction : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCTargetedAction();
|
|
|
|
virtual ~CCTargetedAction();
|
2012-12-06 18:51:33 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Create an action with the specified action and forced target */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCTargetedAction* create(CCNode* pTarget, CCFiniteTimeAction* pAction);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Init an action with the specified action and forced target */
|
|
|
|
bool initWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction);
|
|
|
|
|
|
|
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
|
|
|
virtual void stop(void);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** This is the target that the action will be forced to run with */
|
|
|
|
CC_SYNTHESIZE_RETAIN(CCNode*, m_pForcedTarget, ForcedTarget);
|
|
|
|
private:
|
|
|
|
CCFiniteTimeAction* m_pAction;
|
|
|
|
};
|
|
|
|
|
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_CCINTERVAL_ACTION_H__
|