2010-08-06 10:51:40 +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_CCINTERVAL_ACTION_H__
|
|
|
|
#define __ACTION_CCINTERVAL_ACTION_H__
|
|
|
|
|
|
|
|
#include "CCNode.h"
|
|
|
|
#include "CCAction.h"
|
|
|
|
#include "CCProtocols.h"
|
|
|
|
#include "CCSpriteFrame.h"
|
2010-12-31 09:36:53 +08:00
|
|
|
#include "CCAnimation.h"
|
2010-08-06 10:51:40 +08:00
|
|
|
|
2010-09-29 16:06:03 +08:00
|
|
|
namespace cocos2d {
|
2010-09-29 17:39:45 +08:00
|
|
|
|
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:
|
2010-09-29 17:39:45 +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
|
|
|
|
2010-09-29 17:39:45 +08:00
|
|
|
CCAction *pingPongAction = CCSequence::actions(action, action->reverse(), NULL);
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCActionInterval : public CCFiniteTimeAction
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** how many seconds had elapsed since the actions started to run. */
|
|
|
|
inline ccTime getElapsed(void) { return m_elapsed; }
|
|
|
|
|
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime d);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
2010-09-28 16:18:05 +08:00
|
|
|
/** returns true if the action has finished */
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual bool isDone(void);
|
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
|
|
|
virtual void step(ccTime dt);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-09-28 16:18:05 +08:00
|
|
|
/** returns a reversed action */
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
2010-12-22 15:43:54 +08:00
|
|
|
static CCActionInterval* actionWithDuration(ccTime d);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
2010-08-17 11:43:10 +08:00
|
|
|
public:
|
2010-09-29 17:39:45 +08:00
|
|
|
//extension in CCGridAction
|
2010-08-17 11:43:10 +08:00
|
|
|
void setAmplitudeRate(CGFloat amp);
|
|
|
|
CGFloat getAmplitudeRate(void);
|
|
|
|
|
2010-08-06 10:51:40 +08:00
|
|
|
protected:
|
|
|
|
ccTime m_elapsed;
|
|
|
|
bool m_bFirstTick;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Runs actions sequentially, one after another
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCSequence : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCSequence(void);
|
|
|
|
|
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void stop(void);
|
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
2010-09-29 17:39:45 +08:00
|
|
|
/** helper constructor to create an array of sequenceable actions */
|
2010-08-06 14:44:17 +08:00
|
|
|
static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
/** creates the action */
|
|
|
|
static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
|
|
|
|
protected:
|
|
|
|
CCFiniteTimeAction *m_pActions[2];
|
|
|
|
ccTime m_split;
|
|
|
|
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.
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCRepeat : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCRepeat(void);
|
|
|
|
|
|
|
|
/** initializes a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithAction(CCFiniteTimeAction *pAction, unsigned int times);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void stop(void);
|
|
|
|
virtual void update(ccTime time);
|
|
|
|
virtual bool isDone(void);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
|
|
|
|
static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
unsigned int m_uTimes;
|
|
|
|
unsigned int m_uTotal;
|
|
|
|
CCFiniteTimeAction *m_pOther;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCRepeatForever : public CCActionInterval
|
2010-08-28 18:00:38 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCRepeatForever(){}
|
|
|
|
virtual ~CCRepeatForever();
|
|
|
|
|
2010-09-28 16:18:05 +08:00
|
|
|
/** initializes the action */
|
2010-12-22 15:43:54 +08:00
|
|
|
bool initWithAction(CCActionInterval *pAction);
|
2010-08-28 18:00:38 +08:00
|
|
|
virtual NSObject* copyWithZone(NSZone *pZone);
|
|
|
|
virtual void startWithTarget(CCNode* pTarget);
|
|
|
|
virtual void step(ccTime dt);
|
|
|
|
virtual bool isDone(void);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-28 18:00:38 +08:00
|
|
|
|
|
|
|
public:
|
2010-09-28 16:18:05 +08:00
|
|
|
/** creates the action */
|
2010-12-22 15:43:54 +08:00
|
|
|
static CCRepeatForever* actionWithAction(CCActionInterval *pAction);
|
2010-08-28 18:00:38 +08:00
|
|
|
|
|
|
|
protected:
|
2010-12-22 15:43:54 +08:00
|
|
|
CCActionInterval *m_pOther;
|
2010-08-28 18:00:38 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Spawn a new action immediately
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCSpawn : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCSpawn(void);
|
|
|
|
|
|
|
|
/** initializes the Spawn action with the 2 actions to spawn */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void stop(void);
|
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** helper constructor to create an array of spawned actions */
|
2010-08-06 14:44:17 +08:00
|
|
|
static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
/** creates the Spawn action */
|
|
|
|
static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCRotateTo : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, float fDeltaAngle);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
|
|
|
static CCRotateTo* actionWithDuration(ccTime duration, float fDeltaAngle);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float m_fDstAngle;
|
|
|
|
float m_fStartAngle;
|
|
|
|
float m_fDiffAngle;
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Rotates a CCNode object clockwise a number of degrees by modifying it's rotation attribute.
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCRotateBy : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, float fDeltaAngle);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
|
|
|
static CCRotateBy* actionWithDuration(ccTime duration, float fDeltaAngle);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float m_fAngle;
|
|
|
|
float m_fStartAngle;
|
|
|
|
};
|
|
|
|
|
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.
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCMoveTo : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, CGPoint position);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
|
|
|
static CCMoveTo* actionWithDuration(ccTime duration, CGPoint position);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CGPoint m_endPosition;
|
|
|
|
CGPoint m_startPosition;
|
|
|
|
CGPoint 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.
|
|
|
|
*/
|
2010-08-06 14:44:17 +08:00
|
|
|
class CCX_DLL CCMoveBy : public CCMoveTo
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, CGPoint position);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
|
|
|
static CCMoveBy* actionWithDuration(ccTime duration, CGPoint position);
|
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute.
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCJumpBy : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, CGPoint position, ccTime height, int jumps);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
|
|
|
static CCJumpBy* actionWithDuration(ccTime duration, CGPoint position, ccTime height, int jumps);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CGPoint m_startPosition;
|
|
|
|
CGPoint m_delta;
|
2010-08-09 16:27:36 +08:00
|
|
|
ccTime m_height;
|
|
|
|
int m_nJumps;
|
2010-08-06 10:51:40 +08:00
|
|
|
};
|
|
|
|
|
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.
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-08-06 14:44:17 +08:00
|
|
|
class CCX_DLL CCJumpTo : public CCJumpBy
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-11 14:03:46 +08:00
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2010-09-28 16:18:05 +08:00
|
|
|
/** creates the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
static CCJumpTo* actionWithDuration(ccTime duration, CGPoint position, ccTime height, int jumps);
|
2010-08-06 10:51:40 +08:00
|
|
|
};
|
|
|
|
|
2010-09-29 17:39:45 +08:00
|
|
|
/** @typedef bezier configuration structure
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
|
|
|
typedef struct _ccBezierConfig {
|
|
|
|
//! end position of the bezier
|
|
|
|
CGPoint endPosition;
|
|
|
|
//! Bezier control point 1
|
|
|
|
CGPoint controlPoint_1;
|
|
|
|
//! Bezier control point 2
|
|
|
|
CGPoint 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.
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCBezierBy : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with a duration and a bezier configuration */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime t, ccBezierConfig c);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with a duration and a bezier configuration */
|
|
|
|
static CCBezierBy* actionWithDuration(ccTime t, ccBezierConfig c);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ccBezierConfig m_sConfig;
|
|
|
|
CGPoint 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
|
|
|
|
*/
|
2010-08-06 14:44:17 +08:00
|
|
|
class CCX_DLL CCBezierTo : public CCBezierBy
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-11 14:03:46 +08:00
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2010-09-28 16:18:05 +08:00
|
|
|
/** creates the action with a duration and a bezier configuration */
|
2010-08-11 14:03:46 +08:00
|
|
|
static CCBezierTo* actionWithDuration(ccTime t, ccBezierConfig c);
|
2010-08-06 10:51:40 +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"
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCScaleTo : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with the same scale factor for X and Y */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, float s);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
/** initializes the action with and X factor and a Y factor */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, float sx, float sy);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with the same scale factor for X and Y */
|
|
|
|
static CCScaleTo* actionWithDuration(ccTime duration, float s);
|
|
|
|
|
|
|
|
/** creates the action with and X factor and a Y factor */
|
|
|
|
static CCScaleTo* actionWithDuration(ccTime duration, float sx, float sy);
|
|
|
|
protected:
|
|
|
|
float m_fScaleX;
|
|
|
|
float m_fScaleY;
|
|
|
|
float m_fStartScaleX;
|
|
|
|
float m_fStartScaleY;
|
|
|
|
float m_fEndScaleX;
|
|
|
|
float m_fEndScaleY;
|
2010-08-09 16:27:36 +08:00
|
|
|
float m_fDeltaX;
|
2010-08-06 10:51:40 +08:00
|
|
|
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.
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-08-06 14:44:17 +08:00
|
|
|
class CCX_DLL CCScaleBy : public CCScaleTo
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-11 14:03:46 +08:00
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with the same scale factor for X and Y */
|
|
|
|
static CCScaleBy* actionWithDuration(ccTime duration, float s);
|
|
|
|
|
|
|
|
/** creates the action with and X factor and a Y factor */
|
|
|
|
static CCScaleBy* actionWithDuration(ccTime duration, float sx, float sy);
|
2010-08-06 10:51:40 +08:00
|
|
|
};
|
|
|
|
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Blinks a CCNode object by modifying it's visible attribute
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCBlink : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
2010-09-28 16:18:05 +08:00
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, unsigned int uBlinks);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
|
|
|
static CCBlink* actionWithDuration(ccTime duration, unsigned int uBlinks);
|
|
|
|
protected:
|
|
|
|
int m_nTimes;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCFadeIn : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-11 14:03:46 +08:00
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2010-09-28 16:18:05 +08:00
|
|
|
/** creates the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
static CCFadeIn* actionWithDuration(ccTime d);
|
2010-08-06 10:51:40 +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
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCFadeOut : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-11 14:03:46 +08:00
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2010-09-28 16:18:05 +08:00
|
|
|
/** creates the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
static CCFadeOut* actionWithDuration(ccTime d);
|
2010-08-06 10:51:40 +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"
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCFadeTo : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with duration and opacity */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, GLubyte opacity);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
|
|
|
|
|
|
|
public:
|
2010-09-28 16:18:05 +08:00
|
|
|
/** creates an action with duration and opacity */
|
2010-08-06 10:51:40 +08:00
|
|
|
static CCFadeTo* actionWithDuration(ccTime duration, GLubyte opacity);
|
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCTintTo : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with duration and color */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates an action with duration and color */
|
|
|
|
static CCTintTo* actionWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue);
|
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCTintBy : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** initializes the action with duration and color */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates an action with duration and color */
|
|
|
|
static CCTintBy* actionWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
|
|
|
|
|
|
|
|
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
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCDelayTime : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-11 14:03:46 +08:00
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
|
|
|
|
|
|
|
public:
|
2010-09-28 16:18:05 +08:00
|
|
|
/** creates the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
static CCDelayTime* actionWithDuration(ccTime d);
|
2010-08-06 10:51:40 +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.
|
|
|
|
*/
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCReverseTime : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCReverseTime(void);
|
|
|
|
|
|
|
|
/** initializes the action */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithAction(CCFiniteTimeAction *pAction);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void stop(void);
|
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action */
|
|
|
|
static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CCFiniteTimeAction *m_pOther;
|
|
|
|
};
|
|
|
|
|
2010-09-02 10:33:39 +08:00
|
|
|
class CCTexture2D;
|
2010-09-28 18:27:33 +08:00
|
|
|
/** @brief Animates a sprite given the name of an Animation */
|
2010-12-22 15:43:54 +08:00
|
|
|
class CCX_DLL CCAnimate : public CCActionInterval
|
2010-08-06 10:51:40 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CCAnimate(void);
|
|
|
|
|
2010-09-29 17:39:45 +08:00
|
|
|
/** Get animation used for the animate */
|
2010-08-06 10:51:40 +08:00
|
|
|
inline CCAnimation* getAnimation(void) { return m_pAnimation; }
|
2010-09-29 17:39:45 +08:00
|
|
|
/** Set animation used for the animate, the object is retained */
|
2010-08-06 10:51:40 +08:00
|
|
|
inline void setAnimation(CCAnimation *pAnimation)
|
|
|
|
{
|
2010-09-27 18:19:10 +08:00
|
|
|
CCX_SAFE_RETAIN(pAnimation);
|
2010-09-06 13:52:57 +08:00
|
|
|
CCX_SAFE_RELEASE(m_pAnimation);
|
2010-08-06 10:51:40 +08:00
|
|
|
m_pAnimation = pAnimation;
|
|
|
|
}
|
|
|
|
|
2010-09-29 17:39:45 +08:00
|
|
|
/** initializes the action with an Animation and will restore the original frame when the animation is over */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithAnimation(CCAnimation *pAnimation);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
/** initializes the action with an Animation */
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithAnimation(CCAnimation *pAnimation, bool bRestoreOriginalFrame);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
/** initializes an action with a duration, animation and depending of the restoreOriginalFrame, it will restore the original frame or not.
|
2010-09-29 17:39:45 +08:00
|
|
|
The 'delay' parameter of the animation will be overridden by the duration parameter.
|
2010-08-06 10:51:40 +08:00
|
|
|
@since v0.99.0
|
|
|
|
*/
|
2010-08-11 14:03:46 +08:00
|
|
|
bool initWithDuration(ccTime duration, CCAnimation *pAnimation, bool bRestoreOriginalFrame);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
virtual NSObject* copyWithZone(NSZone* pZone);
|
2010-08-28 12:02:10 +08:00
|
|
|
virtual void startWithTarget(CCNode *pTarget);
|
2010-08-06 10:51:40 +08:00
|
|
|
virtual void stop(void);
|
|
|
|
virtual void update(ccTime time);
|
2010-12-22 15:43:54 +08:00
|
|
|
virtual CCActionInterval* reverse(void);
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** creates the action with an Animation and will restore the original frame when the animation is over */
|
|
|
|
static CCAnimate* actionWithAnimation(CCAnimation *pAnimation);
|
|
|
|
|
|
|
|
/** creates the action with an Animation */
|
|
|
|
static CCAnimate* actionWithAnimation(CCAnimation *pAnimation, bool bRestoreOriginalFrame);
|
|
|
|
|
|
|
|
/** creates an action with a duration, animation and depending of the restoreOriginalFrame, it will restore the original frame or not.
|
2010-09-29 17:39:45 +08:00
|
|
|
The 'delay' parameter of the animation will be overridden by the duration parameter.
|
2010-08-06 10:51:40 +08:00
|
|
|
@since v0.99.0
|
2010-09-28 16:18:05 +08:00
|
|
|
*/
|
2010-08-06 10:51:40 +08:00
|
|
|
static CCAnimate* actionWithDuration(ccTime duration, CCAnimation *pAnimation, bool bRestoreOriginalFrame);
|
|
|
|
protected:
|
|
|
|
CCAnimation *m_pAnimation;
|
2010-08-09 16:27:36 +08:00
|
|
|
CCSpriteFrame *m_pOrigFrame;
|
2010-08-06 10:51:40 +08:00
|
|
|
bool m_bRestoreOriginalFrame;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //__ACTION_CCINTERVAL_ACTION_H__
|