Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into ScriptHandler

This commit is contained in:
samuele3hu 2013-07-16 14:47:46 +08:00
commit 241c01bec3
39 changed files with 1093 additions and 1002 deletions

View File

@ -129,6 +129,7 @@ Developers:
tks2shimizu tks2shimizu
add CCFloat, CCDouble and CCBool add CCFloat, CCDouble and CCBool
Add append function for String class Add append function for String class
Adding String::componentsSeparatedByString function for splitting string.
chenium chenium
fix a bug that CCRenderTexture can not work when coming to foreground on Android fix a bug that CCRenderTexture can not work when coming to foreground on Android
@ -522,6 +523,12 @@ Developers:
jllust jllust
Fixing a bug that CCLabelBMFont crashes in glDrawElements of CCTextureAtlas::drawNumberOfQuads sometimes. Fixing a bug that CCLabelBMFont crashes in glDrawElements of CCTextureAtlas::drawNumberOfQuads sometimes.
Sam Gross (colesbury)
Ignoring formatting specifiers in JavaScript log messages.
James Munro (jdmunro)
Added JSB support for ccpDistanceSQ.
Retired Core Developers: Retired Core Developers:
WenSheng Yang WenSheng Yang

View File

@ -63,22 +63,10 @@ using the camera.
*/ */
class CC_DLL Camera : public Object class CC_DLL Camera : public Object
{ {
protected:
float _eyeX;
float _eyeY;
float _eyeZ;
float _centerX;
float _centerY;
float _centerZ;
float _upX;
float _upY;
float _upZ;
bool _dirty;
kmMat4 _lookupMatrix;
public: public:
/** returns the Z eye */
static float getZEye();
Camera(void); Camera(void);
~Camera(void); ~Camera(void);
@ -108,10 +96,22 @@ public:
void getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ) const; void getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ) const;
/** get the up vector values */ /** get the up vector values */
void getUpXYZ(float *pUpX, float *pUpY, float *pUpZ) const; void getUpXYZ(float *pUpX, float *pUpY, float *pUpZ) const;
public:
/** returns the Z eye */ protected:
static float getZEye(); float _eyeX;
float _eyeY;
float _eyeZ;
float _centerX;
float _centerY;
float _centerZ;
float _upX;
float _upY;
float _upZ;
bool _dirty;
kmMat4 _lookupMatrix;
private: private:
DISALLOW_COPY_AND_ASSIGN(Camera); DISALLOW_COPY_AND_ASSIGN(Camera);

View File

@ -98,6 +98,12 @@ and when to execute the Scenes.
class CC_DLL Director : public Object, public TypeInfo class CC_DLL Director : public Object, public TypeInfo
{ {
public: public:
/** returns a shared instance of the director */
static Director* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector(void);
Director(void); Director(void);
virtual ~Director(void); virtual ~Director(void);
virtual bool init(void); virtual bool init(void);
@ -344,16 +350,8 @@ public:
/* delta time since last tick to main loop */ /* delta time since last tick to main loop */
CC_PROPERTY_READONLY(float, _deltaTime, DeltaTime); CC_PROPERTY_READONLY(float, _deltaTime, DeltaTime);
public:
/** returns a shared instance of the director */
static Director* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector(void);
protected: protected:
void purgeDirector(); void purgeDirector();
bool _purgeDirecotorInNextLoop; // this flag will be set to true in end() bool _purgeDirecotorInNextLoop; // this flag will be set to true in end()
@ -366,6 +364,7 @@ protected:
/** calculates delta time since last time it was called */ /** calculates delta time since last time it was called */
void calculateDeltaTime(); void calculateDeltaTime();
protected: protected:
/* The EGLView, where everything is rendered */ /* The EGLView, where everything is rendered */
EGLView *_openGLView; EGLView *_openGLView;
@ -449,10 +448,13 @@ public:
: _invalid(false) : _invalid(false)
{} {}
virtual void mainLoop(void); //
virtual void setAnimationInterval(double dValue); // Overrides
virtual void startAnimation(void); //
virtual void stopAnimation(); virtual void mainLoop(void) override;
virtual void setAnimationInterval(double dValue) override;
virtual void startAnimation(void) override;
virtual void stopAnimation() override;
protected: protected:
bool _invalid; bool _invalid;

View File

@ -189,6 +189,11 @@ Follow* Follow::clone() const
return a; return a;
} }
Follow* Follow::reverse() const
{
return clone();
}
bool Follow::initWithTarget(Node *pFollowedNode, const Rect& rect/* = Rect::ZERO*/) bool Follow::initWithTarget(Node *pFollowedNode, const Rect& rect/* = Rect::ZERO*/)
{ {
CCAssert(pFollowedNode != NULL, ""); CCAssert(pFollowedNode != NULL, "");

View File

@ -58,6 +58,9 @@ public:
/** returns a clone of action */ /** returns a clone of action */
virtual Action* clone() const = 0; virtual Action* clone() const = 0;
/** returns a new action that performs the exactly the reverse action */
virtual Action* reverse() const = 0;
//! return true if the action has finished //! return true if the action has finished
virtual bool isDone(void) const; virtual bool isDone(void) const;
@ -98,8 +101,6 @@ public:
inline int getTag(void) const { return _tag; } inline int getTag(void) const { return _tag; }
inline void setTag(int nTag) { _tag = nTag; } inline void setTag(int nTag) { _tag = nTag; }
public:
protected: protected:
Node *_originalTarget; Node *_originalTarget;
/** The "target". /** The "target".
@ -133,11 +134,11 @@ public:
//! set duration in seconds of the action //! set duration in seconds of the action
inline void setDuration(float duration) { _duration = duration; } inline void setDuration(float duration) { _duration = duration; }
/** returns a new reversed action */ //
virtual FiniteTimeAction* reverse() const = 0; // Overrides
//
/** returns a clone of action */ virtual FiniteTimeAction* reverse() const override = 0;
virtual FiniteTimeAction* clone() const = 0; virtual FiniteTimeAction* clone() const override = 0;
protected: protected:
//! duration in seconds //! duration in seconds
@ -156,6 +157,10 @@ class RepeatForever;
class CC_DLL Speed : public Action class CC_DLL Speed : public Action
{ {
public: public:
/** create the action */
static Speed* create(ActionInterval* pAction, float fSpeed);
Speed(); Speed();
virtual ~Speed(void); virtual ~Speed(void);
@ -166,16 +171,6 @@ public:
/** initializes the action */ /** initializes the action */
bool initWithAction(ActionInterval *pAction, float fSpeed); bool initWithAction(ActionInterval *pAction, float fSpeed);
/** returns a new clone of the action */
virtual Speed* clone() const;
/** returns a new reversed action */
virtual Speed* reverse(void) const;
virtual void startWithTarget(Node* pTarget);
virtual void stop();
virtual void step(float dt);
virtual bool isDone(void) const;
void setInnerAction(ActionInterval *pAction); void setInnerAction(ActionInterval *pAction);
inline ActionInterval* getInnerAction() inline ActionInterval* getInnerAction()
@ -183,9 +178,16 @@ public:
return _innerAction; return _innerAction;
} }
public: //
/** create the action */ // Override
static Speed* create(ActionInterval* pAction, float fSpeed); //
virtual Speed* clone() const override;
virtual Speed* reverse() const override;
virtual void startWithTarget(Node* pTarget) override;
virtual void stop() override;
virtual void step(float dt) override;
virtual bool isDone(void) const override;
protected: protected:
float _speed; float _speed;
ActionInterval *_innerAction; ActionInterval *_innerAction;
@ -203,6 +205,11 @@ Instead of using Camera as a "follower", use this action instead.
class CC_DLL Follow : public Action class CC_DLL Follow : public Action
{ {
public: public:
/** creates the action with a set boundary,
It will work with no boundary if @param rect is equal to Rect::ZERO.
*/
static Follow* create(Node *pFollowedNode, const Rect& rect = Rect::ZERO);
Follow() Follow()
: _followedNode(NULL) : _followedNode(NULL)
, _boundarySet(false) , _boundarySet(false)
@ -222,17 +229,15 @@ public:
/** initializes the action with a set boundary */ /** initializes the action with a set boundary */
bool initWithTarget(Node *pFollowedNode, const Rect& rect = Rect::ZERO); bool initWithTarget(Node *pFollowedNode, const Rect& rect = Rect::ZERO);
/** returns a clone of action */ //
virtual Follow* clone() const; // Override
virtual void step(float dt); //
virtual bool isDone(void) const; virtual Follow* clone() const override;
virtual void stop(void); virtual Follow* reverse() const override;
virtual void step(float dt) override;
virtual bool isDone(void) const override;
virtual void stop(void) override;
public:
/** creates the action with a set boundary,
It will work with no boundary if @param rect is equal to Rect::ZERO.
*/
static Follow* create(Node *pFollowedNode, const Rect& rect = Rect::ZERO);
protected: protected:
// node to follow // node to follow
Node *_followedNode; Node *_followedNode;

View File

@ -49,14 +49,17 @@ public:
/** initializes the action */ /** initializes the action */
bool initWithAction(ActionInterval *pAction); bool initWithAction(ActionInterval *pAction);
virtual ActionEase* clone() const = 0;
virtual ActionEase* reverse() const = 0;
virtual void startWithTarget(Node *pTarget);
virtual void stop(void);
virtual void update(float time);
virtual ActionInterval* getInnerAction(); virtual ActionInterval* getInnerAction();
//
// Overrides
//
virtual ActionEase* clone() const override = 0;
virtual ActionEase* reverse() const override = 0;
virtual void startWithTarget(Node *pTarget) override;
virtual void stop(void) override;
virtual void update(float time) override;
protected: protected:
/** The inner action */ /** The inner action */
ActionInterval *_inner; ActionInterval *_inner;
@ -71,16 +74,19 @@ class CC_DLL EaseRateAction : public ActionEase
public: public:
virtual ~EaseRateAction(void); virtual ~EaseRateAction(void);
/** Initializes the action with the inner action and the rate parameter */
bool initWithAction(ActionInterval *pAction, float fRate);
/** set rate value for the actions */ /** set rate value for the actions */
inline void setRate(float rate) { _rate = rate; } inline void setRate(float rate) { _rate = rate; }
/** get rate value for the actions */ /** get rate value for the actions */
inline float getRate(void) const { return _rate; } inline float getRate(void) const { return _rate; }
/** Initializes the action with the inner action and the rate parameter */ //
bool initWithAction(ActionInterval *pAction, float fRate); // Overrides
//
virtual EaseRateAction* clone() const = 0; virtual EaseRateAction* clone() const override = 0;
virtual EaseRateAction* reverse() const = 0; virtual EaseRateAction* reverse() const override = 0;
protected: protected:
float _rate; float _rate;
@ -93,17 +99,13 @@ protected:
class CC_DLL EaseIn : public EaseRateAction class CC_DLL EaseIn : public EaseRateAction
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseIn* clone() const;
/** returns a new reversed action */
virtual EaseIn* reverse() const;
public:
/** Creates the action with the inner action and the rate parameter */ /** Creates the action with the inner action and the rate parameter */
static EaseIn* create(ActionInterval* pAction, float fRate); static EaseIn* create(ActionInterval* pAction, float fRate);
// Overrides
virtual void update(float time) override;
virtual EaseIn* clone() const override;
virtual EaseIn* reverse() const override;
}; };
/** /**
@ -113,16 +115,13 @@ public:
class CC_DLL EaseOut : public EaseRateAction class CC_DLL EaseOut : public EaseRateAction
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseOut* clone() const;
/** returns a new reversed action */
virtual EaseOut* reverse() const;
public:
/** Creates the action with the inner action and the rate parameter */ /** Creates the action with the inner action and the rate parameter */
static EaseOut* create(ActionInterval* pAction, float fRate); static EaseOut* create(ActionInterval* pAction, float fRate);
// Overrides
virtual void update(float time) override;
virtual EaseOut* clone() const override;
virtual EaseOut* reverse() const override;
}; };
/** /**
@ -132,17 +131,13 @@ public:
class CC_DLL EaseInOut : public EaseRateAction class CC_DLL EaseInOut : public EaseRateAction
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseInOut* clone() const;
/** returns a new reversed action */
virtual EaseInOut* reverse() const;
public:
/** Creates the action with the inner action and the rate parameter */ /** Creates the action with the inner action and the rate parameter */
static EaseInOut* create(ActionInterval* pAction, float fRate); static EaseInOut* create(ActionInterval* pAction, float fRate);
// Overrides
virtual void update(float time) override;
virtual EaseInOut* clone() const override;
virtual EaseInOut* reverse() const override;
}; };
/** /**
@ -151,16 +146,14 @@ public:
*/ */
class CC_DLL EaseExponentialIn : public ActionEase class CC_DLL EaseExponentialIn : public ActionEase
{ {
public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseExponentialIn* clone() const;
/** returns a new reversed action */
virtual ActionEase* reverse() const;
public: public:
/** creates the action */ /** creates the action */
static EaseExponentialIn* create(ActionInterval* pAction); static EaseExponentialIn* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseExponentialIn* clone() const override;
virtual ActionEase* reverse() const override;
}; };
/** /**
@ -169,16 +162,14 @@ public:
*/ */
class CC_DLL EaseExponentialOut : public ActionEase class CC_DLL EaseExponentialOut : public ActionEase
{ {
public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseExponentialOut* clone() const;
/** returns a new reversed action */
virtual ActionEase* reverse() const;
public: public:
/** creates the action */ /** creates the action */
static EaseExponentialOut* create(ActionInterval* pAction); static EaseExponentialOut* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseExponentialOut* clone() const override;
virtual ActionEase* reverse() const override;
}; };
/** /**
@ -188,15 +179,13 @@ public:
class CC_DLL EaseExponentialInOut : public ActionEase class CC_DLL EaseExponentialInOut : public ActionEase
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseExponentialInOut* clone() const;
/** returns a new reversed action */
virtual EaseExponentialInOut* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseExponentialInOut* create(ActionInterval* pAction); static EaseExponentialInOut* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseExponentialInOut* clone() const override;
virtual EaseExponentialInOut* reverse() const override;
}; };
/** /**
@ -205,15 +194,14 @@ public:
*/ */
class CC_DLL EaseSineIn : public ActionEase class CC_DLL EaseSineIn : public ActionEase
{ {
public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseSineIn* clone() const;
/** returns a new reversed action */
virtual ActionEase* reverse() const;
public: public:
/** creates the action */ /** creates the action */
static EaseSineIn* create(ActionInterval* pAction); static EaseSineIn* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseSineIn* clone() const override;
virtual ActionEase* reverse() const override;
}; };
/** /**
@ -223,16 +211,13 @@ public:
class CC_DLL EaseSineOut : public ActionEase class CC_DLL EaseSineOut : public ActionEase
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseSineOut* clone() const;
/** returns a new reversed action */
virtual ActionEase* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseSineOut* create(ActionInterval* pAction); static EaseSineOut* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseSineOut* clone() const override;
virtual ActionEase* reverse() const override;
}; };
/** /**
@ -242,16 +227,13 @@ public:
class CC_DLL EaseSineInOut : public ActionEase class CC_DLL EaseSineInOut : public ActionEase
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseSineInOut* clone() const;
/** returns a new reversed action */
virtual EaseSineInOut* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseSineInOut* create(ActionInterval* pAction); static EaseSineInOut* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseSineInOut* clone() const override;
virtual EaseSineInOut* reverse() const override;
}; };
/** /**
@ -262,18 +244,19 @@ public:
class CC_DLL EaseElastic : public ActionEase class CC_DLL EaseElastic : public ActionEase
{ {
public: public:
/** Initializes the action with the inner action and the period in radians (default is 0.3) */
bool initWithAction(ActionInterval *pAction, float fPeriod = 0.3f);
/** get period of the wave in radians. default is 0.3 */ /** get period of the wave in radians. default is 0.3 */
inline float getPeriod(void) const { return _period; } inline float getPeriod(void) const { return _period; }
/** set period of the wave in radians. */ /** set period of the wave in radians. */
inline void setPeriod(float fPeriod) { _period = fPeriod; } inline void setPeriod(float fPeriod) { _period = fPeriod; }
/** Initializes the action with the inner action and the period in radians (default is 0.3) */ //
bool initWithAction(ActionInterval *pAction, float fPeriod = 0.3f); // Overrides
//
/** returns a new clone of the action */ virtual EaseElastic* clone() const override = 0;
virtual EaseElastic* clone() const = 0; virtual EaseElastic* reverse() const override = 0;
/** returns a new reversed action */
virtual EaseElastic* reverse() const = 0;
protected: protected:
float _period; float _period;
@ -288,17 +271,14 @@ protected:
class CC_DLL EaseElasticIn : public EaseElastic class CC_DLL EaseElasticIn : public EaseElastic
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseElasticIn* clone() const;
/** returns a new reversed action */
virtual EaseElastic* reverse() const;
public:
/** Creates the action with the inner action and the period in radians (default is 0.3) */ /** Creates the action with the inner action and the period in radians (default is 0.3) */
static EaseElasticIn* create(ActionInterval *pAction, float fPeriod); static EaseElasticIn* create(ActionInterval *pAction, float fPeriod);
static EaseElasticIn* create(ActionInterval *pAction); static EaseElasticIn* create(ActionInterval *pAction);
// Overrides
virtual void update(float time) override;
virtual EaseElasticIn* clone() const override;
virtual EaseElastic* reverse() const override;
}; };
/** /**
@ -310,17 +290,14 @@ public:
class CC_DLL EaseElasticOut : public EaseElastic class CC_DLL EaseElasticOut : public EaseElastic
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseElasticOut* clone() const;
/** returns a new reversed action */
virtual EaseElastic* reverse() const;
public:
/** Creates the action with the inner action and the period in radians (default is 0.3) */ /** Creates the action with the inner action and the period in radians (default is 0.3) */
static EaseElasticOut* create(ActionInterval *pAction, float fPeriod); static EaseElasticOut* create(ActionInterval *pAction, float fPeriod);
static EaseElasticOut* create(ActionInterval *pAction); static EaseElasticOut* create(ActionInterval *pAction);
// Overrides
virtual void update(float time) override;
virtual EaseElasticOut* clone() const override;
virtual EaseElastic* reverse() const override;
}; };
/** /**
@ -332,17 +309,14 @@ public:
class CC_DLL EaseElasticInOut : public EaseElastic class CC_DLL EaseElasticInOut : public EaseElastic
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseElasticInOut* clone() const;
/** returns a new reversed action */
virtual EaseElasticInOut* reverse() const;
public:
/** Creates the action with the inner action and the period in radians (default is 0.3) */ /** Creates the action with the inner action and the period in radians (default is 0.3) */
static EaseElasticInOut* create(ActionInterval *pAction, float fPeriod); static EaseElasticInOut* create(ActionInterval *pAction, float fPeriod);
static EaseElasticInOut* create(ActionInterval *pAction); static EaseElasticInOut* create(ActionInterval *pAction);
// Overrides
virtual void update(float time) override;
virtual EaseElasticInOut* clone() const override;
virtual EaseElasticInOut* reverse() const override;
}; };
/** /**
@ -354,11 +328,10 @@ class CC_DLL EaseBounce : public ActionEase
{ {
public: public:
float bounceTime(float time); float bounceTime(float time);
/** returns a new clone of the action */
virtual EaseBounce* clone() const = 0;
/** returns a new reversed action */
virtual EaseBounce* reverse() const = 0;
// Overrides
virtual EaseBounce* clone() const override = 0;
virtual EaseBounce* reverse() const override = 0;
}; };
/** /**
@ -370,16 +343,13 @@ public:
class CC_DLL EaseBounceIn : public EaseBounce class CC_DLL EaseBounceIn : public EaseBounce
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseBounceIn* clone() const;
/** returns a new reversed action */
virtual EaseBounce* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseBounceIn* create(ActionInterval* pAction); static EaseBounceIn* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseBounceIn* clone() const override;
virtual EaseBounce* reverse() const override;
}; };
/** /**
@ -391,15 +361,13 @@ public:
class CC_DLL EaseBounceOut : public EaseBounce class CC_DLL EaseBounceOut : public EaseBounce
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseBounceOut* clone() const;
/** returns a new reversed action */
virtual EaseBounce* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseBounceOut* create(ActionInterval* pAction); static EaseBounceOut* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseBounceOut* clone() const override;
virtual EaseBounce* reverse() const override;
}; };
/** /**
@ -411,15 +379,13 @@ public:
class CC_DLL EaseBounceInOut : public EaseBounce class CC_DLL EaseBounceInOut : public EaseBounce
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseBounceInOut* clone() const;
/** returns a new reversed action */
virtual EaseBounceInOut* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseBounceInOut* create(ActionInterval* pAction); static EaseBounceInOut* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseBounceInOut* clone() const override;
virtual EaseBounceInOut* reverse() const override;
}; };
/** /**
@ -431,15 +397,13 @@ public:
class CC_DLL EaseBackIn : public ActionEase class CC_DLL EaseBackIn : public ActionEase
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseBackIn* clone() const;
/** returns a new reversed action */
virtual ActionEase* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseBackIn* create(ActionInterval* pAction); static EaseBackIn* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseBackIn* clone() const override;
virtual ActionEase* reverse() const override;
}; };
/** /**
@ -451,15 +415,13 @@ public:
class CC_DLL EaseBackOut : public ActionEase class CC_DLL EaseBackOut : public ActionEase
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseBackOut* clone() const;
/** returns a new reversed action */
virtual ActionEase* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseBackOut* create(ActionInterval* pAction); static EaseBackOut* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseBackOut* clone() const override;
virtual ActionEase* reverse() const override;
}; };
/** /**
@ -471,15 +433,13 @@ public:
class CC_DLL EaseBackInOut : public ActionEase class CC_DLL EaseBackInOut : public ActionEase
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual EaseBackInOut* clone() const;
/** returns a new reversed action */
virtual EaseBackInOut* reverse() const;
public:
/** creates the action */ /** creates the action */
static EaseBackInOut* create(ActionInterval* pAction); static EaseBackInOut* create(ActionInterval* pAction);
// Overrides
virtual void update(float time) override;
virtual EaseBackInOut* clone() const override;
virtual EaseBackInOut* reverse() const override;
}; };
// end of actions group // end of actions group

View File

@ -48,17 +48,14 @@ the IntervalAction actions.
class CC_DLL ActionInstant : public FiniteTimeAction //<NSCopying> class CC_DLL ActionInstant : public FiniteTimeAction //<NSCopying>
{ {
public: public:
virtual ~ActionInstant(){} //
// Action methods // Overrides
//
/** returns a new clone of the action */ virtual ActionInstant* clone() const override = 0;
virtual ActionInstant* clone() const = 0; virtual ActionInstant * reverse(void) const override = 0;
/** returns a new reversed action */ virtual bool isDone(void) const override;
virtual ActionInstant * reverse(void) const = 0; virtual void step(float dt) override;
virtual void update(float time) override;
virtual bool isDone(void) const;
virtual void step(float dt);
virtual void update(float time);
}; };
/** @brief Show the node /** @brief Show the node
@ -66,42 +63,36 @@ public:
class CC_DLL Show : public ActionInstant class CC_DLL Show : public ActionInstant
{ {
public: public:
Show(){}
virtual ~Show(){}
//super methods
virtual void update(float time);
/** returns a new reversed action */
virtual ActionInstant * reverse(void) const;
/** returns a new clone of the action */
virtual Show* clone() const;
public:
/** Allocates and initializes the action */ /** Allocates and initializes the action */
static Show * create(); static Show * create();
Show(){}
//
// Overrides
//
virtual void update(float time) override;
virtual ActionInstant* reverse(void) const override;
virtual Show* clone() const override;
}; };
/** /**
@brief Hide the node @brief Hide the node
*/ */
class CC_DLL Hide : public ActionInstant class CC_DLL Hide : public ActionInstant
{ {
public: public:
Hide(){}
virtual ~Hide(){}
//super methods
virtual void update(float time);
/** returns a new reversed action */
virtual ActionInstant* reverse() const;
/** returns a new clone of the action */
virtual Hide* clone() const;
public:
/** Allocates and initializes the action */ /** Allocates and initializes the action */
static Hide * create(); static Hide * create();
Hide(){}
//
// Overrides
//
virtual void update(float time) override;
virtual ActionInstant* reverse() const override;
virtual Hide* clone() const override;
}; };
/** @brief Toggles the visibility of a node /** @brief Toggles the visibility of a node
@ -109,18 +100,17 @@ public:
class CC_DLL ToggleVisibility : public ActionInstant class CC_DLL ToggleVisibility : public ActionInstant
{ {
public: public:
ToggleVisibility(){}
virtual ~ToggleVisibility(){}
//super method
virtual void update(float time);
/** returns a new reversed action */
virtual ToggleVisibility* reverse() const;
/** returns a new clone of the action */
virtual ToggleVisibility* clone() const;
public:
/** Allocates and initializes the action */ /** Allocates and initializes the action */
static ToggleVisibility * create(); static ToggleVisibility * create();
ToggleVisibility(){}
//
// Overrides
//
virtual void update(float time) override;
virtual ToggleVisibility* reverse() const override;
virtual ToggleVisibility* clone() const override;
}; };
/** /**
@ -128,21 +118,23 @@ public:
*/ */
class CC_DLL RemoveSelf : public ActionInstant class CC_DLL RemoveSelf : public ActionInstant
{ {
public:
RemoveSelf():_isNeedCleanUp(true)
{}
virtual ~RemoveSelf(){}
//super methods
virtual void update(float time);
/** returns a new clone of the instance */
virtual RemoveSelf* clone() const;
/** returns a new reversed action */
virtual RemoveSelf* reverse() const;
public: public:
/** create the action */ /** create the action */
static RemoveSelf * create(bool isNeedCleanUp = true); static RemoveSelf * create(bool isNeedCleanUp = true);
RemoveSelf():_isNeedCleanUp(true)
{}
/** init the action */ /** init the action */
bool init(bool isNeedCleanUp); bool init(bool isNeedCleanUp);
//
// Override
//
virtual void update(float time) override;
virtual RemoveSelf* clone() const override;
virtual RemoveSelf* reverse() const override;
protected: protected:
bool _isNeedCleanUp; bool _isNeedCleanUp;
}; };
@ -154,22 +146,22 @@ protected:
class CC_DLL FlipX : public ActionInstant class CC_DLL FlipX : public ActionInstant
{ {
public: public:
FlipX()
:_flipX(false)
{}
virtual ~FlipX(){}
/** create the action */ /** create the action */
static FlipX * create(bool x); static FlipX * create(bool x);
FlipX()
:_flipX(false)
{}
/** init the action */ /** init the action */
bool initWithFlipX(bool x); bool initWithFlipX(bool x);
//super methods
virtual void update(float time); //
/** returns a new reversed action */ // Overrides
virtual FlipX* reverse() const; //
/** returns a new clone of the action */ virtual void update(float time) override;
virtual FlipX* clone() const; virtual FlipX* reverse() const override;
virtual FlipX* clone() const override;
protected: protected:
bool _flipX; bool _flipX;
@ -182,22 +174,22 @@ protected:
class CC_DLL FlipY : public ActionInstant class CC_DLL FlipY : public ActionInstant
{ {
public: public:
FlipY()
:_flipY(false)
{}
virtual ~FlipY(){}
/** create the action */ /** create the action */
static FlipY * create(bool y); static FlipY * create(bool y);
FlipY()
:_flipY(false)
{}
/** init the action */ /** init the action */
bool initWithFlipY(bool y); bool initWithFlipY(bool y);
//super methods
virtual void update(float time); //
/** returns a new reversed action */ // Overrides
virtual FlipY* reverse() const; //
/** returns a new clone of the action */ virtual void update(float time) override;
virtual FlipY* clone() const; virtual FlipY* reverse() const override;
virtual FlipY* clone() const override;
protected: protected:
bool _flipY; bool _flipY;
@ -209,18 +201,18 @@ class CC_DLL Place : public ActionInstant //<NSCopying>
{ {
public: public:
Place(){} Place(){}
virtual ~Place(){}
/** creates a Place action with a position */ /** creates a Place action with a position */
static Place * create(const Point& pos); static Place * create(const Point& pos);
/** Initializes a Place action with a position */ /** Initializes a Place action with a position */
bool initWithPosition(const Point& pos); bool initWithPosition(const Point& pos);
//super methods
virtual void update(float time); //
/** returns a new reversed action */ // Overrides
virtual Place* reverse() const; //
/** returns a new clone of the action */ virtual void update(float time) override;
virtual Place* clone() const; virtual Place* reverse() const override;
virtual Place* clone() const override;
protected: protected:
Point _position; Point _position;
@ -231,6 +223,22 @@ protected:
*/ */
class CC_DLL CallFunc : public ActionInstant //<NSCopying> class CC_DLL CallFunc : public ActionInstant //<NSCopying>
{ {
public:
/** creates the action with the callback of type std::function<void()>.
This is the preferred way to create the callback.
*/
static CallFunc * create(const std::function<void()>& func);
/** creates the action with the callback
typedef void (Object::*SEL_CallFunc)();
@deprecated Use the std::function API instead.
*/
CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Object* pSelectorTarget, SEL_CallFunc selector);
/** creates the action with the handler script function */
static CallFunc * create(int nHandler);
public: public:
CallFunc() CallFunc()
: _selectorTarget(NULL) : _selectorTarget(NULL)
@ -241,21 +249,6 @@ public:
} }
virtual ~CallFunc(); virtual ~CallFunc();
/** creates the action with the callback of type std::function<void()>.
This is the preferred way to create the callback.
*/
static CallFunc * create(const std::function<void()>& func);
/** creates the action with the callback
typedef void (Object::*SEL_CallFunc)();
@deprecated Use the std::function API instead.
*/
static CallFunc * create(Object* pSelectorTarget, SEL_CallFunc selector);
/** creates the action with the handler script function */
static CallFunc * create(int nHandler);
/** initializes the action with the callback /** initializes the action with the callback
typedef void (Object::*SEL_CallFunc)(); typedef void (Object::*SEL_CallFunc)();
@ -268,12 +261,6 @@ public:
/** executes the callback */ /** executes the callback */
virtual void execute(); virtual void execute();
//super methods
virtual void update(float time);
/** returns a new reversed action */
virtual CallFunc* reverse() const;
/** returns a new clone of the action */
virtual CallFunc* clone() const;
inline Object* getTargetCallback() inline Object* getTargetCallback()
{ {
@ -291,6 +278,14 @@ public:
} }
inline int getScriptHandler() const { return _scriptHandler; }; inline int getScriptHandler() const { return _scriptHandler; };
//
// Overrides
//
virtual void update(float time) override;
virtual CallFunc* reverse() const override;
virtual CallFunc* clone() const override;
protected: protected:
/** Target that will be called */ /** Target that will be called */
Object* _selectorTarget; Object* _selectorTarget;
@ -314,13 +309,6 @@ N means Node
class CC_DLL CallFuncN : public CallFunc, public TypeInfo class CC_DLL CallFuncN : public CallFunc, public TypeInfo
{ {
public: public:
CallFuncN():_functionN(nullptr){}
virtual ~CallFuncN(){}
virtual long getClassTypeInfo() {
static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name());
return id;
}
/** creates the action with the callback of type std::function<void()>. /** creates the action with the callback of type std::function<void()>.
This is the preferred way to create the callback. This is the preferred way to create the callback.
*/ */
@ -331,11 +319,13 @@ public:
typedef void (Object::*SEL_CallFuncN)(Node*); typedef void (Object::*SEL_CallFuncN)(Node*);
@deprecated Use the std::function API instead. @deprecated Use the std::function API instead.
*/ */
static CallFuncN * create(Object* pSelectorTarget, SEL_CallFuncN selector); CC_DEPRECATED_ATTRIBUTE static CallFuncN * create(Object* pSelectorTarget, SEL_CallFuncN selector);
/** creates the action with the handler script function */ /** creates the action with the handler script function */
static CallFuncN * create(int nHandler); static CallFuncN * create(int nHandler);
public:
CallFuncN():_functionN(nullptr){}
/** initializes the action with the std::function<void(Node*)> /** initializes the action with the std::function<void(Node*)>
*/ */
@ -346,10 +336,18 @@ public:
typedef void (Object::*SEL_CallFuncN)(Node*); typedef void (Object::*SEL_CallFuncN)(Node*);
@deprecated Use the std::function API instead. @deprecated Use the std::function API instead.
*/ */
virtual bool initWithTarget(Object* pSelectorTarget, SEL_CallFuncN selector); CC_DEPRECATED_ATTRIBUTE virtual bool initWithTarget(Object* pSelectorTarget, SEL_CallFuncN selector);
// super methods
virtual CallFuncN* clone() const; virtual long getClassTypeInfo() {
virtual void execute(); static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name());
return id;
}
//
// Overrides
//
virtual CallFuncN* clone() const override;
virtual void execute() override;
protected: protected:
/** function that will be called with the "sender" as the 1st argument */ /** function that will be called with the "sender" as the 1st argument */

View File

@ -67,22 +67,20 @@ public:
/** initializes the action */ /** initializes the action */
bool initWithDuration(float d); bool initWithDuration(float d);
/** returns true if the action has finished */ //extension in GridAction
virtual bool isDone(void) const;
virtual void step(float dt);
virtual void startWithTarget(Node *pTarget);
/** returns a reversed action */
virtual ActionInterval* reverse() const = 0;
virtual ActionInterval *clone() const = 0;
public:
//extension in GridAction
void setAmplitudeRate(float amp); void setAmplitudeRate(float amp);
float getAmplitudeRate(void); float getAmplitudeRate(void);
//
// Overrides
//
virtual bool isDone(void) const override;
virtual void step(float dt) override;
virtual void startWithTarget(Node *pTarget) override;
virtual ActionInterval* reverse() const override = 0;
virtual ActionInterval *clone() const override = 0;
protected: protected:
float _elapsed; float _elapsed;
bool _firstTick; bool _firstTick;
@ -93,23 +91,6 @@ protected:
class CC_DLL Sequence : public ActionInterval class CC_DLL Sequence : public ActionInterval
{ {
public: public:
~Sequence(void);
/** initializes the action */
bool initWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo);
/** returns a new clone of the action */
virtual Sequence* clone() const;
/** returns a new reversed action */
virtual Sequence* reverse() const;
virtual void startWithTarget(Node *pTarget);
virtual void stop(void);
virtual void update(float t);
public:
/** helper constructor to create an array of sequenceable actions */ /** helper constructor to create an array of sequenceable actions */
static Sequence* create(FiniteTimeAction *pAction1, ...); static Sequence* create(FiniteTimeAction *pAction1, ...);
/** helper constructor to create an array of sequenceable actions given an array */ /** helper constructor to create an array of sequenceable actions given an array */
@ -119,6 +100,20 @@ public:
/** creates the action */ /** creates the action */
static Sequence* createWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo); static Sequence* createWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo);
virtual ~Sequence(void);
/** initializes the action */
bool initWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo);
//
// Overrides
//
virtual Sequence* clone() const override;
virtual Sequence* reverse() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void stop(void) override;
virtual void update(float t) override;
protected: protected:
FiniteTimeAction *_actions[2]; FiniteTimeAction *_actions[2];
float _split; float _split;
@ -131,22 +126,14 @@ protected:
class CC_DLL Repeat : public ActionInterval class CC_DLL Repeat : public ActionInterval
{ {
public: public:
~Repeat(void); /** creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */
static Repeat* create(FiniteTimeAction *pAction, unsigned int times);
virtual ~Repeat(void);
/** initializes a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */ /** initializes a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */
bool initWithAction(FiniteTimeAction *pAction, unsigned int times); bool initWithAction(FiniteTimeAction *pAction, unsigned int times);
/** returns a new clone of the action */
virtual Repeat* clone() const;
/** returns a new reversed action */
virtual Repeat* reverse() const;
virtual void startWithTarget(Node *pTarget);
virtual void stop(void);
virtual void update(float dt);
virtual bool isDone(void) const;
inline void setInnerAction(FiniteTimeAction *pAction) inline void setInnerAction(FiniteTimeAction *pAction)
{ {
if (_innerAction != pAction) if (_innerAction != pAction)
@ -162,10 +149,16 @@ public:
return _innerAction; return _innerAction;
} }
public: //
// Overrides
//
virtual Repeat* clone() const override;
virtual Repeat* reverse() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void stop(void) override;
virtual void update(float dt) override;
virtual bool isDone(void) const override;
/** creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */
static Repeat* create(FiniteTimeAction *pAction, unsigned int times);
protected: protected:
unsigned int _times; unsigned int _times;
unsigned int _total; unsigned int _total;
@ -182,6 +175,9 @@ To repeat the an action for a limited number of times use the Repeat action.
class CC_DLL RepeatForever : public ActionInterval class CC_DLL RepeatForever : public ActionInterval
{ {
public: public:
/** creates the action */
static RepeatForever* create(ActionInterval *pAction);
RepeatForever() RepeatForever()
: _innerAction(NULL) : _innerAction(NULL)
{} {}
@ -190,16 +186,6 @@ public:
/** initializes the action */ /** initializes the action */
bool initWithAction(ActionInterval *pAction); bool initWithAction(ActionInterval *pAction);
/** returns a new clone of the action */
virtual RepeatForever* clone() const;
/** returns a new reversed action */
virtual RepeatForever* reverse(void) const;
virtual void startWithTarget(Node* pTarget);
virtual void step(float dt);
virtual bool isDone(void) const;
inline void setInnerAction(ActionInterval *pAction) inline void setInnerAction(ActionInterval *pAction)
{ {
if (_innerAction != pAction) if (_innerAction != pAction)
@ -215,10 +201,15 @@ public:
return _innerAction; return _innerAction;
} }
public: //
// Overrides
//
virtual RepeatForever* clone() const override;
virtual RepeatForever* reverse(void) const override;
virtual void startWithTarget(Node* pTarget) override;
virtual void step(float dt) override;
virtual bool isDone(void) const override;
/** creates the action */
static RepeatForever* create(ActionInterval *pAction);
protected: protected:
/** Inner action */ /** Inner action */
ActionInterval *_innerAction; ActionInterval *_innerAction;
@ -229,26 +220,9 @@ protected:
class CC_DLL Spawn : public ActionInterval class CC_DLL Spawn : public ActionInterval
{ {
public: public:
~Spawn(void);
/** initializes the Spawn action with the 2 actions to spawn */
bool initWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction *pAction2);
/** returns a new clone of the action */
virtual Spawn* clone() const;
/** returns a new reversed action */
virtual Spawn* reverse(void) const;
virtual void startWithTarget(Node *pTarget);
virtual void stop(void);
virtual void update(float time);
public:
/** helper constructor to create an array of spawned actions */ /** helper constructor to create an array of spawned actions */
static Spawn* create(FiniteTimeAction *pAction1, ...); static Spawn* create(FiniteTimeAction *pAction1, ...);
/** helper constructor to create an array of spawned actions */ /** helper constructor to create an array of spawned actions */
static Spawn* createWithVariableList(FiniteTimeAction *pAction1, va_list args); static Spawn* createWithVariableList(FiniteTimeAction *pAction1, va_list args);
@ -258,6 +232,20 @@ public:
/** creates the Spawn action */ /** creates the Spawn action */
static Spawn* createWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction *pAction2); static Spawn* createWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction *pAction2);
virtual ~Spawn(void);
/** initializes the Spawn action with the 2 actions to spawn */
bool initWithTwoActions(FiniteTimeAction *pAction1, FiniteTimeAction *pAction2);
//
// Overrides
//
virtual Spawn* clone() const override;
virtual Spawn* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void stop(void) override;
virtual void update(float time) override;
protected: protected:
FiniteTimeAction *_one; FiniteTimeAction *_one;
FiniteTimeAction *_two; FiniteTimeAction *_two;
@ -270,23 +258,23 @@ protected:
class CC_DLL RotateTo : public ActionInterval class CC_DLL RotateTo : public ActionInterval
{ {
public: public:
/** creates the action with separate rotation angles */
static RotateTo* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
/** creates the action */ /** creates the action */
static RotateTo* create(float fDuration, float fDeltaAngle); static RotateTo* create(float fDuration, float fDeltaAngle);
/** initializes the action */ /** initializes the action */
bool initWithDuration(float fDuration, float fDeltaAngle); bool initWithDuration(float fDuration, float fDeltaAngle);
/** creates the action with separate rotation angles */
static RotateTo* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
virtual bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY); virtual bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
/** returns a new clone of the action */ //
virtual RotateTo* clone() const; // Overrides
//
/** returns a new reversed action */ virtual RotateTo* clone() const override;
virtual RotateTo* reverse() const; virtual RotateTo* reverse() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void startWithTarget(Node *pTarget); virtual void update(float time) override;
virtual void update(float time);
protected: protected:
float _dstAngleX; float _dstAngleX;
@ -305,21 +293,20 @@ class CC_DLL RotateBy : public ActionInterval
public: public:
/** creates the action */ /** creates the action */
static RotateBy* create(float fDuration, float fDeltaAngle); static RotateBy* create(float fDuration, float fDeltaAngle);
/** initializes the action */ /** initializes the action */
bool initWithDuration(float fDuration, float fDeltaAngle); bool initWithDuration(float fDuration, float fDeltaAngle);
static RotateBy* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY); static RotateBy* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY); bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
/** returns a new clone of the action */ //
virtual RotateBy* clone() const; // Override
//
/** returns a new reversed action */ virtual RotateBy* clone() const override;
virtual RotateBy* reverse(void) const; virtual RotateBy* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void startWithTarget(Node *pTarget); virtual void update(float time) override;
virtual void update(float time);
protected: protected:
float _angleX; float _angleX;
@ -337,22 +324,20 @@ protected:
class CC_DLL MoveBy : public ActionInterval class CC_DLL MoveBy : public ActionInterval
{ {
public: public:
/** creates the action */
static MoveBy* create(float duration, const Point& deltaPosition);
/** initializes the action */ /** initializes the action */
bool initWithDuration(float duration, const Point& deltaPosition); bool initWithDuration(float duration, const Point& deltaPosition);
/** returns a new clone of the action */ //
virtual MoveBy* clone() const; // Overrides
//
virtual MoveBy* clone() const override;
virtual MoveBy* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
/** returns a new reversed action */
virtual MoveBy* reverse(void) const;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** creates the action */
static MoveBy* create(float duration, const Point& deltaPosition);
protected: protected:
Point _positionDelta; Point _positionDelta;
Point _startPosition; Point _startPosition;
@ -367,17 +352,18 @@ protected:
class CC_DLL MoveTo : public MoveBy class CC_DLL MoveTo : public MoveBy
{ {
public: public:
/** creates the action */
static MoveTo* create(float duration, const Point& position);
/** initializes the action */ /** initializes the action */
bool initWithDuration(float duration, const Point& position); bool initWithDuration(float duration, const Point& position);
/** returns a new clone of the action */ //
virtual MoveTo* clone() const; // Overrides
//
virtual MoveTo* clone() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void startWithTarget(Node *pTarget);
public:
/** creates the action */
static MoveTo* create(float duration, const Point& position);
protected: protected:
Point _endPosition; Point _endPosition;
}; };
@ -388,21 +374,20 @@ protected:
class CC_DLL SkewTo : public ActionInterval class CC_DLL SkewTo : public ActionInterval
{ {
public: public:
/** creates the action */
static SkewTo* create(float t, float sx, float sy);
SkewTo(); SkewTo();
virtual bool initWithDuration(float t, float sx, float sy); virtual bool initWithDuration(float t, float sx, float sy);
/** returns a new clone of the action */ //
virtual SkewTo* clone() const; // Overrides
/** returns a new reversed action */ //
virtual SkewTo* reverse(void) const; virtual SkewTo* clone() const override;
virtual SkewTo* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** creates the action */
static SkewTo* create(float t, float sx, float sy);
protected: protected:
float _skewX; float _skewX;
float _skewY; float _skewY;
@ -420,19 +405,17 @@ protected:
class CC_DLL SkewBy : public SkewTo class CC_DLL SkewBy : public SkewTo
{ {
public: public:
virtual bool initWithDuration(float t, float sx, float sy);
virtual void startWithTarget(Node *pTarget);
/** returns a new clone of the action */
virtual SkewBy* clone() const;
/** returns a new reversed action */
virtual SkewBy* reverse(void) const;
public:
/** creates the action */ /** creates the action */
static SkewBy* create(float t, float deltaSkewX, float deltaSkewY); static SkewBy* create(float t, float deltaSkewX, float deltaSkewY);
virtual bool initWithDuration(float t, float sx, float sy);
//
// Overrides
//
virtual void startWithTarget(Node *pTarget) override;
virtual SkewBy* clone() const override;
virtual SkewBy* reverse(void) const override;
}; };
/** @brief Moves a Node object simulating a parabolic jump movement by modifying it's position attribute. /** @brief Moves a Node object simulating a parabolic jump movement by modifying it's position attribute.
@ -440,43 +423,42 @@ public:
class CC_DLL JumpBy : public ActionInterval class CC_DLL JumpBy : public ActionInterval
{ {
public: public:
/** creates the action */
static JumpBy* create(float duration, const Point& position, float height, unsigned int jumps);
/** initializes the action */ /** initializes the action */
bool initWithDuration(float duration, const Point& position, float height, unsigned int jumps); bool initWithDuration(float duration, const Point& position, float height, unsigned int jumps);
/** returns a new clone of the action */ //
virtual JumpBy* clone() const; // Overrides
/** returns a new reversed action */ //
virtual JumpBy* reverse(void) const; virtual JumpBy* clone() const override;
virtual JumpBy* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** creates the action */
static JumpBy* create(float duration, const Point& position, float height, unsigned int jumps);
protected: protected:
Point _startPosition; Point _startPosition;
Point _delta; Point _delta;
float _height; float _height;
unsigned int _jumps; unsigned int _jumps;
Point _previousPos; Point _previousPos;
}; };
/** @brief Moves a Node object to a parabolic position simulating a jump movement by modifying it's position attribute. /** @brief Moves a Node object to a parabolic position simulating a jump movement by modifying it's position attribute.
*/ */
class CC_DLL JumpTo : public JumpBy class CC_DLL JumpTo : public JumpBy
{ {
public:
virtual void startWithTarget(Node *pTarget);
/** returns a new clone of the action */
virtual JumpTo* clone() const;
/** returns a new reversed action */
virtual JumpTo* reverse(void) const;
public: public:
/** creates the action */ /** creates the action */
static JumpTo* create(float duration, const Point& position, float height, int jumps); static JumpTo* create(float duration, const Point& position, float height, int jumps);
//
// Override
//
virtual void startWithTarget(Node *pTarget) override;
virtual JumpTo* clone() const override;
virtual JumpTo* reverse(void) const override;
}; };
/** @typedef bezier configuration structure /** @typedef bezier configuration structure
@ -495,20 +477,20 @@ typedef struct _ccBezierConfig {
class CC_DLL BezierBy : public ActionInterval class CC_DLL BezierBy : public ActionInterval
{ {
public: public:
/** creates the action with a duration and a bezier configuration */
static BezierBy* create(float t, const ccBezierConfig& c);
/** initializes the action with a duration and a bezier configuration */ /** initializes the action with a duration and a bezier configuration */
bool initWithDuration(float t, const ccBezierConfig& c); bool initWithDuration(float t, const ccBezierConfig& c);
/** returns a new clone of the action */ //
virtual BezierBy* clone() const; // Overrides
/** returns a new reversed action */ //
virtual BezierBy* reverse(void) const; virtual BezierBy* clone() const override;
virtual BezierBy* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** creates the action with a duration and a bezier configuration */
static BezierBy* create(float t, const ccBezierConfig& c);
protected: protected:
ccBezierConfig _config; ccBezierConfig _config;
Point _startPosition; Point _startPosition;
@ -521,19 +503,17 @@ protected:
class CC_DLL BezierTo : public BezierBy class CC_DLL BezierTo : public BezierBy
{ {
public: public:
virtual void startWithTarget(Node *pTarget);
/** returns a new clone of the action */
virtual BezierTo* clone() const;
/** returns a new reversed action */
virtual BezierTo* reverse(void) const;
public:
/** creates the action with a duration and a bezier configuration */ /** creates the action with a duration and a bezier configuration */
static BezierTo* create(float t, const ccBezierConfig& c); static BezierTo* create(float t, const ccBezierConfig& c);
bool initWithDuration(float t, const ccBezierConfig &c); bool initWithDuration(float t, const ccBezierConfig &c);
//
// Overrides
//
virtual void startWithTarget(Node *pTarget);
virtual BezierTo* clone() const;
virtual BezierTo* reverse(void) const;
protected: protected:
ccBezierConfig _toConfig; ccBezierConfig _toConfig;
}; };
@ -544,27 +524,26 @@ protected:
class CC_DLL ScaleTo : public ActionInterval class CC_DLL ScaleTo : public ActionInterval
{ {
public: public:
/** creates the action with the same scale factor for X and Y */
static ScaleTo* create(float duration, float s);
/** creates the action with and X factor and a Y factor */
static ScaleTo* create(float duration, float sx, float sy);
/** initializes the action with the same scale factor for X and Y */ /** initializes the action with the same scale factor for X and Y */
bool initWithDuration(float duration, float s); bool initWithDuration(float duration, float s);
/** initializes the action with and X factor and a Y factor */ /** initializes the action with and X factor and a Y factor */
bool initWithDuration(float duration, float sx, float sy); bool initWithDuration(float duration, float sx, float sy);
/** returns a new clone of the action */ //
virtual ScaleTo* clone() const; // Overrides
/** returns a new reversed action */ //
virtual ScaleTo* reverse(void) const; virtual ScaleTo* clone() const override;
virtual ScaleTo* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** creates the action with the same scale factor for X and Y */
static ScaleTo* create(float duration, float s);
/** creates the action with and X factor and a Y factor */
static ScaleTo* create(float duration, float sx, float sy);
protected: protected:
float _scaleX; float _scaleX;
float _scaleY; float _scaleY;
@ -581,19 +560,18 @@ protected:
class CC_DLL ScaleBy : public ScaleTo class CC_DLL ScaleBy : public ScaleTo
{ {
public: public:
virtual void startWithTarget(Node *pTarget);
/** returns a new clone of the action */
virtual ScaleBy* clone() const;
/** returns a new reversed action */
virtual ScaleBy* reverse(void) const;
public:
/** creates the action with the same scale factor for X and Y */ /** creates the action with the same scale factor for X and Y */
static ScaleBy* create(float duration, float s); static ScaleBy* create(float duration, float s);
/** creates the action with and X factor and a Y factor */ /** creates the action with and X factor and a Y factor */
static ScaleBy* create(float duration, float sx, float sy); static ScaleBy* create(float duration, float sx, float sy);
//
// Overrides
//
virtual void startWithTarget(Node *pTarget) override;
virtual ScaleBy* clone() const override;
virtual ScaleBy* reverse(void) const override;
}; };
/** @brief Blinks a Node object by modifying it's visible attribute /** @brief Blinks a Node object by modifying it's visible attribute
@ -601,23 +579,20 @@ public:
class CC_DLL Blink : public ActionInterval class CC_DLL Blink : public ActionInterval
{ {
public: public:
/** creates the action */
static Blink* create(float duration, unsigned int uBlinks);
/** initializes the action */ /** initializes the action */
bool initWithDuration(float duration, unsigned int uBlinks); bool initWithDuration(float duration, unsigned int uBlinks);
/** returns a new clone of the action */ //
virtual Blink* clone() const; // Overrides
/** returns a new reversed action */ //
virtual Blink* reverse(void) const; virtual Blink* clone() const override;
virtual Blink* reverse(void) const override;
virtual void update(float time); virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget) override;
public: virtual void stop() override;
/** creates the action */
static Blink* create(float duration, unsigned int uBlinks);
virtual void startWithTarget(Node *pTarget);
virtual void stop();
protected: protected:
unsigned int _times; unsigned int _times;
@ -629,17 +604,16 @@ protected:
*/ */
class CC_DLL FadeIn : public ActionInterval class CC_DLL FadeIn : public ActionInterval
{ {
public:
virtual void update(float time);
/** returns a new clone of the action */
virtual FadeIn* clone() const;
/** returns a new reversed action */
virtual ActionInterval* reverse(void) const;
public: public:
/** creates the action */ /** creates the action */
static FadeIn* create(float d); static FadeIn* create(float d);
//
// Overrides
//
virtual void update(float time) override;
virtual FadeIn* clone() const override;
virtual ActionInterval* reverse(void) const override;
}; };
/** @brief Fades Out an object that implements the RGBAProtocol protocol. It modifies the opacity from 255 to 0. /** @brief Fades Out an object that implements the RGBAProtocol protocol. It modifies the opacity from 255 to 0.
@ -648,18 +622,15 @@ public:
class CC_DLL FadeOut : public ActionInterval class CC_DLL FadeOut : public ActionInterval
{ {
public: public:
virtual void update(float time);
/** returns a new clone of the action */
virtual FadeOut* clone() const;
/** returns a new reversed action */
virtual ActionInterval* reverse(void) const;
public:
/** creates the action */ /** creates the action */
static FadeOut* create(float d); static FadeOut* create(float d);
//
// Overrides
//
virtual void update(float time) override;
virtual FadeOut* clone() const override;
virtual ActionInterval* reverse(void) const override;
}; };
/** @brief Fades an object that implements the RGBAProtocol protocol. It modifies the opacity from the current value to a custom one. /** @brief Fades an object that implements the RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
@ -668,20 +639,20 @@ public:
class CC_DLL FadeTo : public ActionInterval class CC_DLL FadeTo : public ActionInterval
{ {
public: public:
/** creates an action with duration and opacity */
static FadeTo* create(float duration, GLubyte opacity);
/** initializes the action with duration and opacity */ /** initializes the action with duration and opacity */
bool initWithDuration(float duration, GLubyte opacity); bool initWithDuration(float duration, GLubyte opacity);
/** returns a new clone of the action */ //
virtual FadeTo* clone() const; // Overrides
/** returns a new reversed action */ //
virtual FadeTo* reverse(void) const; virtual FadeTo* clone() const override;
virtual FadeTo* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** creates an action with duration and opacity */
static FadeTo* create(float duration, GLubyte opacity);
protected: protected:
GLubyte _toOpacity; GLubyte _toOpacity;
GLubyte _fromOpacity; GLubyte _fromOpacity;
@ -694,20 +665,20 @@ protected:
class CC_DLL TintTo : public ActionInterval class CC_DLL TintTo : public ActionInterval
{ {
public: public:
/** creates an action with duration and color */
static TintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue);
/** initializes the action with duration and color */ /** initializes the action with duration and color */
bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue);
/** returns a new clone of the action */ //
virtual TintTo* clone() const; // Overrides
/** returns a new reversed action */ //
virtual TintTo* reverse(void) const; virtual TintTo* clone() const override;
virtual TintTo* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** creates an action with duration and color */
static TintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue);
protected: protected:
Color3B _to; Color3B _to;
Color3B _from; Color3B _from;
@ -719,20 +690,20 @@ protected:
class CC_DLL TintBy : public ActionInterval class CC_DLL TintBy : public ActionInterval
{ {
public: public:
/** creates an action with duration and color */
static TintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
/** initializes the action with duration and color */ /** initializes the action with duration and color */
bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
/** returns a new clone of the action */ //
virtual TintBy* clone() const; // Overrides
/** returns a new reversed action */ //
virtual TintBy* reverse() const; virtual TintBy* clone() const override;
virtual TintBy* reverse() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** creates an action with duration and color */
static TintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
protected: protected:
GLshort _deltaR; GLshort _deltaR;
GLshort _deltaG; GLshort _deltaG;
@ -748,16 +719,15 @@ protected:
class CC_DLL DelayTime : public ActionInterval class CC_DLL DelayTime : public ActionInterval
{ {
public: public:
virtual void update(float time);
/** returns a new reversed action */
virtual DelayTime* reverse() const;
/** returns a new clone of the action */
virtual DelayTime* clone() const;
public:
/** creates the action */ /** creates the action */
static DelayTime* create(float d); static DelayTime* create(float d);
//
// Overrides
//
virtual void update(float time) override;
virtual DelayTime* reverse() const override;
virtual DelayTime* clone() const override;
}; };
/** @brief Executes an action in reverse order, from time=duration to time=0 /** @brief Executes an action in reverse order, from time=duration to time=0
@ -770,23 +740,24 @@ public:
class CC_DLL ReverseTime : public ActionInterval class CC_DLL ReverseTime : public ActionInterval
{ {
public: public:
~ReverseTime(void); /** creates the action */
static ReverseTime* create(FiniteTimeAction *pAction);
virtual ~ReverseTime(void);
ReverseTime(); ReverseTime();
/** initializes the action */ /** initializes the action */
bool initWithAction(FiniteTimeAction *pAction); bool initWithAction(FiniteTimeAction *pAction);
/** returns a new reversed action */ //
virtual ReverseTime* reverse() const; // Overrides
/** returns a new clone of the action */ //
virtual ReverseTime* clone() const; virtual ReverseTime* reverse() const override;
virtual void startWithTarget(Node *pTarget); virtual ReverseTime* clone() const override;
virtual void stop(void); virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time); virtual void stop(void) override;
virtual void update(float time) override;
public:
/** creates the action */
static ReverseTime* create(FiniteTimeAction *pAction);
protected: protected:
FiniteTimeAction *_other; FiniteTimeAction *_other;
}; };
@ -796,24 +767,27 @@ class Texture2D;
class CC_DLL Animate : public ActionInterval class CC_DLL Animate : public ActionInterval
{ {
public: public:
/** creates the action with an Animation and will restore the original frame when the animation is over */
static Animate* create(Animation *pAnimation);
Animate(); Animate();
~Animate(); virtual ~Animate();
/** initializes the action with an Animation and will restore the original frame when the animation is over */ /** initializes the action with an Animation and will restore the original frame when the animation is over */
bool initWithAnimation(Animation *pAnimation); bool initWithAnimation(Animation *pAnimation);
/** returns a new clone of the action */ //
virtual Animate* clone() const; // Overrides
/** returns a new reversed action */ //
virtual Animate* reverse() const; virtual Animate* clone() const override;
virtual Animate* reverse() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void stop(void) override;
virtual void update(float t) override;
virtual void startWithTarget(Node *pTarget);
virtual void stop(void);
virtual void update(float t);
public: public:
/** creates the action with an Animation and will restore the original frame when the animation is over */
static Animate* create(Animation *pAnimation);
CC_SYNTHESIZE_RETAIN(Animation*, _animation, Animation) CC_SYNTHESIZE_RETAIN(Animation*, _animation, Animation)
protected: protected:
std::vector<float>* _splitTimes; std::vector<float>* _splitTimes;
int _nextFrame; int _nextFrame;
@ -836,15 +810,16 @@ public:
/** Init an action with the specified action and forced target */ /** Init an action with the specified action and forced target */
bool initWithTarget(Node* pTarget, FiniteTimeAction* pAction); bool initWithTarget(Node* pTarget, FiniteTimeAction* pAction);
/** returns a new clone of the action */ //
virtual TargetedAction* clone() const; // Overrides
/** returns a new reversed action */ //
virtual TargetedAction* reverse() const; virtual TargetedAction* clone() const override;
virtual TargetedAction* reverse() const override;
virtual void startWithTarget(Node *pTarget); virtual void startWithTarget(Node *pTarget) override;
virtual void stop(void); virtual void stop(void) override;
virtual void update(float time); virtual void update(float time) override;
public:
/** This is the target that the action will be forced to run with */ /** This is the target that the action will be forced to run with */
CC_SYNTHESIZE_RETAIN(Node*, _forcedTarget, ForcedTarget); CC_SYNTHESIZE_RETAIN(Node*, _forcedTarget, ForcedTarget);
private: private:

View File

@ -41,21 +41,20 @@ NS_CC_BEGIN
class CC_DLL ProgressTo : public ActionInterval class CC_DLL ProgressTo : public ActionInterval
{ {
public: public:
/** Creates and initializes with a duration and a percent */
static ProgressTo* create(float duration, float fPercent);
/** Initializes with a duration and a percent */ /** Initializes with a duration and a percent */
bool initWithDuration(float duration, float fPercent); bool initWithDuration(float duration, float fPercent);
/** returns a new clone of the action */ //
virtual ProgressTo* clone() const; // Overrides
//
virtual ProgressTo* clone() const override;
virtual ProgressTo* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
/** returns a new reversed action */
virtual ProgressTo* reverse(void) const;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** Creates and initializes with a duration and a percent */
static ProgressTo* create(float duration, float fPercent);
protected: protected:
float _to; float _to;
float _from; float _from;
@ -68,22 +67,20 @@ protected:
class CC_DLL ProgressFromTo : public ActionInterval class CC_DLL ProgressFromTo : public ActionInterval
{ {
public: public:
/** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */
static ProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage);
/** Initializes the action with a duration, a "from" percentage and a "to" percentage */ /** Initializes the action with a duration, a "from" percentage and a "to" percentage */
bool initWithDuration(float duration, float fFromPercentage, float fToPercentage); bool initWithDuration(float duration, float fFromPercentage, float fToPercentage);
/** returns a new clone of the action */ //
virtual ProgressFromTo* clone() const; // Overrides
//
virtual ProgressFromTo* clone() const override;
virtual ProgressFromTo* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
/** returns a new reversed action */
virtual ProgressFromTo* reverse(void) const;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
public:
/** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */
static ProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage);
protected: protected:
float _to; float _to;
float _from; float _from;

View File

@ -130,7 +130,13 @@ class CC_DLL Node : public Object
public: public:
/// @{ /// @{
/// @name Constructor, Distructor and Initializers /// @name Constructor, Distructor and Initializers
/**
* Allocates and initializes a node.
* @return A initialized node which is marked as "autorelease".
*/
static Node * create(void);
/** /**
* Default constructor * Default constructor
*/ */
@ -146,12 +152,7 @@ public:
* @return Whether the initialization was successful. * @return Whether the initialization was successful.
*/ */
virtual bool init(); virtual bool init();
/**
* Allocates and initializes a node.
* @return A initialized node which is marked as "autorelease".
*/
static Node * create(void);
/** /**
* Gets the description string. It makes debugging easier. * Gets the description string. It makes debugging easier.
* @return A string terminated with '\0' * @return A string terminated with '\0'

View File

@ -3,6 +3,7 @@
#include "ccMacros.h" #include "ccMacros.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "CCArray.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -151,6 +152,28 @@ void String::appendWithFormat(const char* format, ...)
} }
Array* String::componentsSeparatedByString(const char *delimiter)
{
Array* result = Array::create();
int cutAt;
while( (cutAt = _string.find_first_of(delimiter)) != _string.npos )
{
if(cutAt > 0)
{
result->addObject(String::create(_string.substr(0, cutAt)));
}
_string = _string.substr(cutAt + 1);
}
if(_string.length() > 0)
{
result->addObject(String::create(_string));
}
return result;
}
bool String::isEqual(const Object* pObject) bool String::isEqual(const Object* pObject)
{ {
bool bRet = false; bool bRet = false;

View File

@ -86,6 +86,9 @@ public:
/** append(w/ format) additional characters at the end of its current value */ /** append(w/ format) additional characters at the end of its current value */
void appendWithFormat(const char* format, ...); void appendWithFormat(const char* format, ...);
/** split a string */
Array* componentsSeparatedByString(const char *delimiter);
/* override functions */ /* override functions */
virtual bool isEqual(const Object* pObject); virtual bool isEqual(const Object* pObject);

View File

@ -70,10 +70,6 @@ public:
/** creates a fullscreen black layer */ /** creates a fullscreen black layer */
static Layer *create(void); static Layer *create(void);
virtual void onEnter();
virtual void onExit();
virtual void onEnterTransitionDidFinish();
// default implements are used to call script callback if exist // default implements are used to call script callback if exist
virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent); virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent);
virtual void ccTouchMoved(Touch *pTouch, Event *pEvent); virtual void ccTouchMoved(Touch *pTouch, Event *pEvent);
@ -138,13 +134,20 @@ public:
virtual void keyBackClicked(void); virtual void keyBackClicked(void);
virtual void keyMenuClicked(void); virtual void keyMenuClicked(void);
protected: //
// Overrides
//
virtual void onEnter() override;
virtual void onExit() override;
virtual void onEnterTransitionDidFinish() override;
protected:
bool _touchEnabled; bool _touchEnabled;
bool _accelerometerEnabled; bool _accelerometerEnabled;
bool _keyboardEnabled; bool _keyboardEnabled;
bool _keypadEnabled; bool _keypadEnabled;
private: private:
int _touchPriority; int _touchPriority;
ccTouchesMode _touchMode; ccTouchesMode _touchMode;
@ -173,23 +176,26 @@ public:
virtual ~LayerRGBA(); virtual ~LayerRGBA();
virtual bool init(); virtual bool init();
//
// Overrides
//
virtual GLubyte getOpacity() const override;
virtual GLubyte getDisplayedOpacity() const override;
virtual void setOpacity(GLubyte opacity) override;
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
virtual bool isCascadeOpacityEnabled() const override;
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
virtual GLubyte getOpacity() const; virtual const Color3B& getColor() const override;
virtual GLubyte getDisplayedOpacity() const; virtual const Color3B& getDisplayedColor() const override;
virtual void setOpacity(GLubyte opacity); virtual void setColor(const Color3B& color) override;
virtual void updateDisplayedOpacity(GLubyte parentOpacity); virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual bool isCascadeOpacityEnabled() const; virtual bool isCascadeColorEnabled() const override;
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
virtual const Color3B& getColor() const; virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}
virtual const Color3B& getDisplayedColor() const; virtual bool isOpacityModifyRGB() const override { return false; }
virtual void setColor(const Color3B& color);
virtual void updateDisplayedColor(const Color3B& parentColor);
virtual bool isCascadeColorEnabled() const;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB() const { return false; }
protected: protected:
GLubyte _displayedOpacity, _realOpacity; GLubyte _displayedOpacity, _realOpacity;
Color3B _displayedColor, _realColor; Color3B _displayedColor, _realColor;
@ -247,8 +253,11 @@ public:
/** BlendFunction. Conforms to BlendProtocol protocol */ /** BlendFunction. Conforms to BlendProtocol protocol */
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc) CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc)
virtual void setColor(const Color3B &color); //
virtual void setOpacity(GLubyte opacity); // Overrides
//
virtual void setColor(const Color3B &color) override;
virtual void setOpacity(GLubyte opacity) override;
protected: protected:
virtual void updateColor(); virtual void updateColor();
@ -309,7 +318,7 @@ public:
CC_PROPERTY_PASS_BY_REF(Point, _alongVector, Vector) CC_PROPERTY_PASS_BY_REF(Point, _alongVector, Vector)
protected: protected:
virtual void updateColor(); virtual void updateColor() override;
protected: protected:
bool _compressedInterpolation; bool _compressedInterpolation;

View File

@ -49,11 +49,13 @@ It is a good practice to use and Scene as the parent of all your nodes.
class CC_DLL Scene : public Node class CC_DLL Scene : public Node
{ {
public: public:
/** creates a new Scene object */
static Scene *create(void);
Scene(); Scene();
virtual ~Scene(); virtual ~Scene();
bool init(); bool init();
static Scene *create(void);
}; };
// end of scene group // end of scene group

View File

@ -274,7 +274,7 @@ void TransitionRotoZoom:: onEnter()
Sequence::create Sequence::create
( (
rotozoom->reverse(), rotozoom->reverse(),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
) )
); );
@ -328,7 +328,7 @@ void TransitionJumpZoom::onEnter()
( (
delay, delay,
jumpZoomIn, jumpZoomIn,
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
) )
); );
@ -369,7 +369,7 @@ void TransitionMoveInL::onEnter()
Sequence::create Sequence::create
( (
this->easeActionWithAction(a), this->easeActionWithAction(a),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
) )
); );
@ -506,7 +506,7 @@ void TransitionSlideInL::onEnter()
ActionInterval* outAction = (ActionInterval*)Sequence::create ActionInterval* outAction = (ActionInterval*)Sequence::create
( (
easeActionWithAction(out), easeActionWithAction(out),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
); );
_inScene->runAction(inAction); _inScene->runAction(inAction);
@ -709,7 +709,7 @@ void TransitionShrinkGrow::onEnter()
Sequence::create Sequence::create
( (
this->easeActionWithAction(scaleOut), this->easeActionWithAction(scaleOut),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
) )
); );
@ -760,7 +760,7 @@ void TransitionFlipX::onEnter()
DelayTime::create(_duration/2), DelayTime::create(_duration/2),
Show::create(), Show::create(),
OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0), OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
); );
@ -830,7 +830,7 @@ void TransitionFlipY::onEnter()
DelayTime::create(_duration/2), DelayTime::create(_duration/2),
Show::create(), Show::create(),
OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0), OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
); );
outA = (ActionInterval*)Sequence::create outA = (ActionInterval*)Sequence::create
@ -901,7 +901,7 @@ void TransitionFlipAngular::onEnter()
DelayTime::create(_duration/2), DelayTime::create(_duration/2),
Show::create(), Show::create(),
OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0), OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
); );
outA = (ActionInterval *)Sequence::create outA = (ActionInterval *)Sequence::create
@ -973,7 +973,7 @@ void TransitionZoomFlipX::onEnter()
Show::create(), Show::create(),
NULL NULL
), ),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
); );
outA = (ActionInterval *)Sequence::create outA = (ActionInterval *)Sequence::create
@ -1051,7 +1051,7 @@ void TransitionZoomFlipY::onEnter()
Show::create(), Show::create(),
NULL NULL
), ),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
); );
@ -1133,7 +1133,7 @@ void TransitionZoomFlipAngular::onEnter()
NULL NULL
), ),
Show::create(), Show::create(),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
); );
outA = (ActionInterval *)Sequence::create outA = (ActionInterval *)Sequence::create
@ -1222,10 +1222,11 @@ void TransitionFade :: onEnter()
ActionInterval* a = (ActionInterval *)Sequence::create ActionInterval* a = (ActionInterval *)Sequence::create
( (
FadeIn::create(_duration/2), FadeIn::create(_duration/2),
CallFunc::create(this, callfunc_selector(TransitionScene::hideOutShowIn)),//CCCallFunc::create:self selector:@selector(hideOutShowIn)], CallFunc::create(CC_CALLBACK_0(TransitionScene::hideOutShowIn,this)),
FadeOut::create(_duration/2), FadeOut::create(_duration/2),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), //:self selector:@selector(finish)], CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL
NULL
); );
f->runAction(a); f->runAction(a);
} }
@ -1322,8 +1323,8 @@ void TransitionCrossFade::onEnter()
Action* layerAction = Sequence::create Action* layerAction = Sequence::create
( (
FadeTo::create(_duration, 0), FadeTo::create(_duration, 0),
CallFunc::create(this, callfunc_selector(TransitionScene::hideOutShowIn)), CallFunc::create(CC_CALLBACK_0(TransitionScene::hideOutShowIn,this)),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL NULL
); );
@ -1387,7 +1388,7 @@ void TransitionTurnOffTiles::onEnter()
Sequence::create Sequence::create
( (
action, action,
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
StopGrid::create(), StopGrid::create(),
NULL NULL
) )
@ -1431,7 +1432,7 @@ void TransitionSplitCols::onEnter()
ActionInterval* seq = (ActionInterval*)Sequence::create ActionInterval* seq = (ActionInterval*)Sequence::create
( (
split, split,
CallFunc::create(this, callfunc_selector(TransitionScene::hideOutShowIn)), CallFunc::create(CC_CALLBACK_0(TransitionScene::hideOutShowIn,this)),
split->reverse(), split->reverse(),
NULL NULL
); );
@ -1441,7 +1442,7 @@ void TransitionSplitCols::onEnter()
Sequence::create Sequence::create
( (
easeActionWithAction(seq), easeActionWithAction(seq),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
StopGrid::create(), StopGrid::create(),
NULL NULL
) )
@ -1531,7 +1532,7 @@ void TransitionFadeTR::onEnter()
Sequence::create Sequence::create
( (
easeActionWithAction(action), easeActionWithAction(action),
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
StopGrid::create(), StopGrid::create(),
NULL NULL
) )

View File

@ -80,24 +80,12 @@ typedef enum {
class CC_DLL TransitionScene : public Scene class CC_DLL TransitionScene : public Scene
{ {
protected:
Scene * _inScene;
Scene * _outScene;
float _duration;
bool _isInSceneOnTop;
bool _isSendCleanupToScene;
public: public:
/** creates a base transition with duration and incoming scene */
static TransitionScene * create(float t, Scene *scene);
TransitionScene(); TransitionScene();
virtual ~TransitionScene(); virtual ~TransitionScene();
virtual void draw();
virtual void onEnter();
virtual void onExit();
virtual void cleanup();
/** creates a base transition with duration and incoming scene */
static TransitionScene * create(float t, Scene *scene);
/** initializes a transition with duration and incoming scene */ /** initializes a transition with duration and incoming scene */
virtual bool initWithDuration(float t,Scene* scene); virtual bool initWithDuration(float t,Scene* scene);
@ -108,11 +96,26 @@ public:
/** used by some transitions to hide the outer scene */ /** used by some transitions to hide the outer scene */
void hideOutShowIn(void); void hideOutShowIn(void);
//
// Overrides
//
virtual void draw() override;
virtual void onEnter() override;
virtual void onExit() override;
virtual void cleanup() override;
protected: protected:
virtual void sceneOrder(); virtual void sceneOrder();
private: private:
void setNewScene(float dt); void setNewScene(float dt);
protected:
Scene * _inScene;
Scene * _outScene;
float _duration;
bool _isInSceneOnTop;
bool _isSendCleanupToScene;
}; };
/** @brief A Transition that supports orientation like. /** @brief A Transition that supports orientation like.
@ -120,18 +123,18 @@ private:
*/ */
class CC_DLL TransitionSceneOriented : public TransitionScene class CC_DLL TransitionSceneOriented : public TransitionScene
{ {
protected:
tOrientation _orientation;
public: public:
TransitionSceneOriented();
virtual ~TransitionSceneOriented();
/** creates a base transition with duration and incoming scene */ /** creates a base transition with duration and incoming scene */
static TransitionSceneOriented * create(float t,Scene* scene, tOrientation orientation); static TransitionSceneOriented * create(float t,Scene* scene, tOrientation orientation);
TransitionSceneOriented();
virtual ~TransitionSceneOriented();
/** initializes a transition with duration and incoming scene */ /** initializes a transition with duration and incoming scene */
virtual bool initWithDuration(float t,Scene* scene,tOrientation orientation); virtual bool initWithDuration(float t,Scene* scene,tOrientation orientation);
protected:
tOrientation _orientation;
}; };
/** @brief TransitionRotoZoom: /** @brief TransitionRotoZoom:
@ -140,11 +143,15 @@ Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming
class CC_DLL TransitionRotoZoom : public TransitionScene class CC_DLL TransitionRotoZoom : public TransitionScene
{ {
public: public:
static TransitionRotoZoom* create(float t, Scene* scene);
TransitionRotoZoom(); TransitionRotoZoom();
virtual ~TransitionRotoZoom(); virtual ~TransitionRotoZoom();
virtual void onEnter();
static TransitionRotoZoom* create(float t, Scene* scene); //
// Overrides
//
virtual void onEnter() override;
}; };
/** @brief TransitionJumpZoom: /** @brief TransitionJumpZoom:
@ -153,11 +160,15 @@ Zoom out and jump the outgoing scene, and then jump and zoom in the incoming
class CC_DLL TransitionJumpZoom : public TransitionScene class CC_DLL TransitionJumpZoom : public TransitionScene
{ {
public: public:
static TransitionJumpZoom* create(float t, Scene* scene);
TransitionJumpZoom(); TransitionJumpZoom();
virtual ~TransitionJumpZoom(); virtual ~TransitionJumpZoom();
virtual void onEnter();
static TransitionJumpZoom* create(float t, Scene* scene); //
// Overrides
//
virtual void onEnter() override;
}; };
/** @brief TransitionMoveInL: /** @brief TransitionMoveInL:
@ -166,6 +177,8 @@ Move in from to the left the incoming scene.
class CC_DLL TransitionMoveInL : public TransitionScene, public TransitionEaseScene class CC_DLL TransitionMoveInL : public TransitionScene, public TransitionEaseScene
{ {
public: public:
static TransitionMoveInL* create(float t, Scene* scene);
TransitionMoveInL(); TransitionMoveInL();
virtual ~TransitionMoveInL(); virtual ~TransitionMoveInL();
/** initializes the scenes */ /** initializes the scenes */
@ -175,9 +188,10 @@ public:
virtual ActionInterval* easeActionWithAction(ActionInterval * action); virtual ActionInterval* easeActionWithAction(ActionInterval * action);
virtual void onEnter(); //
// Overrides
static TransitionMoveInL* create(float t, Scene* scene); //
virtual void onEnter() override;
}; };
/** @brief TransitionMoveInR: /** @brief TransitionMoveInR:
@ -186,11 +200,11 @@ Move in from to the right the incoming scene.
class CC_DLL TransitionMoveInR : public TransitionMoveInL class CC_DLL TransitionMoveInR : public TransitionMoveInL
{ {
public: public:
static TransitionMoveInR* create(float t, Scene* scene);
TransitionMoveInR(); TransitionMoveInR();
virtual ~TransitionMoveInR(); virtual ~TransitionMoveInR();
virtual void initScenes(); virtual void initScenes();
static TransitionMoveInR* create(float t, Scene* scene);
}; };
/** @brief TransitionMoveInT: /** @brief TransitionMoveInT:
@ -199,11 +213,11 @@ Move in from to the top the incoming scene.
class CC_DLL TransitionMoveInT : public TransitionMoveInL class CC_DLL TransitionMoveInT : public TransitionMoveInL
{ {
public: public:
static TransitionMoveInT* create(float t, Scene* scene);
TransitionMoveInT(); TransitionMoveInT();
virtual ~TransitionMoveInT(); virtual ~TransitionMoveInT();
virtual void initScenes(); virtual void initScenes();
static TransitionMoveInT* create(float t, Scene* scene);
}; };
/** @brief TransitionMoveInB: /** @brief TransitionMoveInB:
@ -212,11 +226,11 @@ Move in from to the bottom the incoming scene.
class CC_DLL TransitionMoveInB : public TransitionMoveInL class CC_DLL TransitionMoveInB : public TransitionMoveInL
{ {
public: public:
static TransitionMoveInB* create(float t, Scene* scene);
TransitionMoveInB(); TransitionMoveInB();
virtual ~TransitionMoveInB(); virtual ~TransitionMoveInB();
virtual void initScenes(); virtual void initScenes();
static TransitionMoveInB* create(float t, Scene* scene);
}; };
/** @brief TransitionSlideInL: /** @brief TransitionSlideInL:
@ -225,21 +239,25 @@ Slide in the incoming scene from the left border.
class CC_DLL TransitionSlideInL : public TransitionScene, public TransitionEaseScene class CC_DLL TransitionSlideInL : public TransitionScene, public TransitionEaseScene
{ {
public: public:
static TransitionSlideInL* create(float t, Scene* scene);
TransitionSlideInL(); TransitionSlideInL();
virtual ~TransitionSlideInL(); virtual ~TransitionSlideInL();
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
/** initializes the scenes */ /** initializes the scenes */
virtual void initScenes(void); virtual void initScenes(void);
/** returns the action that will be performed by the incoming and outgoing scene */ /** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void); virtual ActionInterval* action(void);
virtual void onEnter(); //
// Overrides
//
virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
static TransitionSlideInL* create(float t, Scene* scene);
protected: protected:
virtual void sceneOrder(); virtual void sceneOrder() override;
}; };
/** @brief TransitionSlideInR: /** @brief TransitionSlideInR:
@ -248,6 +266,8 @@ Slide in the incoming scene from the right border.
class CC_DLL TransitionSlideInR : public TransitionSlideInL class CC_DLL TransitionSlideInR : public TransitionSlideInL
{ {
public: public:
static TransitionSlideInR* create(float t, Scene* scene);
TransitionSlideInR(); TransitionSlideInR();
virtual ~TransitionSlideInR(); virtual ~TransitionSlideInR();
@ -256,9 +276,8 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */ /** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void); virtual ActionInterval* action(void);
static TransitionSlideInR* create(float t, Scene* scene);
protected: protected:
virtual void sceneOrder(); virtual void sceneOrder() override;
}; };
/** @brief TransitionSlideInB: /** @brief TransitionSlideInB:
@ -267,6 +286,8 @@ Slide in the incoming scene from the bottom border.
class CC_DLL TransitionSlideInB : public TransitionSlideInL class CC_DLL TransitionSlideInB : public TransitionSlideInL
{ {
public: public:
static TransitionSlideInB* create(float t, Scene* scene);
TransitionSlideInB(); TransitionSlideInB();
virtual ~TransitionSlideInB(); virtual ~TransitionSlideInB();
@ -275,9 +296,8 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */ /** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void); virtual ActionInterval* action(void);
static TransitionSlideInB* create(float t, Scene* scene); protected:
protected: virtual void sceneOrder() override;
virtual void sceneOrder();
}; };
/** @brief TransitionSlideInT: /** @brief TransitionSlideInT:
@ -286,6 +306,8 @@ Slide in the incoming scene from the top border.
class CC_DLL TransitionSlideInT : public TransitionSlideInL class CC_DLL TransitionSlideInT : public TransitionSlideInL
{ {
public: public:
static TransitionSlideInT* create(float t, Scene* scene);
TransitionSlideInT(); TransitionSlideInT();
virtual ~TransitionSlideInT(); virtual ~TransitionSlideInT();
@ -294,9 +316,8 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */ /** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void); virtual ActionInterval* action(void);
static TransitionSlideInT* create(float t, Scene* scene);
protected: protected:
virtual void sceneOrder(); virtual void sceneOrder() override;
}; };
/** /**
@ -305,13 +326,16 @@ protected:
class CC_DLL TransitionShrinkGrow : public TransitionScene , public TransitionEaseScene class CC_DLL TransitionShrinkGrow : public TransitionScene , public TransitionEaseScene
{ {
public: public:
static TransitionShrinkGrow* create(float t, Scene* scene);
TransitionShrinkGrow(); TransitionShrinkGrow();
virtual ~TransitionShrinkGrow(); virtual ~TransitionShrinkGrow();
virtual void onEnter(); //
virtual ActionInterval* easeActionWithAction(ActionInterval * action); // Overrides
//
static TransitionShrinkGrow* create(float t, Scene* scene); virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
}; };
/** @brief TransitionFlipX: /** @brief TransitionFlipX:
@ -321,13 +345,16 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionFlipX : public TransitionSceneOriented class CC_DLL TransitionFlipX : public TransitionSceneOriented
{ {
public: public:
static TransitionFlipX* create(float t, Scene* s, tOrientation o);
static TransitionFlipX* create(float t, Scene* s);
TransitionFlipX(); TransitionFlipX();
virtual ~TransitionFlipX(); virtual ~TransitionFlipX();
virtual void onEnter(); //
// Overrides
static TransitionFlipX* create(float t, Scene* s, tOrientation o); //
static TransitionFlipX* create(float t, Scene* s); virtual void onEnter() override;
}; };
/** @brief TransitionFlipY: /** @brief TransitionFlipY:
@ -337,13 +364,16 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionFlipY : public TransitionSceneOriented class CC_DLL TransitionFlipY : public TransitionSceneOriented
{ {
public: public:
static TransitionFlipY* create(float t, Scene* s, tOrientation o);
static TransitionFlipY* create(float t, Scene* s);
TransitionFlipY(); TransitionFlipY();
virtual ~TransitionFlipY(); virtual ~TransitionFlipY();
virtual void onEnter(); //
// Overrides
static TransitionFlipY* create(float t, Scene* s, tOrientation o); //
static TransitionFlipY* create(float t, Scene* s); virtual void onEnter() override;
}; };
/** @brief TransitionFlipAngular: /** @brief TransitionFlipAngular:
@ -353,13 +383,16 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionFlipAngular : public TransitionSceneOriented class CC_DLL TransitionFlipAngular : public TransitionSceneOriented
{ {
public: public:
static TransitionFlipAngular* create(float t, Scene* s, tOrientation o);
static TransitionFlipAngular* create(float t, Scene* s);
TransitionFlipAngular(); TransitionFlipAngular();
virtual ~TransitionFlipAngular(); virtual ~TransitionFlipAngular();
virtual void onEnter(); //
// Overrides
static TransitionFlipAngular* create(float t, Scene* s, tOrientation o); //
static TransitionFlipAngular* create(float t, Scene* s); virtual void onEnter() override;
}; };
/** @brief TransitionZoomFlipX: /** @brief TransitionZoomFlipX:
@ -369,13 +402,16 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented
{ {
public: public:
static TransitionZoomFlipX* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipX* create(float t, Scene* s);
TransitionZoomFlipX(); TransitionZoomFlipX();
virtual ~TransitionZoomFlipX(); virtual ~TransitionZoomFlipX();
virtual void onEnter(); //
// Overrides
static TransitionZoomFlipX* create(float t, Scene* s, tOrientation o); //
static TransitionZoomFlipX* create(float t, Scene* s); virtual void onEnter() override;
}; };
/** @brief TransitionZoomFlipY: /** @brief TransitionZoomFlipY:
@ -385,13 +421,16 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented
{ {
public: public:
static TransitionZoomFlipY* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipY* create(float t, Scene* s);
TransitionZoomFlipY(); TransitionZoomFlipY();
virtual ~TransitionZoomFlipY(); virtual ~TransitionZoomFlipY();
virtual void onEnter(); //
// Overrides
static TransitionZoomFlipY* create(float t, Scene* s, tOrientation o); //
static TransitionZoomFlipY* create(float t, Scene* s); virtual void onEnter() override;
}; };
/** @brief TransitionZoomFlipAngular: /** @brief TransitionZoomFlipAngular:
@ -401,13 +440,16 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented
{ {
public: public:
static TransitionZoomFlipAngular* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipAngular* create(float t, Scene* s);
TransitionZoomFlipAngular(); TransitionZoomFlipAngular();
virtual ~TransitionZoomFlipAngular(); virtual ~TransitionZoomFlipAngular();
virtual void onEnter(); //
// Overrides
static TransitionZoomFlipAngular* create(float t, Scene* s, tOrientation o); //
static TransitionZoomFlipAngular* create(float t, Scene* s); virtual void onEnter() override;
}; };
/** @brief TransitionFade: /** @brief TransitionFade:
@ -415,26 +457,28 @@ Fade out the outgoing scene and then fade in the incoming scene.'''
*/ */
class CC_DLL TransitionFade : public TransitionScene class CC_DLL TransitionFade : public TransitionScene
{ {
protected:
Color4B _color;
public: public:
TransitionFade();
virtual ~TransitionFade();
/** creates the transition with a duration and with an RGB color /** creates the transition with a duration and with an RGB color
* Example: FadeTransition::create(2, scene, Color3B(255,0,0); // red color * Example: FadeTransition::create(2, scene, Color3B(255,0,0); // red color
*/ */
static TransitionFade* create(float duration,Scene* scene, const Color3B& color); static TransitionFade* create(float duration,Scene* scene, const Color3B& color);
static TransitionFade* create(float duration,Scene* scene); static TransitionFade* create(float duration,Scene* scene);
TransitionFade();
virtual ~TransitionFade();
/** initializes the transition with a duration and with an RGB color */ /** initializes the transition with a duration and with an RGB color */
virtual bool initWithDuration(float t, Scene*scene ,const Color3B& color); virtual bool initWithDuration(float t, Scene*scene ,const Color3B& color);
virtual bool initWithDuration(float t,Scene* scene); //
// Overrides
//
virtual bool initWithDuration(float t,Scene* scene);
virtual void onEnter(); virtual void onEnter();
virtual void onExit(); virtual void onExit();
protected:
Color4B _color;
}; };
class RenderTexture; class RenderTexture;
@ -445,15 +489,18 @@ Cross fades two scenes using the RenderTexture object.
class CC_DLL TransitionCrossFade : public TransitionScene class CC_DLL TransitionCrossFade : public TransitionScene
{ {
public : public :
static TransitionCrossFade* create(float t, Scene* scene);
TransitionCrossFade(); TransitionCrossFade();
virtual ~TransitionCrossFade(); virtual ~TransitionCrossFade();
virtual void draw(); //
virtual void onEnter(); // Overrides
virtual void onExit(); //
virtual void draw() override;
virtual void onEnter() override;
virtual void onExit() override;
public:
static TransitionCrossFade* create(float t, Scene* scene);
}; };
/** @brief TransitionTurnOffTiles: /** @brief TransitionTurnOffTiles:
@ -462,16 +509,19 @@ Turn off the tiles of the outgoing scene in random order
class CC_DLL TransitionTurnOffTiles : public TransitionScene ,public TransitionEaseScene class CC_DLL TransitionTurnOffTiles : public TransitionScene ,public TransitionEaseScene
{ {
public : public :
static TransitionTurnOffTiles* create(float t, Scene* scene);
TransitionTurnOffTiles(); TransitionTurnOffTiles();
virtual ~TransitionTurnOffTiles(); virtual ~TransitionTurnOffTiles();
virtual void onEnter(); //
virtual ActionInterval * easeActionWithAction(ActionInterval * action); // Overrides
//
virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
public:
static TransitionTurnOffTiles* create(float t, Scene* scene);
protected: protected:
virtual void sceneOrder(); virtual void sceneOrder() override;
}; };
/** @brief TransitionSplitCols: /** @brief TransitionSplitCols:
@ -480,16 +530,18 @@ The odd columns goes upwards while the even columns goes downwards.
class CC_DLL TransitionSplitCols : public TransitionScene , public TransitionEaseScene class CC_DLL TransitionSplitCols : public TransitionScene , public TransitionEaseScene
{ {
public: public:
static TransitionSplitCols* create(float t, Scene* scene);
TransitionSplitCols(); TransitionSplitCols();
virtual ~TransitionSplitCols(); virtual ~TransitionSplitCols();
virtual ActionInterval* action(void); virtual ActionInterval* action(void);
virtual void onEnter();
virtual ActionInterval * easeActionWithAction(ActionInterval * action);
public: //
// Overrides
static TransitionSplitCols* create(float t, Scene* scene); //
virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
}; };
/** @brief TransitionSplitRows: /** @brief TransitionSplitRows:
@ -498,14 +550,15 @@ The odd rows goes to the left while the even rows goes to the right.
class CC_DLL TransitionSplitRows : public TransitionSplitCols class CC_DLL TransitionSplitRows : public TransitionSplitCols
{ {
public: public:
static TransitionSplitRows* create(float t, Scene* scene);
TransitionSplitRows(); TransitionSplitRows();
virtual ~TransitionSplitRows(); virtual ~TransitionSplitRows();
virtual ActionInterval* action(void); //
// Overrides
public: //
virtual ActionInterval* action(void) override;
static TransitionSplitRows* create(float t, Scene* scene);
}; };
/** @brief TransitionFadeTR: /** @brief TransitionFadeTR:
@ -514,15 +567,18 @@ Fade the tiles of the outgoing scene from the left-bottom corner the to top-righ
class CC_DLL TransitionFadeTR : public TransitionScene , public TransitionEaseScene class CC_DLL TransitionFadeTR : public TransitionScene , public TransitionEaseScene
{ {
public: public:
static TransitionFadeTR* create(float t, Scene* scene);
TransitionFadeTR(); TransitionFadeTR();
virtual ~TransitionFadeTR(); virtual ~TransitionFadeTR();
virtual ActionInterval* actionWithSize(const Size& size); virtual ActionInterval* actionWithSize(const Size& size);
virtual void onEnter();
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
public: //
// Overrides
//
virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
static TransitionFadeTR* create(float t, Scene* scene);
protected: protected:
virtual void sceneOrder(); virtual void sceneOrder();
}; };
@ -533,13 +589,16 @@ Fade the tiles of the outgoing scene from the top-right corner to the bottom-lef
class CC_DLL TransitionFadeBL : public TransitionFadeTR class CC_DLL TransitionFadeBL : public TransitionFadeTR
{ {
public: public:
static TransitionFadeBL* create(float t, Scene* scene);
TransitionFadeBL(); TransitionFadeBL();
virtual ~TransitionFadeBL(); virtual ~TransitionFadeBL();
virtual ActionInterval* actionWithSize(const Size& size);
public: //
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
static TransitionFadeBL* create(float t, Scene* scene);
}; };
/** @brief TransitionFadeUp: /** @brief TransitionFadeUp:
@ -548,13 +607,15 @@ public:
class CC_DLL TransitionFadeUp : public TransitionFadeTR class CC_DLL TransitionFadeUp : public TransitionFadeTR
{ {
public: public:
static TransitionFadeUp* create(float t, Scene* scene);
TransitionFadeUp(); TransitionFadeUp();
virtual ~TransitionFadeUp(); virtual ~TransitionFadeUp();
virtual ActionInterval* actionWithSize(const Size& size);
public: //
// Overrides
static TransitionFadeUp* create(float t, Scene* scene); //
virtual ActionInterval* actionWithSize(const Size& size) override;
}; };
/** @brief TransitionFadeDown: /** @brief TransitionFadeDown:
@ -563,13 +624,15 @@ public:
class CC_DLL TransitionFadeDown : public TransitionFadeTR class CC_DLL TransitionFadeDown : public TransitionFadeTR
{ {
public: public:
static TransitionFadeDown* create(float t, Scene* scene);
TransitionFadeDown(); TransitionFadeDown();
virtual ~TransitionFadeDown(); virtual ~TransitionFadeDown();
virtual ActionInterval* actionWithSize(const Size& size);
public: //
// Overrides
static TransitionFadeDown* create(float t, Scene* scene); //
virtual ActionInterval* actionWithSize(const Size& size) override;
}; };
// end of transition group // end of transition group

View File

@ -92,7 +92,7 @@ void TransitionPageTurn::onEnter()
Sequence::create Sequence::create
( (
action, action,
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
StopGrid::create(), StopGrid::create(),
NULL NULL
) )
@ -108,7 +108,7 @@ void TransitionPageTurn::onEnter()
( (
Show::create(), Show::create(),
action, action,
CallFunc::create(this, callfunc_selector(TransitionScene::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
StopGrid::create(), StopGrid::create(),
NULL NULL
) )

View File

@ -48,20 +48,17 @@ is turned on in Director using:
*/ */
class CC_DLL TransitionPageTurn : public TransitionScene class CC_DLL TransitionPageTurn : public TransitionScene
{ {
protected:
bool _back;
public: public:
/**
* Creates a base transition with duration and incoming scene.
* If back is true then the effect is reversed to appear as if the incoming
* scene is being turned from left over the outgoing scene.
*/
static TransitionPageTurn* create(float t,Scene* scene,bool backwards);
TransitionPageTurn(); TransitionPageTurn();
virtual ~TransitionPageTurn(); virtual ~TransitionPageTurn();
/**
* Creates a base transition with duration and incoming scene.
* If back is true then the effect is reversed to appear as if the incoming
* scene is being turned from left over the outgoing scene.
*/
static TransitionPageTurn* create(float t,Scene* scene,bool backwards);
/** /**
* Creates a base transition with duration and incoming scene. * Creates a base transition with duration and incoming scene.
* If back is true then the effect is reversed to appear as if the incoming * If back is true then the effect is reversed to appear as if the incoming
@ -71,10 +68,17 @@ public:
ActionInterval* actionWithSize(const Size& vector); ActionInterval* actionWithSize(const Size& vector);
virtual void onEnter(); //
// Overrides
//
virtual void onEnter() override;
protected: protected:
virtual void sceneOrder(); virtual void sceneOrder() override;
protected:
bool _back;
}; };
// end of transition group // end of transition group

View File

@ -94,7 +94,7 @@ void TransitionProgress::onEnter()
// create the blend action // create the blend action
ActionInterval* layerAction = (ActionInterval*)Sequence::create( ActionInterval* layerAction = (ActionInterval*)Sequence::create(
ProgressFromTo::create(_duration, _from, _to), ProgressFromTo::create(_duration, _from, _to),
CallFunc::create(this, callfunc_selector(TransitionProgress::finish)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
NULL); NULL);
// run the blend action // run the blend action
pNode->runAction(layerAction); pNode->runAction(layerAction);

View File

@ -38,19 +38,27 @@ class RenderTexture;
* @addtogroup transition * @addtogroup transition
* @{ * @{
*/ */
class CC_DLL TransitionProgress : public TransitionScene class CC_DLL TransitionProgress : public TransitionScene
{ {
public: public:
static TransitionProgress* create(float t, Scene* scene); static TransitionProgress* create(float t, Scene* scene);
TransitionProgress(); TransitionProgress();
virtual void onEnter();
virtual void onExit(); //
// Overrides
//
virtual void onEnter() override;
virtual void onExit() override;
protected:
virtual void sceneOrder() override;
protected: protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture); virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture);
virtual void setupTransition(); virtual void setupTransition();
virtual void sceneOrder();
protected:
float _to; float _to;
float _from; float _from;
Scene* _sceneToBeModified; Scene* _sceneToBeModified;
@ -64,8 +72,12 @@ class CC_DLL TransitionProgressRadialCCW : public TransitionProgress
{ {
public: public:
static TransitionProgressRadialCCW* create(float t, Scene* scene); static TransitionProgressRadialCCW* create(float t, Scene* scene);
protected: protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture); //
// Overrides
//
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
}; };
@ -77,8 +89,12 @@ class CC_DLL TransitionProgressRadialCW : public TransitionProgress
{ {
public: public:
static TransitionProgressRadialCW* create(float t, Scene* scene); static TransitionProgressRadialCW* create(float t, Scene* scene);
protected: protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture); //
// Overrides
//
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
}; };
@ -88,41 +104,51 @@ protected:
class CC_DLL TransitionProgressHorizontal : public TransitionProgress class CC_DLL TransitionProgressHorizontal : public TransitionProgress
{ {
public: public:
static TransitionProgressHorizontal* create(float t, Scene* scene); static TransitionProgressHorizontal* create(float t, Scene* scene);
protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture);
protected:
//
// Overrides
//
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
}; };
class CC_DLL TransitionProgressVertical : public TransitionProgress class CC_DLL TransitionProgressVertical : public TransitionProgress
{ {
public: public:
static TransitionProgressVertical* create(float t, Scene* scene); static TransitionProgressVertical* create(float t, Scene* scene);
protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture);
protected:
//
// Overrides
//
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
}; };
class CC_DLL TransitionProgressInOut : public TransitionProgress class CC_DLL TransitionProgressInOut : public TransitionProgress
{ {
public: public:
static TransitionProgressInOut* create(float t, Scene* scene); static TransitionProgressInOut* create(float t, Scene* scene);
protected: protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture); //
virtual void sceneOrder(); // Overrides
virtual void setupTransition(); //
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
virtual void sceneOrder() override;
virtual void setupTransition() override;
}; };
class CC_DLL TransitionProgressOutIn : public TransitionProgress class CC_DLL TransitionProgressOutIn : public TransitionProgress
{ {
public: public:
static TransitionProgressOutIn* create(float t, Scene* scene); static TransitionProgressOutIn* create(float t, Scene* scene);
protected: protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture); //
// Overrides
//
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
}; };

View File

@ -258,51 +258,7 @@ public:
virtual bool initWithFile(const char *pszFilename, const Rect& rect); virtual bool initWithFile(const char *pszFilename, const Rect& rect);
/// @} end of initializers /// @} end of initializers
/// @{
/// @name Functions inherited from TextureProtocol
virtual void setTexture(Texture2D *texture);
virtual Texture2D* getTexture(void);
inline void setBlendFunc(const BlendFunc &blendFunc) { _blendFunc = blendFunc; }
inline const BlendFunc& getBlendFunc(void) const { return _blendFunc; }
/// @}
/// @{
/// @name Functions inherited from Node
virtual void setScaleX(float fScaleX);
virtual void setScaleY(float fScaleY);
virtual void setPosition(const Point& pos);
virtual void setRotation(float fRotation);
virtual void setRotationX(float fRotationX);
virtual void setRotationY(float fRotationY);
virtual void setSkewX(float sx);
virtual void setSkewY(float sy);
virtual void removeChild(Node* pChild, bool bCleanup);
virtual void removeAllChildrenWithCleanup(bool bCleanup);
virtual void reorderChild(Node *pChild, int zOrder);
virtual void addChild(Node *pChild);
virtual void addChild(Node *pChild, int zOrder);
virtual void addChild(Node *pChild, int zOrder, int tag);
virtual void sortAllChildren();
virtual void setScale(float fScale);
virtual void setVertexZ(float fVertexZ);
virtual void setAnchorPoint(const Point& anchor);
virtual void ignoreAnchorPointForPosition(bool value);
virtual void setVisible(bool bVisible);
virtual void draw(void);
/// @}
/// @{
/// @name Functions inherited from NodeRGBA
virtual void setColor(const Color3B& color3);
virtual void updateDisplayedColor(const Color3B& parentColor);
virtual void setOpacity(GLubyte opacity);
virtual void setOpacityModifyRGB(bool modify);
virtual bool isOpacityModifyRGB(void) const;
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
/// @}
/// @{ /// @{
/// @name BatchNode methods /// @name BatchNode methods
@ -486,7 +442,54 @@ public:
void setFlipY(bool bFlipY); void setFlipY(bool bFlipY);
/// @} End of Sprite properties getter/setters /// @} End of Sprite properties getter/setters
//
// Overrides
//
/// @{
/// @name Functions inherited from TextureProtocol
virtual void setTexture(Texture2D *texture) override;
virtual Texture2D* getTexture(void) override;
inline void setBlendFunc(const BlendFunc &blendFunc) override { _blendFunc = blendFunc; }
inline const BlendFunc& getBlendFunc(void) const override { return _blendFunc; }
/// @}
/// @{
/// @name Functions inherited from Node
virtual void setScaleX(float fScaleX) override;
virtual void setScaleY(float fScaleY) override;
virtual void setPosition(const Point& pos) override;
virtual void setRotation(float fRotation) override;
virtual void setRotationX(float fRotationX) override;
virtual void setRotationY(float fRotationY) override;
virtual void setSkewX(float sx) override;
virtual void setSkewY(float sy) override;
virtual void removeChild(Node* pChild, bool bCleanup) override;
virtual void removeAllChildrenWithCleanup(bool bCleanup) override;
virtual void reorderChild(Node *pChild, int zOrder) override;
virtual void addChild(Node *pChild) override;
virtual void addChild(Node *pChild, int zOrder) override;
virtual void addChild(Node *pChild, int zOrder, int tag) override;
virtual void sortAllChildren() override;
virtual void setScale(float fScale) override;
virtual void setVertexZ(float fVertexZ) override;
virtual void setAnchorPoint(const Point& anchor) override;
virtual void ignoreAnchorPointForPosition(bool value) override;
virtual void setVisible(bool bVisible) override;
virtual void draw(void) override;
/// @}
/// @{
/// @name Functions inherited from NodeRGBA
virtual void setColor(const Color3B& color3) override;
virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual void setOpacity(GLubyte opacity) override;
virtual void setOpacityModifyRGB(bool modify) override;
virtual bool isOpacityModifyRGB(void) const override;
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
/// @}
protected: protected:
void updateColor(void); void updateColor(void);
virtual void setTextureCoords(Rect rect); virtual void setTextureCoords(Rect rect);

View File

@ -128,22 +128,26 @@ public:
unsigned int atlasIndexForChild(Sprite *sprite, int z); unsigned int atlasIndexForChild(Sprite *sprite, int z);
/* Sprites use this to start sortChildren, don't call this manually */ /* Sprites use this to start sortChildren, don't call this manually */
void reorderBatch(bool reorder); void reorderBatch(bool reorder);
// TextureProtocol
virtual Texture2D* getTexture(void);
virtual void setTexture(Texture2D *texture);
virtual void setBlendFunc(const BlendFunc &blendFunc);
virtual const BlendFunc& getBlendFunc(void) const;
virtual void visit(void); //
virtual void addChild(Node * child); // Overrides
virtual void addChild(Node * child, int zOrder); //
virtual void addChild(Node * child, int zOrder, int tag); // TextureProtocol
virtual void reorderChild(Node * child, int zOrder); virtual Texture2D* getTexture(void) override;
virtual void setTexture(Texture2D *texture) override;
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
virtual const BlendFunc& getBlendFunc(void) const override;
virtual void visit(void) override;
virtual void addChild(Node * child) override;
virtual void addChild(Node * child, int zOrder) override;
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void reorderChild(Node * child, int zOrder) override;
virtual void removeChild(Node* child, bool cleanup); virtual void removeChild(Node* child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup); virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void sortAllChildren(); virtual void sortAllChildren() override;
virtual void draw(void); virtual void draw(void) override;
protected: protected:
/** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array. /** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.

View File

@ -101,6 +101,41 @@ class CC_DLL Texture2D : public Object
, public GLBufferedNode , public GLBufferedNode
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
{ {
public:
/** sets the default pixel format for UIImagescontains alpha channel.
If the UIImage contains alpha channel, then the options are:
- generate 32-bit textures: kTexture2DPixelFormat_RGBA8888 (default one)
- generate 24-bit textures: kTexture2DPixelFormat_RGB888
- generate 16-bit textures: kTexture2DPixelFormat_RGBA4444
- generate 16-bit textures: kTexture2DPixelFormat_RGB5A1
- generate 16-bit textures: kTexture2DPixelFormat_RGB565
- generate 8-bit textures: kTexture2DPixelFormat_A8 (only use it if you use just 1 color)
How does it work ?
- If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture)
- If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used.
This parameter is not valid for PVR / PVR.CCZ images.
@since v0.8
*/
static void setDefaultAlphaPixelFormat(Texture2DPixelFormat format);
/** returns the alpha pixel format
@since v0.8
*/
static Texture2DPixelFormat defaultAlphaPixelFormat();
/** treats (or not) PVR files as if they have alpha premultiplied.
Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
possible load them as if they have (or not) the alpha channel premultiplied.
By default it is disabled.
@since v0.99.5
*/
static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
public: public:
Texture2D(); Texture2D();
virtual ~Texture2D(); virtual ~Texture2D();
@ -195,45 +230,12 @@ public:
*/ */
unsigned int bitsPerPixelForFormat(Texture2DPixelFormat format) const; unsigned int bitsPerPixelForFormat(Texture2DPixelFormat format) const;
/** sets the default pixel format for UIImagescontains alpha channel.
If the UIImage contains alpha channel, then the options are:
- generate 32-bit textures: kTexture2DPixelFormat_RGBA8888 (default one)
- generate 24-bit textures: kTexture2DPixelFormat_RGB888
- generate 16-bit textures: kTexture2DPixelFormat_RGBA4444
- generate 16-bit textures: kTexture2DPixelFormat_RGB5A1
- generate 16-bit textures: kTexture2DPixelFormat_RGB565
- generate 8-bit textures: kTexture2DPixelFormat_A8 (only use it if you use just 1 color)
How does it work ?
- If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture)
- If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used.
This parameter is not valid for PVR / PVR.CCZ images.
@since v0.8
*/
static void setDefaultAlphaPixelFormat(Texture2DPixelFormat format);
/** returns the alpha pixel format
@since v0.8
*/
static Texture2DPixelFormat defaultAlphaPixelFormat();
/** treats (or not) PVR files as if they have alpha premultiplied.
Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
possible load them as if they have (or not) the alpha channel premultiplied.
By default it is disabled.
@since v0.99.5
*/
static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
/** content size */ /** content size */
const Size& getContentSizeInPixels(); const Size& getContentSizeInPixels();
bool hasPremultipliedAlpha() const; bool hasPremultipliedAlpha() const;
bool hasMipmaps() const; bool hasMipmaps() const;
private: private:
bool initPremultipliedATextureWithImage(Image * image, unsigned int pixelsWide, unsigned int pixelsHigh); bool initPremultipliedATextureWithImage(Image * image, unsigned int pixelsWide, unsigned int pixelsHigh);

View File

@ -58,14 +58,6 @@ NS_CC_BEGIN
class CC_DLL TextureCache : public Object class CC_DLL TextureCache : public Object
{ {
public: public:
TextureCache();
virtual ~TextureCache();
const char* description(void) const;
Dictionary* snapshotTextures();
/** Returns the shared instance of the cache */ /** Returns the shared instance of the cache */
static TextureCache * getInstance(); static TextureCache * getInstance();
@ -80,6 +72,19 @@ public:
/** @deprecated Use destroyInstance() instead */ /** @deprecated Use destroyInstance() instead */
CC_DEPRECATED_ATTRIBUTE static void purgeSharedTextureCache(); CC_DEPRECATED_ATTRIBUTE static void purgeSharedTextureCache();
/** Reload all textures
It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1
*/
static void reloadAllTextures();
public:
TextureCache();
virtual ~TextureCache();
const char* description(void) const;
Dictionary* snapshotTextures();
/** Returns a Texture2D object given an file image /** Returns a Texture2D object given an file image
* If the file image was not previously loaded, it will create a new Texture2D * If the file image was not previously loaded, it will create a new Texture2D
* object and it will return it. It will use the filename as a key. * object and it will return it. It will use the filename as a key.
@ -153,11 +158,6 @@ public:
*/ */
Texture2D* addETCImage(const char* filename); Texture2D* addETCImage(const char* filename);
/** Reload all textures
It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1
*/
static void reloadAllTextures();
private: private:
void addImageAsyncCallBack(float dt); void addImageAsyncCallBack(float dt);
void loadImage(); void loadImage();
@ -206,13 +206,13 @@ protected:
class VolatileTexture class VolatileTexture
{ {
typedef enum { typedef enum {
kInvalid = 0, kInvalid = 0,
kImageFile, kImageFile,
kImageData, kImageData,
kString, kString,
kImage, kImage,
}ccCachedImageType; }ccCachedImageType;
public: public:
VolatileTexture(Texture2D *t); VolatileTexture(Texture2D *t);

View File

@ -148,15 +148,20 @@ public:
/** Creates the tiles */ /** Creates the tiles */
void setupTiles(); void setupTiles();
/** TMXLayer doesn't support adding a Sprite manually.
@warning addchild(z, tag); is not supported on TMXLayer. Instead of setTileGID.
*/
virtual void addChild(Node * child, int zOrder, int tag);
// super method
void removeChild(Node* child, bool cleanup);
inline const char* getLayerName(){ return _layerName.c_str(); } inline const char* getLayerName(){ return _layerName.c_str(); }
inline void setLayerName(const char *layerName){ _layerName = layerName; } inline void setLayerName(const char *layerName){ _layerName = layerName; }
//
// Override
//
/** TMXLayer doesn't support adding a Sprite manually.
@warning addchild(z, tag); is not supported on TMXLayer. Instead of setTileGID.
*/
virtual void addChild(Node * child, int zOrder, int tag) override;
// super method
void removeChild(Node* child, bool cleanup) override;
private: private:
Point positionForIsoAt(const Point& pos); Point positionForIsoAt(const Point& pos);
Point positionForOrthoAt(const Point& pos); Point positionForOrthoAt(const Point& pos);

View File

@ -789,7 +789,7 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl
// Make callback at end of sequence // Make callback at end of sequence
CCBSequence *seq = getSequence(nSeqId); CCBSequence *seq = getSequence(nSeqId);
Action *completeAction = Sequence::createWithTwoActions(DelayTime::create(seq->getDuration() + fTweenDuration), Action *completeAction = Sequence::createWithTwoActions(DelayTime::create(seq->getDuration() + fTweenDuration),
CallFunc::create(this, callfunc_selector(CCBAnimationManager::sequenceCompleted))); CallFunc::create( CC_CALLBACK_0(CCBAnimationManager::sequenceCompleted,this)));
mRootNode->runAction(completeAction); mRootNode->runAction(completeAction);
// Set the running scene // Set the running scene

View File

@ -218,7 +218,7 @@ void ScrollView::setContentOffsetInDuration(Point offset, float dt)
FiniteTimeAction *scroll, *expire; FiniteTimeAction *scroll, *expire;
scroll = MoveTo::create(dt, offset); scroll = MoveTo::create(dt, offset);
expire = CallFuncN::create(this, callfuncN_selector(ScrollView::stoppedAnimatedScroll)); expire = CallFuncN::create(CC_CALLBACK_1(ScrollView::stoppedAnimatedScroll,this));
_container->runAction(Sequence::create(scroll, expire, NULL)); _container->runAction(Sequence::create(scroll, expire, NULL));
this->schedule(schedule_selector(ScrollView::performedAnimatedScroll)); this->schedule(schedule_selector(ScrollView::performedAnimatedScroll));
} }

View File

@ -67,8 +67,7 @@ bool GameOverLayer::init()
this->runAction( Sequence::create( this->runAction( Sequence::create(
DelayTime::create(3), DelayTime::create(3),
CallFunc::create(this, CallFunc::create( CC_CALLBACK_0(GameOverLayer::gameOverDone, this)),
callfunc_selector(GameOverLayer::gameOverDone)),
NULL)); NULL));
return true; return true;

View File

@ -153,8 +153,7 @@ void HelloWorld::addTarget()
// Create the actions // Create the actions
FiniteTimeAction* actionMove = MoveTo::create( (float)actualDuration, FiniteTimeAction* actionMove = MoveTo::create( (float)actualDuration,
Point(0 - target->getContentSize().width/2, actualY) ); Point(0 - target->getContentSize().width/2, actualY) );
FiniteTimeAction* actionMoveDone = CallFuncN::create( this, FiniteTimeAction* actionMoveDone = CallFuncN::create( CC_CALLBACK_1(HelloWorld::spriteMoveFinished, this));
callfuncN_selector(HelloWorld::spriteMoveFinished));
target->runAction( Sequence::create(actionMove, actionMoveDone, NULL) ); target->runAction( Sequence::create(actionMove, actionMoveDone, NULL) );
// Add to targets array // Add to targets array
@ -228,9 +227,8 @@ void HelloWorld::ccTouchesEnded(Set* touches, Event* event)
// Move projectile to actual endpoint // Move projectile to actual endpoint
projectile->runAction( Sequence::create( projectile->runAction( Sequence::create(
MoveTo::create(realMoveDuration, realDest), MoveTo::create(realMoveDuration, realDest),
CallFuncN::create(this, CallFuncN::create(CC_CALLBACK_1(HelloWorld::spriteMoveFinished, this)),
callfuncN_selector(HelloWorld::spriteMoveFinished)), NULL) );
NULL) );
// Add to projectiles array // Add to projectiles array
projectile->setTag(2); projectile->setTag(2);

View File

@ -132,7 +132,7 @@ void CrashTest::onEnter()
//After 1.5 second, self will be removed. //After 1.5 second, self will be removed.
runAction( Sequence::create( runAction( Sequence::create(
DelayTime::create(1.4f), DelayTime::create(1.4f),
CallFunc::create(this, callfunc_selector(CrashTest::removeThis)), CallFunc::create( CC_CALLBACK_0(CrashTest::removeThis,this)),
NULL) NULL)
); );
} }
@ -164,7 +164,7 @@ void LogicTest::onEnter()
grossini->runAction( Sequence::create( grossini->runAction( Sequence::create(
MoveBy::create(1, Point(150,0)), MoveBy::create(1, Point(150,0)),
CallFuncN::create(this, callfuncN_selector(LogicTest::bugMe)), CallFuncN::create(CC_CALLBACK_1(LogicTest::bugMe,this)),
NULL) NULL)
); );
} }
@ -242,7 +242,7 @@ void RemoveTest::onEnter()
l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75) ); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75) );
MoveBy* pMove = MoveBy::create(2, Point(200, 0)); MoveBy* pMove = MoveBy::create(2, Point(200, 0));
CallFunc* pCallback = CallFunc::create(this, callfunc_selector(RemoveTest::stopAction)); CallFunc* pCallback = CallFunc::create(CC_CALLBACK_0(RemoveTest::stopAction,this));
ActionInterval* pSequence = Sequence::create(pMove, pCallback, NULL); ActionInterval* pSequence = Sequence::create(pMove, pCallback, NULL);
pSequence->setTag(kTagSequence); pSequence->setTag(kTagSequence);

View File

@ -384,14 +384,14 @@ void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType mo
{ {
ActionInterval *actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y)); ActionInterval *actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y));
armature->stopAllActions(); armature->stopAllActions();
armature->runAction(Sequence::create(actionToRight, CallFunc::create(this, callfunc_selector(TestAnimationEvent::callback1)), NULL)); armature->runAction(Sequence::create(actionToRight, CallFunc::create(CC_CALLBACK_0(TestAnimationEvent::callback1,this)), NULL));
armature->getAnimation()->play("Walk"); armature->getAnimation()->play("Walk");
} }
else if (id.compare("FireMax") == 0) else if (id.compare("FireMax") == 0)
{ {
ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y)); ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y));
armature->stopAllActions(); armature->stopAllActions();
armature->runAction(Sequence::create(actionToLeft, CallFunc::create(this, callfunc_selector(TestAnimationEvent::callback2)), NULL)); armature->runAction(Sequence::create(actionToLeft, CallFunc::create(CC_CALLBACK_0(TestAnimationEvent::callback2,this)), NULL));
armature->getAnimation()->play("Walk"); armature->getAnimation()->play("Walk");
} }
} }

View File

@ -68,8 +68,7 @@ bool GameOverLayer::init()
this->runAction( Sequence::create( this->runAction( Sequence::create(
DelayTime::create(3), DelayTime::create(3),
CallFunc::create(this, CallFunc::create(CC_CALLBACK_0(GameOverLayer::gameOverDone, this)),
callfunc_selector(GameOverLayer::gameOverDone)),
NULL)); NULL));

View File

@ -303,7 +303,7 @@ LabelAtlasColorTest::LabelAtlasColorTest()
ActionInterval* fade = FadeOut::create(1.0f); ActionInterval* fade = FadeOut::create(1.0f);
ActionInterval* fade_in = fade->reverse(); ActionInterval* fade_in = fade->reverse();
CallFunc* cb = CallFunc::create(this, callfunc_selector(LabelAtlasColorTest::actionFinishCallback)); CallFunc* cb = CallFunc::create(CC_CALLBACK_0(LabelAtlasColorTest::actionFinishCallback, this));
Sequence* seq = Sequence::create(fade, fade_in, cb, NULL); Sequence* seq = Sequence::create(fade, fade_in, cb, NULL);
Action* repeat = RepeatForever::create( seq ); Action* repeat = RepeatForever::create( seq );
label2->runAction( repeat ); label2->runAction( repeat );

View File

@ -368,7 +368,7 @@ void StressTest1::shouldNotCrash(float dt)
runAction( Sequence::create( runAction( Sequence::create(
RotateBy::create(2, 360), RotateBy::create(2, 360),
CallFuncN::create(this, callfuncN_selector(StressTest1::removeMe)), CallFuncN::create(CC_CALLBACK_1(StressTest1::removeMe, this)),
NULL) ); NULL) );
addChild(explosion); addChild(explosion);

View File

@ -391,7 +391,7 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * pSender, const
ScaleTo::create(duration, 1), ScaleTo::create(duration, 1),
FadeOut::create(duration), FadeOut::create(duration),
0), 0),
CallFuncN::create(this, callfuncN_selector(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction)), CallFuncN::create(CC_CALLBACK_1(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction, this)),
0); 0);
label->runAction(seq); label->runAction(seq);
return false; return false;
@ -425,7 +425,7 @@ bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * pSender, c
repeatTime), repeatTime),
FadeOut::create(duration), FadeOut::create(duration),
0), 0),
CallFuncN::create(this, callfuncN_selector(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction)), CallFuncN::create(CC_CALLBACK_1(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction, this)),
0); 0);
label->runAction(seq); label->runAction(seq);
return false; return false;

View File

@ -338,7 +338,7 @@ TMXReadWriteTest::TMXReadWriteTest()
ActionInterval* opacity = FadeOut::create(2); ActionInterval* opacity = FadeOut::create(2);
ActionInterval* fadein = FadeIn::create(2); ActionInterval* fadein = FadeIn::create(2);
ActionInterval* scaleback = ScaleTo::create(1, 1); ActionInterval* scaleback = ScaleTo::create(1, 1);
ActionInstant* finish = CallFuncN::create(this, callfuncN_selector(TMXReadWriteTest::removeSprite)); ActionInstant* finish = CallFuncN::create(CC_CALLBACK_1(TMXReadWriteTest::removeSprite, this));
Sequence* seq0 = Sequence::create(move, rotate, scale, opacity, fadein, scaleback, finish, NULL); Sequence* seq0 = Sequence::create(move, rotate, scale, opacity, fadein, scaleback, finish, NULL);
ActionInterval* seq1 = seq0->clone(); ActionInterval* seq1 = seq0->clone();
ActionInterval* seq2 = seq0->clone(); ActionInterval* seq2 = seq0->clone();

View File

@ -583,7 +583,7 @@ JSBool ScriptingCore::log(JSContext* cx, uint32_t argc, jsval *vp)
JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string);
if (string) { if (string) {
JSStringWrapper wrapper(string); JSStringWrapper wrapper(string);
js_log((char *)wrapper); js_log("%s", (char *)wrapper);
} }
} }
return JS_TRUE; return JS_TRUE;

View File

@ -1 +1 @@
892bd065cf79b195f59b92dee3e4f4ea9acdf461 1bc7b8568392f87fc5a60148cce14376b8e1a569

@ -1 +1 @@
Subproject commit ca1f04e9a8386da1d6c768dcbb1647c02c4c506e Subproject commit 47d7b831bedde49e53d8daf8e619eea7932b2b79