code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
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 __ACTIONS_CCACTION_H__
#define __ACTIONS_CCACTION_H__

#include "ccTypes.h"
#include "CCObject.h"
#include "CCZone.h"
#include "CCNode.h"

namespace   cocos2d {

enum {
	//! Default tag
	kCCActionTagInvalid = -1,
};

/**
@brief Base class for CCAction objects.
 */
class CC_DLL CCAction : public CCObject
{
public:
    CCAction(void);
	virtual ~CCAction(void);

	char * description();

	virtual CCObject* copyWithZone(CCZone *pZone);

	//! return true if the action has finished
	virtual bool isDone(void);

	//! called before the action start. It will also set the target.
	virtual void startWithTarget(CCNode *pTarget);

	/**
	called after the action has finished. It will set the 'target' to nil.
    IMPORTANT: You should never call "[action stop]" manually. Instead, use: "target->stopAction(action);"
	*/
    virtual void stop(void);

	//! called every frame with it's delta time. DON'T override unless you know what you are doing.
	virtual void step(ccTime dt);

	/**
	called once per frame. time a value between 0 and 1

	For example:
	- 0 means that the action just started
	- 0.5 means that the action is in the middle
	- 1 means that the action is over
	*/
	virtual void update(ccTime time);

	inline CCNode* getTarget(void) { return m_pTarget; }
	/** The action will modify the target properties. */
	inline void setTarget(CCNode *pTarget) { m_pTarget = pTarget; }

	inline CCNode* getOriginalTarget(void) { return m_pOriginalTarget; }
	/** Set the original target, since target can be nil.
	Is the target that were used to run the action. Unless you are doing something complex, like CCActionManager, you should NOT call this method.
	The target is 'assigned', it is not 'retained'.
	@since v0.8.2
	*/
	inline void setOriginalTarget(CCNode *pOriginalTarget) { m_pOriginalTarget = pOriginalTarget; }

	inline int getTag(void) { return m_nTag; }
	inline void setTag(int nTag) { m_nTag = nTag; }

public:
	/** Allocates and initializes the action */
	static CCAction* action();

protected:
	CCNode	*m_pOriginalTarget;
	/** The "target".
	The target will be set with the 'startWithTarget' method.
	When the 'stop' method is called, target will be set to nil.
	The target is 'assigned', it is not 'retained'.
	*/
	CCNode	*m_pTarget;
	/** The action tag. An identifier of the action */
	int 	m_nTag;
};

/**
@brief
 Base class actions that do have a finite time duration.
 Possible actions:
   - An action with a duration of 0 seconds
   - An action with a duration of 35.5 seconds

 Infinite time actions are valid
 */
class CC_DLL CCFiniteTimeAction : public CCAction
{
public:
	CCFiniteTimeAction()
		: m_fDuration(0)
	{}
	virtual ~CCFiniteTimeAction(){}
    //! get duration in seconds of the action
	inline ccTime getDuration(void) { return m_fDuration; }
	//! set duration in seconds of the action
	inline void setDuration(ccTime duration) { m_fDuration = duration; }

	/** returns a reversed action */
	virtual CCFiniteTimeAction* reverse(void);
protected:
	//! duration in seconds
	ccTime m_fDuration;
};

class CCActionInterval;
class CCRepeatForever;

/**
 @brief Changes the speed of an action, making it take longer (speed>1)
 or less (speed<1) time.
 Useful to simulate 'slow motion' or 'fast forward' effect.
 @warning This action can't be Sequenceable because it is not an CCIntervalAction
 */
class CC_DLL CCSpeed : public CCAction
{
public:
	CCSpeed()
		: m_fSpeed(0.0)
		, m_pInnerAction(NULL)
	{}
	virtual ~CCSpeed(void);

	inline float getSpeed(void) { return m_fSpeed; }
	/** alter the speed of the inner function in runtime */
	inline void setSpeed(float fSpeed) { m_fSpeed = fSpeed; }

	/** initializes the action */
	bool initWithAction(CCActionInterval *pAction, float fRate);

	virtual CCObject* copyWithZone(CCZone *pZone);
	virtual void startWithTarget(CCNode* pTarget);
	virtual void stop();
	virtual void step(ccTime dt);
	virtual bool isDone(void);
	virtual CCActionInterval* reverse(void);

	void setInnerAction(CCActionInterval *pAction);

	inline CCActionInterval* getInnerAction()
	{
		return m_pInnerAction;
	}

public:
	/** creates the action */
	static CCSpeed* actionWithAction(CCActionInterval *pAction, float fRate);

protected:
	float m_fSpeed;
	CCActionInterval *m_pInnerAction;
};

class CCNode;
class CCPoint;
class CCRect;
/**
@brief CCFollow is an action that "follows" a node.

Eg:
layer->runAction(CCFollow::actionWithTarget(hero));

Instead of using CCCamera as a "follower", use this action instead.
@since v0.99.2
*/
class CC_DLL CCFollow : public CCAction
{
public:
	CCFollow()
		: m_pobFollowedNode(NULL)
        , m_bBoundarySet(false)
		, m_bBoundaryFullyCovered(false)
		, m_fLeftBoundary(0.0)
		, m_fRightBoundary(0.0)
		, m_fTopBoundary(0.0)
        , m_fBottomBoundary(0.0)
	{}
	virtual ~CCFollow(void);

	inline bool isBoundarySet(void) { return m_bBoundarySet; }
	/** alter behavior - turn on/off boundary */
	inline void setBoudarySet(bool bValue) { m_bBoundarySet = bValue; }

	/** initializes the action */
	bool initWithTarget(CCNode *pFollowedNode);

	/** initializes the action with a set boundary */
	bool initWithTarget(CCNode *pFollowedNode, const CCRect& rect);

	virtual CCObject* copyWithZone(CCZone *pZone);
	virtual void step(ccTime dt);
	virtual bool isDone(void);
	virtual void stop(void);

public:
	/** creates the action with no boundary set */
	static CCFollow* actionWithTarget(CCNode *pFollowedNode);

	/** creates the action with a set boundary */
	static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect);

protected:
	// node to follow
	CCNode *m_pobFollowedNode;

	// whether camera should be limited to certain area
	bool m_bBoundarySet;

	// if screen size is bigger than the boundary - update not needed
	bool m_bBoundaryFullyCovered;

	// fast access to the screen dimensions
	CCPoint m_obHalfScreenSize;
	CCPoint m_obFullScreenSize;

	// world boundaries
	float m_fLeftBoundary;
	float m_fRightBoundary;
	float m_fTopBoundary;
	float m_fBottomBoundary;
};
}//namespace   cocos2d

#endif // __ACTIONS_CCACTION_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada

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 __CCCAMERA_ACTION_H__
#define __CCCAMERA_ACTION_H__
#include "CCActionInterval.h"

namespace cocos2d {
	class CCCamera;

	/**
	@brief Base class for CCCamera actions
	*/
	class CC_DLL CCActionCamera : public CCActionInterval //<NSCopying>
	{
	public:
		CCActionCamera()
			:m_fCenterXOrig(0)
			,m_fCenterYOrig(0)
			,m_fCenterZOrig(0)
			,m_fEyeXOrig(0)
			,m_fEyeYOrig(0)
			,m_fEyeZOrig(0)
			,m_fUpXOrig(0)
			,m_fUpYOrig(0)
			,m_fUpZOrig(0)
		{}
		virtual ~CCActionCamera(){}
		// super methods
		virtual void startWithTarget(CCNode *pTarget);
		virtual CCActionInterval * reverse();
	protected:
		float m_fCenterXOrig;
		float m_fCenterYOrig;
		float m_fCenterZOrig;

		float m_fEyeXOrig;
		float m_fEyeYOrig;
		float m_fEyeZOrig;

		float m_fUpXOrig;
		float m_fUpYOrig;
		float m_fUpZOrig;
	};

	/**
	@brief CCOrbitCamera action
	Orbits the camera around the center of the screen using spherical coordinates
	*/
	class CC_DLL CCOrbitCamera : public CCActionCamera //<NSCopying>
	{
	public:
		CCOrbitCamera()
			: m_fRadius(0.0)
            , m_fDeltaRadius(0.0)
            , m_fAngleZ(0.0)
            , m_fDeltaAngleZ(0.0)
            , m_fAngleX(0.0)
			, m_fDeltaAngleX(0.0)
            , m_fRadZ(0.0)
            , m_fRadDeltaZ(0.0)
            , m_fRadX(0.0)
			, m_fRadDeltaX(0.0)
		{}
		~CCOrbitCamera(){}
		/** creates a CCOrbitCamera action with radius, delta-radius,  z, deltaZ, x, deltaX */
		static CCOrbitCamera * actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
		/** initializes a CCOrbitCamera action with radius, delta-radius,  z, deltaZ, x, deltaX */
		bool initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
		/** positions the camera according to spherical coordinates */
		void sphericalRadius(float *r, float *zenith, float *azimuth);
		// super methods
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void startWithTarget(CCNode *pTarget);
		virtual void update(ccTime time);

	protected:
		float m_fRadius;
		float m_fDeltaRadius;
		float m_fAngleZ;
		float m_fDeltaAngleZ;
		float m_fAngleX;
		float m_fDeltaAngleX;

		float m_fRadZ;
		float m_fRadDeltaZ;
		float m_fRadX;
		float m_fRadDeltaX;
	};

} // namespace cocos2d

#endif //__CCCAMERA_ACTION_H__

license: mit


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2009 Jason Booth

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_CCEASE_ACTION_H__
#define __ACTION_CCEASE_ACTION_H__

#include "CCActionInterval.h"

namespace cocos2d {

class CCObject;
class CCZone;

/**
 @brief Base class for Easing actions
 */
class CC_DLL CCActionEase : public CCActionInterval
{
public:
	virtual ~CCActionEase(void);

	/** initializes the action */
    bool initWithAction(CCActionInterval *pAction);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void stop(void);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

public:
	/** creates the action */
	static CCActionEase* actionWithAction(CCActionInterval *pAction);

protected:
	CCActionInterval *m_pOther;
};

/**
 @brief Base class for Easing actions with rate parameters
 */
class CC_DLL CCEaseRateAction : public CCActionEase
{
public:
	virtual ~CCEaseRateAction(void);

	/** set rate value for the actions */
	inline void setRate(float rate) { m_fRate = rate; }
	/** get rate value for the actions */
	inline float getRate(void) { return m_fRate; }

	/** Initializes the action with the inner action and the rate parameter */
	bool initWithAction(CCActionInterval *pAction, float fRate);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual CCActionInterval* reverse(void);

public:
	/** Creates the action with the inner action and the rate parameter */
	static CCEaseRateAction* actionWithAction(CCActionInterval* pAction, float fRate);

protected:
	float m_fRate;
};

/**
 @brief CCEaseIn action with a rate
 */
class CC_DLL CCEaseIn : public CCEaseRateAction
{
public:
	virtual void update(ccTime time);
	virtual CCObject* copyWithZone(CCZone* pZone);
public:
	/** Creates the action with the inner action and the rate parameter */
	static CCEaseIn* actionWithAction(CCActionInterval* pAction, float fRate);
};

/**
 @brief CCEaseOut action with a rate
 */
class CC_DLL CCEaseOut : public CCEaseRateAction
{
public:
	virtual void update(ccTime time);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** Creates the action with the inner action and the rate parameter */
    static CCEaseOut* actionWithAction(CCActionInterval* pAction, float fRate);
};

/**
 @brief CCEaseInOut action with a rate
 */
class CC_DLL CCEaseInOut : public CCEaseRateAction
{
public:
	virtual void update(ccTime time);
	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual CCActionInterval* reverse(void);

public:
	/** Creates the action with the inner action and the rate parameter */
	static CCEaseInOut* actionWithAction(CCActionInterval* pAction, float fRate);
};

/**
 @brief CCEase Exponential In
 */
class CC_DLL CCEaseExponentialIn : public CCActionEase
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseExponentialIn* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief Ease Exponential Out
 */
class CC_DLL CCEaseExponentialOut : public CCActionEase
{
public:
    virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseExponentialOut* actionWithAction(CCActionInterval* pAction);

};

/**
 @brief Ease Exponential InOut
 */
class CC_DLL CCEaseExponentialInOut : public CCActionEase
{
public:
	virtual void update(ccTime time);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseExponentialInOut* actionWithAction(CCActionInterval* pAction);

};

/**
 @brief Ease Sine In
 */
class CC_DLL CCEaseSineIn : public CCActionEase
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseSineIn* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief Ease Sine Out
 */
class CC_DLL CCEaseSineOut : public CCActionEase
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseSineOut* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief Ease Sine InOut
 */
class CC_DLL CCEaseSineInOut : public CCActionEase
{
public:
	virtual void update(ccTime time);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseSineInOut* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief Ease Elastic abstract class
 @since v0.8.2
 */
class CC_DLL CCEaseElastic : public CCActionEase
{
public:
	/** get period of the wave in radians. default is 0.3 */
	inline float getPeriod(void) { return m_fPeriod; }
	/** set period of the wave in radians. */
	inline void setPeriod(float fPeriod) { m_fPeriod = fPeriod; }

	/** Initializes the action with the inner action and the period in radians (default is 0.3) */
	bool initWithAction(CCActionInterval *pAction, float fPeriod);
	/** initializes the action */
	bool initWithAction(CCActionInterval *pAction);

	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseElastic* actionWithAction(CCActionInterval *pAction);
	/** Creates the action with the inner action and the period in radians (default is 0.3) */
	static CCEaseElastic* actionWithAction(CCActionInterval *pAction, float fPeriod);

protected:
	float m_fPeriod;
};

/**
 @brief Ease Elastic In action.
 @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
 */
class CC_DLL CCEaseElasticIn : public CCEaseElastic
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction);
	/** Creates the action with the inner action and the period in radians (default is 0.3) */
	static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction, float fPeriod);
};

/**
 @brief Ease Elastic Out action.
 @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
 */
class CC_DLL CCEaseElasticOut : public CCEaseElastic
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction);
	/** Creates the action with the inner action and the period in radians (default is 0.3) */
	static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction, float fPeriod);
};

/**
 @brief Ease Elastic InOut action.
 @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
 */
class CC_DLL CCEaseElasticInOut : public CCEaseElastic
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction);
	/** Creates the action with the inner action and the period in radians (default is 0.3) */
	static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction, float fPeriod);
};

/**
 @brief CCEaseBounce abstract class.
 @since v0.8.2
*/
class CC_DLL CCEaseBounce : public CCActionEase
{
public:
	ccTime bounceTime(ccTime time);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseBounce* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief CCEaseBounceIn action.
 @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
*/
class CC_DLL CCEaseBounceIn : public CCEaseBounce
{
public:
    virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseBounceIn* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief EaseBounceOut action.
 @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
 */
class CC_DLL CCEaseBounceOut : public CCEaseBounce
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseBounceOut* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief CCEaseBounceInOut action.
 @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
 */
class CC_DLL CCEaseBounceInOut : public CCEaseBounce
{
public:
	virtual void update(ccTime time);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseBounceInOut* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief CCEaseBackIn action.
 @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
 */
class CC_DLL CCEaseBackIn : public CCActionEase
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseBackIn* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief CCEaseBackOut action.
 @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
 */
class CC_DLL CCEaseBackOut : public CCActionEase
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseBackOut* actionWithAction(CCActionInterval* pAction);
};

/**
 @brief CCEaseBackInOut action.
 @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
 @since v0.8.2
 */
class CC_DLL CCEaseBackInOut : public CCActionEase
{
public:
	virtual void update(ccTime time);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCEaseBackInOut* actionWithAction(CCActionInterval* pAction);
};

}

#endif // __ACTION_CCEASE_ACTION_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
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"

namespace cocos2d
{
	class CCGridBase;

	/** @brief Base class for Grid actions */
	class CC_DLL CCGridAction : public CCActionInterval
	{
	public:
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void startWithTarget(CCNode *pTarget);
		virtual CCActionInterval* reverse(void);

		/** initializes the action with size and duration */
		virtual bool initWithSize(const ccGridSize& gridSize, ccTime duration);
		/** returns the grid */
		virtual CCGridBase* getGrid(void);

	public:
		/** creates the action with size and duration */
		static CCGridAction* actionWithSize(const ccGridSize& gridSize, ccTime duration);

	protected:
		ccGridSize m_sGridSize;
	};

	/**
	 @brief Base class for CCGrid3D actions.
	 Grid3D actions can modify a non-tiled grid.
	 */
	class CC_DLL CCGrid3DAction : public CCGridAction
	{
	public:
		/** returns the grid */
		virtual CCGridBase* getGrid(void);
		/** returns the vertex than belongs to certain position in the grid */
		ccVertex3F vertex(const ccGridSize& pos);
		/** returns the non-transformed vertex than belongs to certain position in the grid */
		ccVertex3F originalVertex(const ccGridSize& pos);
		/** sets a new vertex to a certain position of the grid */
		void setVertex(const ccGridSize& pos, const ccVertex3F& vertex);

	public:
		/** creates the action with size and duration */
        static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, ccTime duration);
	};

	/** @brief Base class for CCTiledGrid3D actions */
	class CC_DLL CCTiledGrid3DAction : public CCGridAction
	{
	public:
		/** returns the tile that belongs to a certain position of the grid */
		ccQuad3 tile(const ccGridSize& pos);
		/** returns the non-transformed tile that belongs to a certain position of the grid */
		ccQuad3 originalTile(const ccGridSize& pos);
		/** sets a new tile to a certain position of the grid */
		void setTile(const ccGridSize& pos, const ccQuad3& coords);

		/** returns the grid */
		virtual CCGridBase* getGrid(void);

	public:
		/** creates the action with size and duration */
        static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, ccTime duration);
	};

	/** @brief CCAccelDeccelAmplitude action */
	class CC_DLL CCAccelDeccelAmplitude : public CCActionInterval
	{
	public:
		virtual ~CCAccelDeccelAmplitude(void);
		/** initializes the action with an inner action that has the amplitude property, and a duration time */
		bool initWithAction(CCAction *pAction, ccTime duration);

		virtual void startWithTarget(CCNode *pTarget);
		virtual void update(ccTime time);
        virtual CCActionInterval* reverse(void);

		/** get amplitude rate */
		inline float getRate(void) { return m_fRate; }
		/** set amplitude rate */
		inline void setRate(float fRate) { m_fRate = fRate; }

	public:
		/** creates the action with an inner action that has the amplitude property, and a duration time */
		static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration);

	protected:
		float m_fRate;
		CCActionInterval *m_pOther;
	};

	/** @brief CCAccelAmplitude action */
	class CC_DLL CCAccelAmplitude : public CCActionInterval
	{
	public:
		~CCAccelAmplitude(void);
		/** initializes the action with an inner action that has the amplitude property, and a duration time */
		bool initWithAction(CCAction *pAction, ccTime duration);

		/** get amplitude rate */
		inline float getRate(void) { return m_fRate; }
		/** set amplitude rate */
		inline void setRate(float fRate) { m_fRate = fRate; }

		virtual void startWithTarget(CCNode *pTarget);
		virtual void update(ccTime time);
        virtual CCActionInterval* reverse(void);

	public:
		/** creates the action with an inner action that has the amplitude property, and a duration time */
		static CCAccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration);

	protected:
		float m_fRate;
		CCActionInterval *m_pOther;
	};

	/** @brief CCDeccelAmplitude action */
	class CC_DLL CCDeccelAmplitude : public CCActionInterval
	{
	public:
		~CCDeccelAmplitude(void);
		/** initializes the action with an inner action that has the amplitude property, and a duration time */
		bool initWithAction(CCAction *pAction, ccTime duration);

		/** get amplitude rate */
		inline float getRate(void) { return m_fRate; }
		/** set amplitude rate */
		inline void setRate(float fRate) { m_fRate = fRate; }

		virtual void startWithTarget(CCNode *pTarget);
		virtual void update(ccTime time);
        virtual CCActionInterval* reverse(void);

	public:
		/** creates the action with an inner action that has the amplitude property, and a duration time */
        static CCDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration);

	protected:
		float m_fRate;
		CCActionInterval *m_pOther;
	};

	/** @brief CCStopGrid action.
	 @warning Don't call this action if another grid action is active.
	 Call if you want to remove the the grid effect. Example:
	 CCSequence::actions(Lens::action(...), CCStopGrid::action(...), NULL);
	 */
	class CC_DLL CCStopGrid : public CCActionInstant
	{
	public:
		virtual void startWithTarget(CCNode *pTarget);

	public:
		/** Allocates and initializes the action */
		static CCStopGrid* action(void);
	};

	/** @brief CCReuseGrid action */
	class CC_DLL CCReuseGrid : public CCActionInstant
	{
	public:
		/** initializes an action with the number of times that the current grid will be reused */
        bool initWithTimes(int times);

		virtual void startWithTarget(CCNode *pTarget);

	public:
		/** creates an action with the number of times that the current grid will be reused */
		static CCReuseGrid* actionWithTimes(int times);

	protected:
		int m_nTimes;
	};

} // end of namespace cocos2d

#endif // __ACTION_CCGRID_ACTION_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
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_CCGRID3D_ACTION_H__
#define __ACTION_CCGRID3D_ACTION_H__

#include "CCActionGrid.h"

namespace cocos2d
{
	/**
	@brief CCWaves3D action
	*/
	class CC_DLL CCWaves3D : public CCGrid3DAction
	{
	public:
		inline float getAmplitude(void) { return m_fAmplitude; }
		inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }

		inline float getAmplitudeRate(void) { return m_fAmplitudeRate; }
		inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; }

		/** init the action */
		bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration);

		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** create the action */
		static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration);

	protected:
		int m_nWaves;
		float m_fAmplitude;
		float m_fAmplitudeRate;
	};

	/** @brief CCFlipX3D action */
	class CC_DLL CCFlipX3D : public CCGrid3DAction
	{
	public:
		/** initializes the action with duration */
		bool initWithDuration(ccTime duration);
		virtual bool initWithSize(const ccGridSize& gridSize, ccTime duration);
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with duration */
		static CCFlipX3D* actionWithDuration(ccTime duration);
	};

	/** @brief CCFlipY3D action */
	class CC_DLL CCFlipY3D : public CCFlipX3D
	{
	public:
		virtual void update(ccTime time);
		virtual CCObject* copyWithZone(CCZone* pZone);

	public:
		/** creates the action with duration */
		static CCFlipY3D* actionWithDuration(ccTime duration);
	};

	/** @brief CCLens3D action */
	class CC_DLL CCLens3D : public CCGrid3DAction
	{
	public:
		/** Get lens center position */
		inline float getLensEffect(void) { return m_fLensEffect; }
		/** Set lens center position */
		inline void setLensEffect(float fLensEffect) { m_fLensEffect = fLensEffect; }

		inline const CCPoint& getPosition(void) { return m_position; }
		void setPosition(const CCPoint& position);

		/** initializes the action with center position, radius, a grid size and duration */
		bool initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration);
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with center position, radius, a grid size and duration */
        static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration);
	protected:
		/* lens center position */
		CCPoint m_position;
		float m_fRadius;
		/** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */
		float m_fLensEffect;

        /* @since v0.99.5 */
        // CCPoint m_lastPosition;
        CCPoint m_positionInPixels;
        bool    m_bDirty;
	};

	/** @brief CCRipple3D action */
	class CC_DLL CCRipple3D : public CCGrid3DAction
	{
	public:
		/** get center position */
		inline const CCPoint& getPosition(void) { return m_position; }
		/** set center position */
		void setPosition(const CCPoint& position);

		inline float getAmplitude(void) { return m_fAmplitude; }
		inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }

		inline float getAmplitudeRate(void) { return m_fAmplitudeRate; }
		inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; }

		/** initializes the action with radius, number of waves, amplitude, a grid size and duration */
		bool initWithPosition(const CCPoint& pos, float r, int wav, float amp,
			const ccGridSize& gridSize, ccTime duration);
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with radius, number of waves, amplitude, a grid size and duration */
		static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp,
			const ccGridSize& gridSize, ccTime duration);
	protected:
		/* center position */
		CCPoint m_position;
		float m_fRadius;
		int m_nWaves;
		float m_fAmplitude;
		float m_fAmplitudeRate;

        /*@since v0.99.5*/
        CCPoint m_positionInPixels;
	};

	/** @brief CCShaky3D action */
	class CC_DLL CCShaky3D : public CCGrid3DAction
	{
	public:
		/** initializes the action with a range, shake Z vertices, a grid and duration */
		bool initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration);
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with a range, shake Z vertices, a grid and duration */
        static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration);

	protected:
		int m_nRandrange;
		bool m_bShakeZ;
	};

	/** @brief CCLiquid action */
	class CC_DLL CCLiquid : public CCGrid3DAction
	{
	public:
		inline float getAmplitude(void) { return m_fAmplitude; }
		inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }

		inline float getAmplitudeRate(void) { return m_fAmplitudeRate; }
		inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; }

		/** initializes the action with amplitude, a grid and duration */
		bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration);
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with amplitude, a grid and duration */
		static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration);

	protected:
		int m_nWaves;
		float m_fAmplitude;
		float m_fAmplitudeRate;
	};

	/** @brief CCWaves action */
	class CC_DLL CCWaves : public CCGrid3DAction
	{
	public:
		inline float getAmplitude(void) { return m_fAmplitude; }
		inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }

		inline float getAmplitudeRate(void) { return m_fAmplitudeRate; }
		inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; }

		/** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */
		bool initWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize,
			ccTime duration);
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */
        static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize,
			ccTime duration);
	protected:
		int m_nWaves;
		float m_fAmplitude;
		float m_fAmplitudeRate;
		bool m_bVertical;
		bool m_bHorizontal;
	};

	/** @brief CCTwirl action */
	class CC_DLL CCTwirl : public CCGrid3DAction
	{
	public:
		/** get twirl center */
		inline const CCPoint& getPosition(void) { return m_position; }
		/** set twirl center */
		void setPosition(const CCPoint& position);

		inline float getAmplitude(void) { return m_fAmplitude; }
		inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }

		inline float getAmplitudeRate(void) { return m_fAmplitudeRate; }
		inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; }

		/** initializes the action with center position, number of twirls, amplitude, a grid size and duration */
		bool initWithPosition(const CCPoint& pos, int t, float amp, const ccGridSize& gridSize,
			ccTime duration);
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with center position, number of twirls, amplitude, a grid size and duration */
		static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize,
			ccTime duration);
	protected:
		/* twirl center */
		CCPoint m_position;
		int m_nTwirls;
		float m_fAmplitude;
		float m_fAmplitudeRate;

        /*@since v0.99.5 */
        CCPoint m_positionInPixels;
	};
}

#endif // __ACTION_CCGRID3D_ACTION_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
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 __CCINSTANT_ACTION_H__
#define __CCINSTANT_ACTION_H__

#include <string>
#include "CCAction.h"

namespace cocos2d {

	/**
	@brief Instant actions are immediate actions. They don't have a duration like
	the CCIntervalAction actions.
	*/
	class CC_DLL CCActionInstant : public CCFiniteTimeAction //<NSCopying>
	{
	public:
		CCActionInstant();
		virtual ~CCActionInstant(){}
		// CCAction methods
		virtual CCObject* copyWithZone(CCZone *pZone);
		virtual bool isDone(void);
		virtual void step(ccTime dt);
		virtual void update(ccTime time);
		//CCFiniteTimeAction method
		virtual CCFiniteTimeAction * reverse(void);
	};

	/** @brief Show the node
	*/
	class CC_DLL CCShow : public CCActionInstant
	{
	public:
		CCShow(){}
		virtual ~CCShow(){}
		//super methods
		virtual void startWithTarget(CCNode *pTarget);
		virtual CCFiniteTimeAction * reverse(void);
		virtual CCObject* copyWithZone(CCZone *pZone);
	public:
		//override static method
		/** Allocates and initializes the action */
		static CCShow * action();
	};

	/**
	@brief Hide the node
	*/
	class CC_DLL CCHide : public CCActionInstant
	{
	public:
		CCHide(){}
		virtual ~CCHide(){}
		//super methods
		virtual void startWithTarget(CCNode *pTarget);
		virtual CCFiniteTimeAction * reverse(void);
		virtual CCObject* copyWithZone(CCZone *pZone);
	public:
		//override static method
		/** Allocates and initializes the action */
		static CCHide * action();
	};

	/** @brief Toggles the visibility of a node
	*/
	class CC_DLL CCToggleVisibility : public CCActionInstant
	{
	public:
		CCToggleVisibility(){}
		virtual ~CCToggleVisibility(){}
		//super method
		virtual void startWithTarget(CCNode *pTarget);
	public:
		//override static method
		/** Allocates and initializes the action */
		static CCToggleVisibility * action();
	};

	/**
	@brief Flips the sprite horizontally
	@since v0.99.0
	*/
	class CC_DLL CCFlipX : public CCActionInstant
	{
	public:
		CCFlipX()
			:m_bFlipX(false)
		{}
		virtual ~CCFlipX(){}

		/** create the action */
		static CCFlipX * actionWithFlipX(bool x);
		/** init the action */
		bool initWithFlipX(bool x);
		//super methods
		virtual void startWithTarget(CCNode *pTarget);
		virtual CCFiniteTimeAction * reverse(void);
		virtual CCObject* copyWithZone(CCZone *pZone);

	protected:
		bool	m_bFlipX;
	};

	/**
	@brief Flips the sprite vertically
	@since v0.99.0
	*/
	class CC_DLL CCFlipY : public CCActionInstant
	{
	public:
		CCFlipY()
			:m_bFlipY(false)
		{}
		virtual ~CCFlipY(){}

		/** create the action */
		static CCFlipY * actionWithFlipY(bool y);
		/** init the action */
		bool initWithFlipY(bool y);
		//super methods
		virtual void startWithTarget(CCNode *pTarget);
		virtual CCFiniteTimeAction * reverse(void);
		virtual CCObject* copyWithZone(CCZone *pZone);

	protected:
		bool	m_bFlipY;
	};

	/** @brief Places the node in a certain position
	*/
	class CC_DLL CCPlace : public CCActionInstant //<NSCopying>
	{
	public:
		CCPlace(){}
		virtual ~CCPlace(){}
		/** creates a Place action with a position */
		static CCPlace * actionWithPosition(const CCPoint& pos);
		/** Initializes a Place action with a position */
		bool initWithPosition(const CCPoint& pos);
		//super methods
		virtual void startWithTarget(CCNode *pTarget);
		virtual CCObject* copyWithZone(CCZone *pZone);
	protected:
		CCPoint m_tPosition;
	};

	/** @brief Calls a 'callback'
	*/
	class CC_DLL CCCallFunc : public CCActionInstant //<NSCopying>
	{
	public:
		CCCallFunc()
            : m_pSelectorTarget(NULL)
            , m_pCallFunc(NULL)

        {
		}
		virtual ~CCCallFunc()
		{
			if (m_pSelectorTarget)
			{
				m_pSelectorTarget->release();
			}
		}
		/** creates the action with the callback

		typedef void (CCObject::*SEL_CallFunc)();
		*/
		static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector);
		/** initializes the action with the callback

		typedef void (CCObject::*SEL_CallFunc)();
		*/
		virtual bool initWithTarget(CCObject* pSelectorTarget);
		/** executes the callback */
		virtual void execute();
		//super methods
		virtual void startWithTarget(CCNode *pTarget);
		CCObject * copyWithZone(CCZone *pZone);

		inline CCObject* getTargetCallback()
		{
			return m_pSelectorTarget;
		}

		inline void setTargetCallback(CCObject* pSel)
		{
			if (pSel != m_pSelectorTarget)
			{
				if (m_pSelectorTarget)
				{
					m_pSelectorTarget->release();
				}

				m_pSelectorTarget = pSel;

				if (m_pSelectorTarget)
				{
					m_pSelectorTarget->retain();
				}
			}
		}

	protected:
		/** Target that will be called */
		CCObject*   m_pSelectorTarget;

		union
		{
			SEL_CallFunc	m_pCallFunc;
			SEL_CallFuncN	m_pCallFuncN;
			SEL_CallFuncND	m_pCallFuncND;
            SEL_CallFuncO   m_pCallFuncO;
		};
	};

	/**
	@brief Calls a 'callback' with the node as the first argument
	N means Node
	*/
	class CC_DLL CCCallFuncN : public CCCallFunc
	{
	public:
		CCCallFuncN(){}
		virtual ~CCCallFuncN(){}
		/** creates the action with the callback

		typedef void (CCObject::*SEL_CallFuncN)(CCNode*);
		*/
		static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector);
		/** initializes the action with the callback

		typedef void (CCObject::*SEL_CallFuncN)(CCNode*);
		*/
		virtual bool initWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector);
		// super methods
		virtual CCObject* copyWithZone(CCZone *pZone);
		virtual void execute();
	};

	/**
	@brief Calls a 'callback' with the node as the first argument and the 2nd argument is data
	* ND means: Node and Data. Data is void *, so it could be anything.
	*/
	class CC_DLL CCCallFuncND : public CCCallFuncN
	{
	public:

		/** creates the action with the callback and the data to pass as an argument */
		static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d);
		/** initializes the action with the callback and the data to pass as an argument */
		virtual bool initWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d);
		// super methods
		virtual CCObject* copyWithZone(CCZone *pZone);
		virtual void execute();

	protected:
		void			*m_pData;
	};

    /**
    @brief Calls a 'callback' with an object as the first argument.
    O means Object.
    @since v0.99.5
    */
    class CC_DLL CCCallFuncO : public CCCallFunc
    {
    public:
        CCCallFuncO();
        virtual ~CCCallFuncO();
        /** creates the action with the callback

        typedef void (CCObject::*SEL_CallFuncO)(CCObject*);
        */
        static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject);
        /** initializes the action with the callback

        typedef void (CCObject::*SEL_CallFuncO)(CCObject*);
        */
        virtual bool initWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject);
        // super methods
        virtual CCObject* copyWithZone(CCZone *pZone);
        virtual void execute();

		inline CCObject* getObject()
		{
			return m_pObject;
		}

		inline void setObject(CCObject* pObj)
		{
			if (pObj != m_pObject)
			{
				CC_SAFE_RELEASE(m_pObject);
				m_pObject = pObj;
				CC_SAFE_RETAIN(m_pObject);
			}
		}

    protected:
		/** object to be passed as argument */
        CCObject* m_pObject;
    };

}

#endif //__CCINSTANT_ACTION_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
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__

#include "CCNode.h"
#include "CCAction.h"
#include "CCProtocols.h"
#include "CCSpriteFrame.h"
#include "CCAnimation.h"

namespace cocos2d {

/**
@brief An interval action is an action that takes place within a certain period of time.
It has an start time, and a finish time. The finish time is the parameter
duration plus the start time.

These CCActionInterval actions have some interesting properties, like:
- 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.

For example, you can simulate a Ping Pong effect running the action normally and
then running it again in Reverse mode.

Example:

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. */
	inline ccTime getElapsed(void) { return m_elapsed; }

	/** initializes the action */
	bool initWithDuration(ccTime d);

	/** returns true if the action has finished */
	virtual bool isDone(void);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void step(ccTime dt);
	virtual void startWithTarget(CCNode *pTarget);
	/** returns a reversed action */
	virtual CCActionInterval* reverse(void);

public:
	/** creates the action */
	static CCActionInterval* actionWithDuration(ccTime d);

public:
    //extension in CCGridAction
	void setAmplitudeRate(CGFloat amp);
	CGFloat getAmplitudeRate(void);

protected:
	ccTime m_elapsed;
	bool   m_bFirstTick;
};

/** @brief Runs actions sequentially, one after another
 */
class CC_DLL CCSequence : public CCActionInterval
{
public:
	~CCSequence(void);

	/** initializes the action */
    bool initOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void stop(void);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

public:
	/** helper constructor to create an array of sequenceable actions */
	static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...);
	/** helper contructor to create an array of sequenceable actions given an array */
	static CCFiniteTimeAction* actionsWithArray(CCArray *actions);
    /** for Lua */
    static CCSequence* actionsWithArrayLua(CCArray *actions);

	/** creates the action */
	static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
protected:
	CCFiniteTimeAction *m_pActions[2];
	ccTime m_split;
	int m_last;
};

/** @brief Repeats an action a number of times.
 * To repeat an action forever use the CCRepeatForever action.
 */
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);
	virtual void update(ccTime time);
	virtual bool isDone(void);
	virtual CCActionInterval* reverse(void);

	inline void setInnerAction(CCFiniteTimeAction *pAction)
	{
		if (m_pInnerAction != pAction)
		{
			CC_SAFE_RELEASE(m_pInnerAction);
			m_pInnerAction = pAction;
			CC_SAFE_RETAIN(m_pInnerAction);
		}
	}

	inline CCFiniteTimeAction* getInnerAction()
	{
		return m_pInnerAction;
	}

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;
	/** Inner action */
	CCFiniteTimeAction *m_pInnerAction;
};

/** @brief Repeats an action for ever.
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
*/
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);
	virtual void step(ccTime dt);
	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:
	/** creates the action */
	static CCRepeatForever* actionWithAction(CCActionInterval *pAction);

protected:
	/** Inner action */
	CCActionInterval *m_pInnerAction;
};

/** @brief Spawn a new action immediately
 */
class CC_DLL CCSpawn : public CCActionInterval
{
public:
	~CCSpawn(void);

	/** initializes the Spawn action with the 2 actions to spawn */
	bool initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void stop(void);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

public:
	/** helper constructor to create an array of spawned actions */
	static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...);

	/** helper contructor to create an array of spawned actions given an array */
	static CCFiniteTimeAction* actionsWithArray(CCArray *actions);
	static CCSpawn* actionsWithArrayLua(CCArray *actions);

	/** creates the Spawn action */
	static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);

protected:
	CCFiniteTimeAction *m_pOne;
	CCFiniteTimeAction *m_pTwo;
};

/** @brief Rotates a CCNode object to a certain angle by modifying it's
 rotation attribute.
 The direction will be decided by the shortest angle.
*/
class CC_DLL CCRotateTo : public CCActionInterval
{
public:
	/** initializes the action */
	bool initWithDuration(ccTime duration, float fDeltaAngle);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	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;
};

/** @brief Rotates a CCNode object clockwise a number of degrees by modifying it's rotation attribute.
*/
class CC_DLL CCRotateBy : public CCActionInterval
{
public:
	/** initializes the action */
    bool initWithDuration(ccTime duration, float fDeltaAngle);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

public:
	/** creates the action */
	static CCRotateBy* actionWithDuration(ccTime duration, float fDeltaAngle);

protected:
	float m_fAngle;
	float m_fStartAngle;
};

/** @brief Moves a CCNode object to the position x,y. x and y are absolute coordinates by modifying it's position attribute.
*/
class CC_DLL CCMoveTo : public CCActionInterval
{
public:
	/** initializes the action */
	bool initWithDuration(ccTime duration, const CCPoint& position);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);

public:
	/** creates the action */
	static CCMoveTo* actionWithDuration(ccTime duration, const CCPoint& position);

protected:
	CCPoint m_endPosition;
	CCPoint m_startPosition;
	CCPoint m_delta;
};

/** @brief Moves a CCNode object x,y pixels by modifying it's position attribute.
 x and y are relative to the position of the object.
 Duration is is seconds.
*/
class CC_DLL CCMoveBy : public CCMoveTo
{
public:
	/** initializes the action */
	bool initWithDuration(ccTime duration, const CCPoint& position);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual CCActionInterval* reverse(void);

public:
	/** creates the action */
	static CCMoveBy* actionWithDuration(ccTime duration, const CCPoint& position);
};

/** 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();
	virtual bool initWithDuration(ccTime t, float sx, float sy);
	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);

public:
	static CCSkewTo* actionWithDuration(ccTime t, float sx, float sy);

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:
	virtual bool initWithDuration(ccTime t, float sx, float sy);
	virtual void startWithTarget(CCNode *pTarget);
	virtual CCActionInterval* reverse(void);

public:
	static CCSkewBy* actionWithDuration(ccTime t, float deltaSkewX, float deltaSkewY);
};

/** @brief Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute.
*/
class CC_DLL CCJumpBy : public CCActionInterval
{
public:
	/** initializes the action */
	bool initWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

public:
	/** creates the action */
	static CCJumpBy* actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps);

protected:
	CCPoint			m_startPosition;
	CCPoint			m_delta;
	ccTime			m_height;
	unsigned int    m_nJumps;
};

/** @brief Moves a CCNode object to a parabolic position simulating a jump movement by modifying it's position attribute.
*/
class CC_DLL CCJumpTo : public CCJumpBy
{
public:
    virtual void startWithTarget(CCNode *pTarget);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCJumpTo* actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, int jumps);
};

/** @typedef bezier configuration structure
 */
typedef struct _ccBezierConfig {
	//! end position of the bezier
	CCPoint endPosition;
	//! Bezier control point 1
	CCPoint controlPoint_1;
	//! Bezier control point 2
	CCPoint controlPoint_2;
} ccBezierConfig;

/** @brief An action that moves the target with a cubic Bezier curve by a certain distance.
 */
class CC_DLL CCBezierBy : public CCActionInterval
{
public:
	/** initializes the action with a duration and a bezier configuration */
	bool initWithDuration(ccTime t, const ccBezierConfig& c);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

public:
	/** creates the action with a duration and a bezier configuration */
	static CCBezierBy* actionWithDuration(ccTime t, const ccBezierConfig& c);

protected:
	ccBezierConfig m_sConfig;
	CCPoint m_startPosition;
};

/** @brief An action that moves the target with a cubic Bezier curve to a destination point.
 @since v0.8.2
 */
class CC_DLL CCBezierTo : public CCBezierBy
{
public:
    virtual void startWithTarget(CCNode *pTarget);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action with a duration and a bezier configuration */
    static CCBezierTo* actionWithDuration(ccTime t, const ccBezierConfig& c);
};

/** @brief Scales a CCNode object to a zoom factor by modifying it's scale attribute.
 @warning This action doesn't support "reverse"
 */
class CC_DLL CCScaleTo : public CCActionInterval
{
public:
	/** initializes the action with the same scale factor for X and Y */
	bool initWithDuration(ccTime duration, float s);

	/** initializes the action with and X factor and a Y factor */
	bool initWithDuration(ccTime duration, float sx, float sy);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	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;
	float m_fDeltaX;
	float m_fDeltaY;
};

/** @brief Scales a CCNode object a zoom factor by modifying it's scale attribute.
*/
class CC_DLL CCScaleBy : public CCScaleTo
{
public:
    virtual void startWithTarget(CCNode *pTarget);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* 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);
};

/** @brief Blinks a CCNode object by modifying it's visible attribute
*/
class CC_DLL CCBlink : public CCActionInterval
{
public:
	/** initializes the action */
	bool initWithDuration(ccTime duration, unsigned int uBlinks);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

public:
	/** creates the action */
	static CCBlink* actionWithDuration(ccTime duration, unsigned int uBlinks);
protected:
	unsigned int m_nTimes;
};

/** @brief Fades In an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 0 to 255.
 The "reverse" of this action is FadeOut
 */
class CC_DLL CCFadeIn : public CCActionInterval
{
public:
    virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCFadeIn* actionWithDuration(ccTime d);
};

/** @brief Fades Out an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 255 to 0.
 The "reverse" of this action is FadeIn
*/
class CC_DLL CCFadeOut : public CCActionInterval
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCFadeOut* actionWithDuration(ccTime d);
};

/** @brief Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
 @warning This action doesn't support "reverse"
 */
class CC_DLL CCFadeTo : public CCActionInterval
{
public:
	/** initializes the action with duration and opacity */
	bool initWithDuration(ccTime duration, GLubyte opacity);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);

public:
	/** creates an action with duration and opacity */
	static CCFadeTo* actionWithDuration(ccTime duration, GLubyte opacity);

protected:
	GLubyte m_toOpacity;
	GLubyte m_fromOpacity;
};

/** @brief Tints a CCNode that implements the CCNodeRGB protocol from current tint to a custom one.
 @warning This action doesn't support "reverse"
 @since v0.7.2
*/
class CC_DLL CCTintTo : public CCActionInterval
{
public:
	/** initializes the action with duration and color */
	bool initWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	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;
};

/** @brief Tints a CCNode that implements the CCNodeRGB protocol from current tint to a custom one.
 @since v0.7.2
 */
class CC_DLL CCTintBy : public CCActionInterval
{
public:
	/** initializes the action with duration and color */
	bool initWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

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;
};

/** @brief Delays the action a certain amount of seconds
*/
class CC_DLL CCDelayTime : public CCActionInterval
{
public:
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);
	virtual CCObject* copyWithZone(CCZone* pZone);

public:
	/** creates the action */
	static CCDelayTime* actionWithDuration(ccTime d);
};

/** @brief Executes an action in reverse order, from time=duration to time=0

 @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.
*/
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);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

public:
	/** creates the action */
	static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction);

protected:
	CCFiniteTimeAction *m_pOther;
};

class CCTexture2D;
/** @brief Animates a sprite given the name of an Animation */
class CC_DLL CCAnimate : public CCActionInterval
{
public:
	~CCAnimate(void);

	/** Get animation used for the animate */
	inline CCAnimation* getAnimation(void) { return m_pAnimation; }
	/** Set animation used for the animate, the object is retained */
	inline void setAnimation(CCAnimation *pAnimation)
	{
		CC_SAFE_RETAIN(pAnimation);
		CC_SAFE_RELEASE(m_pAnimation);
		m_pAnimation = pAnimation;
	}

	/** initializes the action with an Animation and will restore the original frame when the animation is over */
    bool initWithAnimation(CCAnimation *pAnimation);

	/** initializes the action with an Animation */
	bool initWithAnimation(CCAnimation *pAnimation, bool bRestoreOriginalFrame);

	/** initializes an action with a duration, animation and depending of the restoreOriginalFrame, it will restore the original frame or not.
	 The 'delay' parameter of the animation will be overridden by the duration parameter.
	 @since v0.99.0
	 */
	bool initWithDuration(ccTime duration, CCAnimation *pAnimation, bool bRestoreOriginalFrame);

	virtual CCObject* copyWithZone(CCZone* pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void stop(void);
	virtual void update(ccTime time);
	virtual CCActionInterval* reverse(void);

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.
	 The 'delay' parameter of the animation will be overridden by the duration parameter.
	 @since v0.99.0
	 */
     static CCAnimate* actionWithDuration(ccTime duration, CCAnimation *pAnimation, bool bRestoreOriginalFrame);
protected:
	CCAnimation *m_pAnimation;
	CCSpriteFrame *m_pOrigFrame;
    bool m_bRestoreOriginalFrame;
};

}

#endif //__ACTION_CCINTERVAL_ACTION_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2009      Valentin Milea
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_CCACTION_MANAGER_H__
#define __ACTION_CCACTION_MANAGER_H__

#include "CCAction.h"
#include "CCMutableArray.h"
#include "CCObject.h"

namespace cocos2d {

struct _hashElement;
/**
 @brief CCActionManager is a singleton that manages all the actions.
 Normally you won't need to use this singleton directly. 99% of the cases you will use the CCNode interface,
 which uses this singleton.
 But there are some cases where you might need to use this singleton.
 Examples:
	- When you want to run an action where the target is different from a CCNode.
	- When you want to pause / resume the actions

 @since v0.8
 */
class CC_DLL CCActionManager : public CCObject
{
public:
	CCActionManager(void);
	~CCActionManager(void);
	bool init(void);

    // actions

	/** Adds an action with a target.
	 If the target is already present, then the action will be added to the existing target.
	 If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target.
	 When the target is paused, the queued actions won't be 'ticked'.
	 */
	void addAction(CCAction *pAction, CCNode *pTarget, bool paused);

    /** Removes all actions from all the targets.
    */
	void removeAllActions(void);

    /** Removes all actions from a certain target.
	 All the actions that belongs to the target will be removed.
	 */
	void removeAllActionsFromTarget(CCObject *pTarget);

    /** Removes an action given an action reference.
    */
	void removeAction(CCAction *pAction);

    /** Removes an action given its tag and the target */
	void removeActionByTag(unsigned int tag, CCObject *pTarget);

	/** Gets an action given its tag an a target
	 @return the Action the with the given tag
	 */
	CCAction* getActionByTag(unsigned int tag, CCObject *pTarget);

    /** Returns the numbers of actions that are running in a certain target.
	 * Composable actions are counted as 1 action. Example:
	 * - If you are running 1 Sequence of 7 actions, it will return 1.
	 * - If you are running 7 Sequences of 2 actions, it will return 7.
	 */
	unsigned int numberOfRunningActionsInTarget(CCObject *pTarget);

    /** Pauses the target: all running actions and newly added actions will be paused.
	*/
	void pauseTarget(CCObject *pTarget);

    /** Resumes the target. All queued actions will be resumed.
	*/
	void resumeTarget(CCObject *pTarget);

	/** purges the shared action manager. It releases the retained instance.
	 * because it uses this, so it can not be static
	 @since v0.99.0
	 */
	void purgeSharedManager(void);

public:
	/** returns a shared instance of the CCActionManager */
	static CCActionManager* sharedManager(void);

protected:
	// declared in CCActionManager.m

	void removeActionAtIndex(unsigned int uIndex, struct _hashElement *pElement);
    void deleteHashElement(struct _hashElement *pElement);
	void actionAllocWithHashElement(struct _hashElement *pElement);
	void update(ccTime dt);

protected:
	struct _hashElement	*m_pTargets;
	struct _hashElement	*m_pCurrentTarget;
	bool			m_bCurrentTargetSalvaged;
};

}

#endif // __ACTION_CCACTION_MANAGER_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2009      Sindesso Pty Ltd http://www.sindesso.com/

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_CCPAGETURN3D_ACTION_H__
#define __ACTION_CCPAGETURN3D_ACTION_H__

#include "CCActionGrid3D.h"

namespace cocos2d
{
	/**
	 @brief This action simulates a page turn from the bottom right hand corner of the screen.
	 It's not much use by itself but is used by the PageTurnTransition.

	 Based on an original paper by L Hong et al.
	 http://www.parc.com/publication/1638/turning-pages-of-3d-electronic-books.html

	 @since v0.8.2
	 */
	class CC_DLL CCPageTurn3D : public CCGrid3DAction
	{
	public:
		virtual void update(ccTime time);

	public:
		/** create the action */
		static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, ccTime time);
	};
}

#endif // __ACTION_CCPAGETURN3D_ACTION_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (C) 2010      Lam Pham

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_CCPROGRESS_TIMER_H__
#define __ACTION_CCPROGRESS_TIMER_H__

#include "CCActionInterval.h"

namespace cocos2d
{

/**
@brief Progress to percentage
@since v0.99.1
*/
class CC_DLL CCProgressTo : public CCActionInterval
{
public:
	/** Initializes with a duration and a percent */
	bool initWithDuration(ccTime duration, float fPercent);

	virtual CCObject* copyWithZone(CCZone *pZone);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);

public:
	/** Creates and initializes with a duration and a percent */
	static CCProgressTo* actionWithDuration(ccTime duration, float fPercent);

protected:
	float m_fTo;
	float m_fFrom;
};

/**
@brief Progress from a percentage to another percentage
@since v0.99.1
*/
class CC_DLL CCProgressFromTo : public CCActionInterval
{
public:
	/** Initializes the action with a duration, a "from" percentage and a "to" percentage */
    bool initWithDuration(ccTime duration, float fFromPercentage, float fToPercentage);

	virtual CCObject* copyWithZone(CCZone *pZone);
	virtual CCActionInterval* reverse(void);
	virtual void startWithTarget(CCNode *pTarget);
	virtual void update(ccTime time);

public:
	/** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */
	static CCProgressFromTo* actionWithDuration(ccTime duration, float fFromPercentage, float fToPercentage);

protected:
	float m_fTo;
	float m_fFrom;
};

} // end of namespace cocos2d

#endif // __ACTION_CCPROGRESS_TIMER_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
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_CCTILEDGRID_ACTION_H__
#define __ACTION_CCTILEDGRID_ACTION_H__

#include "CCActionGrid.h"

namespace cocos2d
{
	/** @brief CCShakyTiles3D action */
	class CC_DLL CCShakyTiles3D : public CCTiledGrid3DAction
	{
	public:
		/** initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration */
		bool initWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize,
			ccTime duration);

		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration */
		static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize,
			ccTime duration);

	protected:
		int m_nRandrange;
		bool m_bShakeZ;
	};

	/** @brief CCShatteredTiles3D action */
	class CC_DLL CCShatteredTiles3D : public CCTiledGrid3DAction
	{
	public:
		/** initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration */
        bool initWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize,
			ccTime duration);

		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */
		static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize,
			ccTime duration);

	protected:
		int m_nRandrange;
		bool m_bOnce;
		bool m_bShatterZ;
	};

	struct Tile;
	/** @brief CCShuffleTiles action
	 Shuffle the tiles in random order
	 */
	class CC_DLL CCShuffleTiles : public CCTiledGrid3DAction
	{
	public:
		~CCShuffleTiles(void);
		/** initializes the action with a random seed, the grid size and the duration */
		bool initWithSeed(int s, const ccGridSize& gridSize, ccTime duration);
		void shuffle(int *pArray, unsigned int nLen);
		ccGridSize getDelta(const ccGridSize& pos);
		void placeTile(const ccGridSize& pos, Tile *t);

		virtual void startWithTarget(CCNode *pTarget);
		virtual void update(ccTime time);
		virtual CCObject* copyWithZone(CCZone* pZone);

	public:
		/** creates the action with a random seed, the grid size and the duration */
		static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration);

	protected:
		int			 m_nSeed;
		unsigned int m_nTilesCount;
		int			 *m_pTilesOrder;
		Tile		 *m_pTiles;
	};

	/** @brief CCFadeOutTRTiles action
	 Fades out the tiles in a Top-Right direction
	 */
	class CC_DLL CCFadeOutTRTiles : public CCTiledGrid3DAction
	{
	public:
		virtual float testFunc(const ccGridSize& pos, ccTime time);
		void turnOnTile(const ccGridSize& pos);
		void turnOffTile(const ccGridSize& pos);
		virtual void transformTile(const ccGridSize& pos, float distance);
		virtual void update(ccTime time);

	public:
		/** creates the action with the grid size and the duration */
		static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, ccTime time);
	};

	/** @brief CCFadeOutBLTiles action.
	 Fades out the tiles in a Bottom-Left direction
	 */
	class CC_DLL CCFadeOutBLTiles : public CCFadeOutTRTiles
	{
	public:
		virtual float testFunc(const ccGridSize& pos, ccTime time);

	public:
		/** creates the action with the grid size and the duration */
        static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, ccTime time);
	};

	/** @brief CCFadeOutUpTiles action.
	 Fades out the tiles in upwards direction
	 */
	class CC_DLL CCFadeOutUpTiles : public CCFadeOutTRTiles
	{
	public:
		virtual float testFunc(const ccGridSize& pos, ccTime time);
		virtual void transformTile(const ccGridSize& pos, float distance);

	public:
		/** creates the action with the grid size and the duration */
        static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, ccTime time);
	};

	/** @brief CCFadeOutDownTiles action.
	 Fades out the tiles in downwards direction
	 */
	class CC_DLL CCFadeOutDownTiles : public CCFadeOutUpTiles
	{
	public:
		virtual float testFunc(const ccGridSize& pos, ccTime time);

	public:
		/** creates the action with the grid size and the duration */
        static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, ccTime time);
	};

	/** @brief CCTurnOffTiles action.
	 Turn off the files in random order
	 */
	class CC_DLL CCTurnOffTiles : public CCTiledGrid3DAction
	{
	public:
		~CCTurnOffTiles(void);
		/** initializes the action with a random seed, the grid size and the duration */
		bool initWithSeed(int s, const ccGridSize& gridSize, ccTime duration);
		void shuffle(int *pArray, unsigned int nLen);
		void turnOnTile(const ccGridSize& pos);
		void turnOffTile(const ccGridSize& pos);

		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void startWithTarget(CCNode *pTarget);
		virtual void update(ccTime time);

	public:
		/** creates the action with the grid size and the duration */
		static CCTurnOffTiles* actionWithSize(const ccGridSize& size, ccTime d);
		/** creates the action with a random seed, the grid size and the duration */
		static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration);

	protected:
		int				m_nSeed;
		unsigned int	m_nTilesCount;
		int				*m_pTilesOrder;
	};

	/** @brief CCWavesTiles3D action. */
	class CC_DLL CCWavesTiles3D : public CCTiledGrid3DAction
	{
	public:
		/** waves amplitude */
		inline float getAmplitude(void) { return m_fAmplitude; }
		inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }

		/** waves amplitude rate */
		inline float getAmplitudeRate(void) { return m_fAmplitudeRate; }
		inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; }

		/** initializes the action with a number of waves, the waves amplitude, the grid size and the duration */
		bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration);

		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with a number of waves, the waves amplitude, the grid size and the duration */
		static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration);

	protected:
		int m_nWaves;
		float m_fAmplitude;
		float m_fAmplitudeRate;
	};

	/** @brief CCJumpTiles3D action.
	 A sin function is executed to move the tiles across the Z axis
	 */
	class CC_DLL CCJumpTiles3D : public CCTiledGrid3DAction
	{
	public:
		/** amplitude of the sin*/
		inline float getAmplitude(void) { return m_fAmplitude; }
		inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }

		/** amplitude rate */
		inline float getAmplitudeRate(void) { return m_fAmplitudeRate; }
		inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; }

		/** initializes the action with the number of jumps, the sin amplitude, the grid size and the duration */
		bool initWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration);
		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);

	public:
		/** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */
        static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration);

	protected:
		int m_nJumps;
		float m_fAmplitude;
		float m_fAmplitudeRate;
	};

	/** @brief CCSplitRows action */
	class CC_DLL CCSplitRows : public CCTiledGrid3DAction
	{
	public :
		/** initializes the action with the number of rows to split and the duration */
		bool initWithRows(int nRows, ccTime duration);

		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);
		virtual void startWithTarget(CCNode *pTarget);

	public:
		/** creates the action with the number of rows to split and the duration */
		static CCSplitRows* actionWithRows(int nRows, ccTime duration);

	protected:
		int m_nRows;
		CCSize m_winSize;
	};

	/** @brief CCSplitCols action */
	class CC_DLL CCSplitCols : public CCTiledGrid3DAction
	{
	public:
		/** initializes the action with the number of columns to split and the duration */
		bool initWithCols(int nCols, ccTime duration);

		virtual CCObject* copyWithZone(CCZone* pZone);
		virtual void update(ccTime time);
		virtual void startWithTarget(CCNode *pTarget);

	public:
		/** creates the action with the number of columns to split and the duration */
		static CCSplitCols* actionWithCols(int nCols, ccTime duration);

	protected:
		int m_nCols;
		CCSize m_winSize;
	};
} // end of namespace cocos2d

#endif // __ACTION_CCTILEDGRID_ACTION_H__


code:
/****************************************************************************
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 __COCOA_CGAFFINETRANSFORM_H__
#define __COCOA_CGAFFINETRANSFORM_H__

#include "CCGeometry.h"
#include "CCPlatformMacros.h"

namespace   cocos2d {

struct CCAffineTransform {
  CGFloat a, b, c, d;
  CGFloat tx, ty;
};

CC_DLL CCAffineTransform __CCAffineTransformMake(CGFloat a, CGFloat b, CGFloat c, CGFloat d, CGFloat tx, CGFloat ty);
#define CCAffineTransformMake __CCAffineTransformMake

CC_DLL CCPoint __CCPointApplyAffineTransform(const CCPoint& point, const CCAffineTransform& t);
#define CCPointApplyAffineTransform __CCPointApplyAffineTransform

CC_DLL CCSize __CCSizeApplyAffineTransform(const CCSize& size, const CCAffineTransform& t);
#define CCSizeApplyAffineTransform __CCSizeApplyAffineTransform

CC_DLL CCAffineTransform CCAffineTransformMakeIdentity();
CC_DLL CCRect CCRectApplyAffineTransform(const CCRect& rect, const CCAffineTransform& anAffineTransform);

CC_DLL CCAffineTransform CCAffineTransformTranslate(const CCAffineTransform& t, float tx, float ty);
CC_DLL CCAffineTransform CCAffineTransformRotate(const CCAffineTransform& aTransform, CGFloat anAngle);
CC_DLL CCAffineTransform CCAffineTransformScale(const CCAffineTransform& t, CGFloat sx, CGFloat sy);
CC_DLL CCAffineTransform CCAffineTransformConcat(const CCAffineTransform& t1, const CCAffineTransform& t2);
CC_DLL bool CCAffineTransformEqualToTransform(const CCAffineTransform& t1, const CCAffineTransform& t2);
CC_DLL CCAffineTransform CCAffineTransformInvert(const CCAffineTransform& t);

extern const CCAffineTransform CCAffineTransformIdentity;
}//namespace   cocos2d

#endif // __COCOA_CGAFFINETRANSFORM_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
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 __CC_ANIMATION_H__
#define __CC_ANIMATION_H__

#include "CCPlatformConfig.h"
#include "CCObject.h"
#include "CCMutableArray.h"
#include "CCGeometry.h"
#include <string>

namespace   cocos2d {
	class CCSpriteFrame;
    class CCTexture2D;
	/** A CCAnimation object is used to perform animations on the CCSprite objects.

	The CCAnimation object contains CCSpriteFrame objects, and a possible delay between the frames.
	You can animate a CCAnimation object by using the CCAnimate action. Example:

	[sprite runAction:[CCAnimate actionWithAnimation:animation]];

	*/
	class CC_DLL CCAnimation : public CCObject
	{
	protected:
		std::string m_nameStr;
		float m_fDelay;
		CCMutableArray<CCSpriteFrame*> *m_pobFrames;

	public:
		// attributes

		/** get name of the animation */
		inline const char* getName(void) { return m_nameStr.c_str(); }
		/** set name of the animation */
		inline void setName(const char *pszName){ m_nameStr = pszName; }

		/** get delay between frames in seconds */
		inline float getDelay(void) { return m_fDelay; }
		/** set delay between frames in seconds */
		inline void setDelay(float fDelay) { m_fDelay = fDelay; }

		/** get array of frames */
		inline CCMutableArray<CCSpriteFrame*>* getFrames(void) { return m_pobFrames; }
		/** set array of frames, the Frames is retained */
		inline void setFrames(CCMutableArray<CCSpriteFrame*> *pFrames)
		{
			CC_SAFE_RETAIN(pFrames);
			CC_SAFE_RELEASE(m_pobFrames);
			m_pobFrames = pFrames;
		}

	public:
		~CCAnimation(void);

		/** Initializes a CCAnimation with frames.
		@since v0.99.5
		*/
		bool initWithFrames(CCMutableArray<CCSpriteFrame*> *pFrames);

		/** Initializes a CCAnimation with frames and a delay between frames
		@since v0.99.5
		*/
		bool initWithFrames(CCMutableArray<CCSpriteFrame*> *pFrames, float delay);

		/** adds a frame to a CCAnimation */
		void addFrame(CCSpriteFrame *pFrame);

		/** Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it.
		Added to facilitate the migration from v0.8 to v0.9.
		*/
		void addFrameWithFileName(const char *pszFileName);

		/** Adds a frame with a texture and a rect. Internally it will create a CCSpriteFrame and it will add it.
		Added to facilitate the migration from v0.8 to v0.9.
		*/
		void addFrameWithTexture(CCTexture2D* pobTexture, const CCRect& rect);

		bool init(void);

	public:
		/** Creates an animation
		@since v0.99.5
		*/
        static CCAnimation* animation(void);

		/** Creates an animation with frames.
		@since v0.99.5
		*/
		static CCAnimation* animationWithFrames(CCMutableArray<CCSpriteFrame*> *frames);

		/* Creates an animation with frames and a delay between frames.
		@since v0.99.5
		*/
		static CCAnimation* animationWithFrames(CCMutableArray<CCSpriteFrame*> *frames, float delay);
	};
} // end of name sapce cocos2d

#endif // __CC_ANIMATION_H__


code:
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 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 __CC_ANIMATION_CACHE_H__
#define __CC_ANIMATION_CACHE_H__

#include "CCObject.h"
#include "CCMutableDictionary.h"

#include <string>

namespace cocos2d
{
	class CCAnimation;

	/** Singleton that manages the Animations.
	It saves in a cache the animations. You should use this class if you want to save your animations in a cache.

	Before v0.99.5, the recommend way was to save them on the CCSprite. Since v0.99.5, you should use this class instead.

	@since v0.99.5
	*/
	class CC_DLL CCAnimationCache : public CCObject
	{
	public:
		~CCAnimationCache();
		CCAnimationCache();

		/** Retruns ths shared instance of the Animation cache */
		static CCAnimationCache* sharedAnimationCache(void);

		/** Purges the cache. It releases all the CCAnimation objects and the shared instance.
		*/
		static void purgeSharedAnimationCache(void);

		/** Adds a CCAnimation with a name.
		*/
		void addAnimation(CCAnimation *animation, const char * name);

		/** Deletes a CCAnimation from the cache.
		*/
		void removeAnimationByName(const char* name);

		/** Returns a CCAnimation that was previously added.
		If the name is not found it will return nil.
		You should retain the returned copy if you are going to use it.
		*/
		CCAnimation* animationByName(const char* name);

		bool init(void);

	private:
		CCMutableDictionary<std::string, CCAnimation*> *m_pAnimations;
		static CCAnimationCache *s_pSharedAnimationCache;
	};
}

#endif // __CC_ANIMATION_CACHE_H__