Merge pull request #3157 from ricardoquesada/override_love

closed 2407: Adds more readability to the class internals.
This commit is contained in:
James Chen 2013-07-15 22:05:33 -07:00
commit 13e939b55e
33 changed files with 1057 additions and 998 deletions

View File

@ -63,22 +63,10 @@ using the camera.
*/
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:
/** returns the Z eye */
static float getZEye();
Camera(void);
~Camera(void);
@ -108,10 +96,22 @@ public:
void getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ) const;
/** get the up vector values */
void getUpXYZ(float *pUpX, float *pUpY, float *pUpZ) const;
public:
/** returns the Z eye */
static float getZEye();
protected:
float _eyeX;
float _eyeY;
float _eyeZ;
float _centerX;
float _centerY;
float _centerZ;
float _upX;
float _upY;
float _upZ;
bool _dirty;
kmMat4 _lookupMatrix;
private:
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
{
public:
/** returns a shared instance of the director */
static Director* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector(void);
Director(void);
virtual ~Director(void);
virtual bool init(void);
@ -344,16 +350,8 @@ public:
/* delta time since last tick to main loop */
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:
void purgeDirector();
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 */
void calculateDeltaTime();
protected:
/* The EGLView, where everything is rendered */
EGLView *_openGLView;
@ -449,10 +448,13 @@ public:
: _invalid(false)
{}
virtual void mainLoop(void);
virtual void setAnimationInterval(double dValue);
virtual void startAnimation(void);
virtual void stopAnimation();
//
// Overrides
//
virtual void mainLoop(void) override;
virtual void setAnimationInterval(double dValue) override;
virtual void startAnimation(void) override;
virtual void stopAnimation() override;
protected:
bool _invalid;

View File

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

View File

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

View File

@ -49,14 +49,17 @@ public:
/** initializes the action */
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();
//
// 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:
/** The inner action */
ActionInterval *_inner;
@ -71,16 +74,19 @@ class CC_DLL EaseRateAction : public ActionEase
public:
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 */
inline void setRate(float rate) { _rate = rate; }
/** get rate value for the actions */
inline float getRate(void) const { return _rate; }
/** Initializes the action with the inner action and the rate parameter */
bool initWithAction(ActionInterval *pAction, float fRate);
virtual EaseRateAction* clone() const = 0;
virtual EaseRateAction* reverse() const = 0;
//
// Overrides
//
virtual EaseRateAction* clone() const override = 0;
virtual EaseRateAction* reverse() const override = 0;
protected:
float _rate;
@ -93,17 +99,13 @@ protected:
class CC_DLL EaseIn : public EaseRateAction
{
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 */
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
{
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 */
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
{
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 */
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
{
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:
/** creates the action */
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
{
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:
/** creates the action */
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
{
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 */
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
{
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:
/** creates the action */
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
{
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 */
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
{
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 */
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
{
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 */
inline float getPeriod(void) const { return _period; }
/** set period of the wave in radians. */
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);
/** returns a new clone of the action */
virtual EaseElastic* clone() const = 0;
/** returns a new reversed action */
virtual EaseElastic* reverse() const = 0;
//
// Overrides
//
virtual EaseElastic* clone() const override = 0;
virtual EaseElastic* reverse() const override = 0;
protected:
float _period;
@ -288,17 +271,14 @@ protected:
class CC_DLL EaseElasticIn : public EaseElastic
{
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) */
static EaseElasticIn* create(ActionInterval *pAction, float fPeriod);
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
{
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) */
static EaseElasticOut* create(ActionInterval *pAction, float fPeriod);
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
{
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) */
static EaseElasticInOut* create(ActionInterval *pAction, float fPeriod);
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:
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
{
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 */
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
{
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 */
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
{
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 */
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
{
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 */
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
{
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 */
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
{
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 */
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

View File

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

View File

@ -67,22 +67,20 @@ public:
/** initializes the action */
bool initWithDuration(float d);
/** returns true if the action has finished */
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
//extension in GridAction
void setAmplitudeRate(float amp);
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:
float _elapsed;
bool _firstTick;
@ -93,23 +91,6 @@ protected:
class CC_DLL Sequence : public ActionInterval
{
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 */
static Sequence* create(FiniteTimeAction *pAction1, ...);
/** helper constructor to create an array of sequenceable actions given an array */
@ -119,6 +100,20 @@ public:
/** creates the action */
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:
FiniteTimeAction *_actions[2];
float _split;
@ -131,22 +126,14 @@ protected:
class CC_DLL Repeat : public ActionInterval
{
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) */
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)
{
if (_innerAction != pAction)
@ -162,10 +149,16 @@ public:
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:
unsigned int _times;
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
{
public:
/** creates the action */
static RepeatForever* create(ActionInterval *pAction);
RepeatForever()
: _innerAction(NULL)
{}
@ -190,16 +186,6 @@ public:
/** initializes the action */
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)
{
if (_innerAction != pAction)
@ -215,10 +201,15 @@ public:
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:
/** Inner action */
ActionInterval *_innerAction;
@ -229,26 +220,9 @@ protected:
class CC_DLL Spawn : public ActionInterval
{
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 */
static Spawn* create(FiniteTimeAction *pAction1, ...);
/** helper constructor to create an array of spawned actions */
static Spawn* createWithVariableList(FiniteTimeAction *pAction1, va_list args);
@ -258,6 +232,20 @@ public:
/** creates the Spawn action */
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:
FiniteTimeAction *_one;
FiniteTimeAction *_two;
@ -270,23 +258,23 @@ protected:
class CC_DLL RotateTo : public ActionInterval
{
public:
/** creates the action with separate rotation angles */
static RotateTo* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
/** creates the action */
static RotateTo* create(float fDuration, float fDeltaAngle);
/** initializes the action */
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);
/** returns a new clone of the action */
virtual RotateTo* clone() const;
/** returns a new reversed action */
virtual RotateTo* reverse() const;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
//
// Overrides
//
virtual RotateTo* clone() const override;
virtual RotateTo* reverse() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
protected:
float _dstAngleX;
@ -305,21 +293,20 @@ class CC_DLL RotateBy : public ActionInterval
public:
/** creates the action */
static RotateBy* create(float fDuration, float fDeltaAngle);
/** initializes the action */
bool initWithDuration(float fDuration, float fDeltaAngle);
static RotateBy* create(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;
/** returns a new reversed action */
virtual RotateBy* reverse(void) const;
virtual void startWithTarget(Node *pTarget);
virtual void update(float time);
//
// Override
//
virtual RotateBy* clone() const override;
virtual RotateBy* reverse(void) const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void update(float time) override;
protected:
float _angleX;
@ -337,22 +324,20 @@ protected:
class CC_DLL MoveBy : public ActionInterval
{
public:
/** creates the action */
static MoveBy* create(float duration, const Point& deltaPosition);
/** initializes the action */
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:
Point _positionDelta;
Point _startPosition;
@ -367,17 +352,18 @@ protected:
class CC_DLL MoveTo : public MoveBy
{
public:
/** creates the action */
static MoveTo* create(float duration, const Point& position);
/** initializes the action */
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:
Point _endPosition;
};
@ -388,21 +374,20 @@ protected:
class CC_DLL SkewTo : public ActionInterval
{
public:
/** creates the action */
static SkewTo* create(float t, float sx, float sy);
SkewTo();
virtual bool initWithDuration(float t, float sx, float sy);
/** returns a new clone of the action */
virtual SkewTo* clone() const;
/** returns a new reversed action */
virtual SkewTo* reverse(void) const;
//
// Overrides
//
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:
float _skewX;
float _skewY;
@ -420,19 +405,17 @@ protected:
class CC_DLL SkewBy : public SkewTo
{
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 */
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.
@ -440,43 +423,42 @@ public:
class CC_DLL JumpBy : public ActionInterval
{
public:
/** creates the action */
static JumpBy* create(float duration, const Point& position, float height, unsigned int jumps);
/** initializes the action */
bool initWithDuration(float duration, const Point& position, float height, unsigned int jumps);
/** returns a new clone of the action */
virtual JumpBy* clone() const;
/** returns a new reversed action */
virtual JumpBy* reverse(void) const;
//
// Overrides
//
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:
Point _startPosition;
Point _delta;
Point _startPosition;
Point _delta;
float _height;
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.
*/
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:
/** creates the action */
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
@ -495,20 +477,20 @@ typedef struct _ccBezierConfig {
class CC_DLL BezierBy : public ActionInterval
{
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 */
bool initWithDuration(float t, const ccBezierConfig& c);
/** returns a new clone of the action */
virtual BezierBy* clone() const;
/** returns a new reversed action */
virtual BezierBy* reverse(void) const;
//
// Overrides
//
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:
ccBezierConfig _config;
Point _startPosition;
@ -521,19 +503,17 @@ protected:
class CC_DLL BezierTo : public BezierBy
{
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 */
static BezierTo* create(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:
ccBezierConfig _toConfig;
};
@ -544,27 +524,26 @@ protected:
class CC_DLL ScaleTo : public ActionInterval
{
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 */
bool initWithDuration(float duration, float s);
/** initializes the action with and X factor and a Y factor */
bool initWithDuration(float duration, float sx, float sy);
/** returns a new clone of the action */
virtual ScaleTo* clone() const;
/** returns a new reversed action */
virtual ScaleTo* reverse(void) const;
//
// Overrides
//
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:
float _scaleX;
float _scaleY;
@ -581,19 +560,18 @@ protected:
class CC_DLL ScaleBy : public ScaleTo
{
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 */
static ScaleBy* create(float duration, float s);
/** creates the action with and X factor and a Y factor */
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
@ -601,23 +579,20 @@ public:
class CC_DLL Blink : public ActionInterval
{
public:
/** creates the action */
static Blink* create(float duration, unsigned int uBlinks);
/** initializes the action */
bool initWithDuration(float duration, unsigned int uBlinks);
/** returns a new clone of the action */
virtual Blink* clone() const;
/** returns a new reversed action */
virtual Blink* reverse(void) const;
virtual void update(float time);
public:
/** creates the action */
static Blink* create(float duration, unsigned int uBlinks);
virtual void startWithTarget(Node *pTarget);
virtual void stop();
//
// Overrides
//
virtual Blink* clone() const override;
virtual Blink* reverse(void) const override;
virtual void update(float time) override;
virtual void startWithTarget(Node *pTarget) override;
virtual void stop() override;
protected:
unsigned int _times;
@ -629,17 +604,16 @@ protected:
*/
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:
/** creates the action */
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.
@ -648,18 +622,15 @@ public:
class CC_DLL FadeOut : public ActionInterval
{
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 */
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.
@ -668,20 +639,20 @@ public:
class CC_DLL FadeTo : public ActionInterval
{
public:
/** creates an action with duration and opacity */
static FadeTo* create(float duration, GLubyte opacity);
/** initializes the action with duration and opacity */
bool initWithDuration(float duration, GLubyte opacity);
/** returns a new clone of the action */
virtual FadeTo* clone() const;
/** returns a new reversed action */
virtual FadeTo* reverse(void) const;
//
// Overrides
//
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:
GLubyte _toOpacity;
GLubyte _fromOpacity;
@ -694,20 +665,20 @@ protected:
class CC_DLL TintTo : public ActionInterval
{
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 */
bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue);
/** returns a new clone of the action */
virtual TintTo* clone() const;
/** returns a new reversed action */
virtual TintTo* reverse(void) const;
//
// Overrides
//
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:
Color3B _to;
Color3B _from;
@ -719,20 +690,20 @@ protected:
class CC_DLL TintBy : public ActionInterval
{
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 */
bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
/** returns a new clone of the action */
virtual TintBy* clone() const;
/** returns a new reversed action */
virtual TintBy* reverse() const;
//
// Overrides
//
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:
GLshort _deltaR;
GLshort _deltaG;
@ -748,16 +719,15 @@ protected:
class CC_DLL DelayTime : public ActionInterval
{
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 */
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
@ -770,23 +740,24 @@ public:
class CC_DLL ReverseTime : public ActionInterval
{
public:
~ReverseTime(void);
/** creates the action */
static ReverseTime* create(FiniteTimeAction *pAction);
virtual ~ReverseTime(void);
ReverseTime();
/** initializes the action */
bool initWithAction(FiniteTimeAction *pAction);
/** returns a new reversed action */
virtual ReverseTime* reverse() const;
/** returns a new clone of the action */
virtual ReverseTime* clone() const;
virtual void startWithTarget(Node *pTarget);
virtual void stop(void);
virtual void update(float time);
//
// Overrides
//
virtual ReverseTime* reverse() const override;
virtual ReverseTime* clone() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void stop(void) override;
virtual void update(float time) override;
public:
/** creates the action */
static ReverseTime* create(FiniteTimeAction *pAction);
protected:
FiniteTimeAction *_other;
};
@ -796,24 +767,27 @@ class Texture2D;
class CC_DLL Animate : public ActionInterval
{
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();
virtual ~Animate();
/** initializes the action with an Animation and will restore the original frame when the animation is over */
bool initWithAnimation(Animation *pAnimation);
/** returns a new clone of the action */
virtual Animate* clone() const;
/** returns a new reversed action */
virtual Animate* reverse() const;
//
// Overrides
//
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:
/** 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)
protected:
std::vector<float>* _splitTimes;
int _nextFrame;
@ -836,15 +810,16 @@ public:
/** Init an action with the specified action and forced target */
bool initWithTarget(Node* pTarget, FiniteTimeAction* pAction);
/** returns a new clone of the action */
virtual TargetedAction* clone() const;
/** returns a new reversed action */
virtual TargetedAction* reverse() const;
virtual void startWithTarget(Node *pTarget);
virtual void stop(void);
virtual void update(float time);
//
// Overrides
//
virtual TargetedAction* clone() const override;
virtual TargetedAction* reverse() const override;
virtual void startWithTarget(Node *pTarget) override;
virtual void stop(void) override;
virtual void update(float time) override;
public:
/** This is the target that the action will be forced to run with */
CC_SYNTHESIZE_RETAIN(Node*, _forcedTarget, ForcedTarget);
private:

View File

@ -41,21 +41,20 @@ NS_CC_BEGIN
class CC_DLL ProgressTo : public ActionInterval
{
public:
/** Creates and initializes with a duration and a percent */
static ProgressTo* create(float duration, float fPercent);
/** Initializes with a duration and a percent */
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:
float _to;
float _from;
@ -68,22 +67,20 @@ protected:
class CC_DLL ProgressFromTo : public ActionInterval
{
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 */
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:
float _to;
float _from;

View File

@ -130,7 +130,13 @@ class CC_DLL Node : public Object
public:
/// @{
/// @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
*/
@ -146,12 +152,7 @@ public:
* @return Whether the initialization was successful.
*/
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.
* @return A string terminated with '\0'

View File

@ -70,10 +70,6 @@ public:
/** creates a fullscreen black layer */
static Layer *create(void);
virtual void onEnter();
virtual void onExit();
virtual void onEnterTransitionDidFinish();
// default implements are used to call script callback if exist
virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent);
virtual void ccTouchMoved(Touch *pTouch, Event *pEvent);
@ -154,7 +150,15 @@ public:
inline TouchScriptHandlerEntry* getScriptTouchHandlerEntry() const { return _scriptTouchHandlerEntry; };
inline ScriptHandlerEntry* getScriptKeypadHandlerEntry() const { return _scriptKeypadHandlerEntry; };
inline ScriptHandlerEntry* getScriptAccelerateHandlerEntry() const { return _scriptAccelerateHandlerEntry; };
protected:
//
// Overrides
//
virtual void onEnter() override;
virtual void onExit() override;
virtual void onEnterTransitionDidFinish() override;
protected:
bool _touchEnabled;
bool _accelerometerEnabled;
bool _keyboardEnabled;
@ -194,23 +198,26 @@ public:
virtual ~LayerRGBA();
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 GLubyte getDisplayedOpacity() const;
virtual void setOpacity(GLubyte opacity);
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
virtual bool isCascadeOpacityEnabled() const;
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
virtual const Color3B& getColor() const override;
virtual const Color3B& getDisplayedColor() const override;
virtual void setColor(const Color3B& color) override;
virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual bool isCascadeColorEnabled() const override;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
virtual const Color3B& getColor() const;
virtual const Color3B& getDisplayedColor() const;
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; }
virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB() const override { return false; }
protected:
GLubyte _displayedOpacity, _realOpacity;
Color3B _displayedColor, _realColor;
@ -268,8 +275,11 @@ public:
/** BlendFunction. Conforms to BlendProtocol protocol */
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:
virtual void updateColor();
@ -330,7 +340,7 @@ public:
CC_PROPERTY_PASS_BY_REF(Point, _alongVector, Vector)
protected:
virtual void updateColor();
virtual void updateColor() override;
protected:
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
{
public:
/** creates a new Scene object */
static Scene *create(void);
Scene();
virtual ~Scene();
bool init();
static Scene *create(void);
};
// end of scene group

View File

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

View File

@ -80,24 +80,12 @@ typedef enum {
class CC_DLL TransitionScene : public Scene
{
protected:
Scene * _inScene;
Scene * _outScene;
float _duration;
bool _isInSceneOnTop;
bool _isSendCleanupToScene;
public:
/** creates a base transition with duration and incoming scene */
static TransitionScene * create(float t, Scene *scene);
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 */
virtual bool initWithDuration(float t,Scene* scene);
@ -108,11 +96,26 @@ public:
/** used by some transitions to hide the outer scene */
void hideOutShowIn(void);
//
// Overrides
//
virtual void draw() override;
virtual void onEnter() override;
virtual void onExit() override;
virtual void cleanup() override;
protected:
virtual void sceneOrder();
private:
void setNewScene(float dt);
protected:
Scene * _inScene;
Scene * _outScene;
float _duration;
bool _isInSceneOnTop;
bool _isSendCleanupToScene;
};
/** @brief A Transition that supports orientation like.
@ -120,18 +123,18 @@ private:
*/
class CC_DLL TransitionSceneOriented : public TransitionScene
{
protected:
tOrientation _orientation;
public:
TransitionSceneOriented();
virtual ~TransitionSceneOriented();
/** creates a base transition with duration and incoming scene */
static TransitionSceneOriented * create(float t,Scene* scene, tOrientation orientation);
TransitionSceneOriented();
virtual ~TransitionSceneOriented();
/** initializes a transition with duration and incoming scene */
virtual bool initWithDuration(float t,Scene* scene,tOrientation orientation);
protected:
tOrientation _orientation;
};
/** @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
{
public:
static TransitionRotoZoom* create(float t, Scene* scene);
TransitionRotoZoom();
virtual ~TransitionRotoZoom();
virtual void onEnter();
static TransitionRotoZoom* create(float t, Scene* scene);
//
// Overrides
//
virtual void onEnter() override;
};
/** @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
{
public:
static TransitionJumpZoom* create(float t, Scene* scene);
TransitionJumpZoom();
virtual ~TransitionJumpZoom();
virtual void onEnter();
static TransitionJumpZoom* create(float t, Scene* scene);
//
// Overrides
//
virtual void onEnter() override;
};
/** @brief TransitionMoveInL:
@ -166,6 +177,8 @@ Move in from to the left the incoming scene.
class CC_DLL TransitionMoveInL : public TransitionScene, public TransitionEaseScene
{
public:
static TransitionMoveInL* create(float t, Scene* scene);
TransitionMoveInL();
virtual ~TransitionMoveInL();
/** initializes the scenes */
@ -175,9 +188,10 @@ public:
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
virtual void onEnter();
static TransitionMoveInL* create(float t, Scene* scene);
//
// Overrides
//
virtual void onEnter() override;
};
/** @brief TransitionMoveInR:
@ -186,11 +200,11 @@ Move in from to the right the incoming scene.
class CC_DLL TransitionMoveInR : public TransitionMoveInL
{
public:
static TransitionMoveInR* create(float t, Scene* scene);
TransitionMoveInR();
virtual ~TransitionMoveInR();
virtual void initScenes();
static TransitionMoveInR* create(float t, Scene* scene);
};
/** @brief TransitionMoveInT:
@ -199,11 +213,11 @@ Move in from to the top the incoming scene.
class CC_DLL TransitionMoveInT : public TransitionMoveInL
{
public:
static TransitionMoveInT* create(float t, Scene* scene);
TransitionMoveInT();
virtual ~TransitionMoveInT();
virtual void initScenes();
static TransitionMoveInT* create(float t, Scene* scene);
};
/** @brief TransitionMoveInB:
@ -212,11 +226,11 @@ Move in from to the bottom the incoming scene.
class CC_DLL TransitionMoveInB : public TransitionMoveInL
{
public:
static TransitionMoveInB* create(float t, Scene* scene);
TransitionMoveInB();
virtual ~TransitionMoveInB();
virtual void initScenes();
static TransitionMoveInB* create(float t, Scene* scene);
};
/** @brief TransitionSlideInL:
@ -225,21 +239,25 @@ Slide in the incoming scene from the left border.
class CC_DLL TransitionSlideInL : public TransitionScene, public TransitionEaseScene
{
public:
static TransitionSlideInL* create(float t, Scene* scene);
TransitionSlideInL();
virtual ~TransitionSlideInL();
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incoming and outgoing scene */
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:
virtual void sceneOrder();
virtual void sceneOrder() override;
};
/** @brief TransitionSlideInR:
@ -248,6 +266,8 @@ Slide in the incoming scene from the right border.
class CC_DLL TransitionSlideInR : public TransitionSlideInL
{
public:
static TransitionSlideInR* create(float t, Scene* scene);
TransitionSlideInR();
virtual ~TransitionSlideInR();
@ -256,9 +276,8 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
static TransitionSlideInR* create(float t, Scene* scene);
protected:
virtual void sceneOrder();
virtual void sceneOrder() override;
};
/** @brief TransitionSlideInB:
@ -267,6 +286,8 @@ Slide in the incoming scene from the bottom border.
class CC_DLL TransitionSlideInB : public TransitionSlideInL
{
public:
static TransitionSlideInB* create(float t, Scene* scene);
TransitionSlideInB();
virtual ~TransitionSlideInB();
@ -275,9 +296,8 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
static TransitionSlideInB* create(float t, Scene* scene);
protected:
virtual void sceneOrder();
protected:
virtual void sceneOrder() override;
};
/** @brief TransitionSlideInT:
@ -286,6 +306,8 @@ Slide in the incoming scene from the top border.
class CC_DLL TransitionSlideInT : public TransitionSlideInL
{
public:
static TransitionSlideInT* create(float t, Scene* scene);
TransitionSlideInT();
virtual ~TransitionSlideInT();
@ -294,9 +316,8 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
static TransitionSlideInT* create(float t, Scene* scene);
protected:
virtual void sceneOrder();
virtual void sceneOrder() override;
};
/**
@ -305,13 +326,16 @@ protected:
class CC_DLL TransitionShrinkGrow : public TransitionScene , public TransitionEaseScene
{
public:
static TransitionShrinkGrow* create(float t, Scene* scene);
TransitionShrinkGrow();
virtual ~TransitionShrinkGrow();
virtual void onEnter();
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
static TransitionShrinkGrow* create(float t, Scene* scene);
//
// Overrides
//
virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
};
/** @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
{
public:
static TransitionFlipX* create(float t, Scene* s, tOrientation o);
static TransitionFlipX* create(float t, Scene* s);
TransitionFlipX();
virtual ~TransitionFlipX();
virtual void onEnter();
static TransitionFlipX* create(float t, Scene* s, tOrientation o);
static TransitionFlipX* create(float t, Scene* s);
//
// Overrides
//
virtual void onEnter() override;
};
/** @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
{
public:
static TransitionFlipY* create(float t, Scene* s, tOrientation o);
static TransitionFlipY* create(float t, Scene* s);
TransitionFlipY();
virtual ~TransitionFlipY();
virtual void onEnter();
static TransitionFlipY* create(float t, Scene* s, tOrientation o);
static TransitionFlipY* create(float t, Scene* s);
//
// Overrides
//
virtual void onEnter() override;
};
/** @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
{
public:
static TransitionFlipAngular* create(float t, Scene* s, tOrientation o);
static TransitionFlipAngular* create(float t, Scene* s);
TransitionFlipAngular();
virtual ~TransitionFlipAngular();
virtual void onEnter();
static TransitionFlipAngular* create(float t, Scene* s, tOrientation o);
static TransitionFlipAngular* create(float t, Scene* s);
//
// Overrides
//
virtual void onEnter() override;
};
/** @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
{
public:
static TransitionZoomFlipX* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipX* create(float t, Scene* s);
TransitionZoomFlipX();
virtual ~TransitionZoomFlipX();
virtual void onEnter();
static TransitionZoomFlipX* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipX* create(float t, Scene* s);
//
// Overrides
//
virtual void onEnter() override;
};
/** @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
{
public:
static TransitionZoomFlipY* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipY* create(float t, Scene* s);
TransitionZoomFlipY();
virtual ~TransitionZoomFlipY();
virtual void onEnter();
static TransitionZoomFlipY* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipY* create(float t, Scene* s);
//
// Overrides
//
virtual void onEnter() override;
};
/** @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
{
public:
static TransitionZoomFlipAngular* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipAngular* create(float t, Scene* s);
TransitionZoomFlipAngular();
virtual ~TransitionZoomFlipAngular();
virtual void onEnter();
static TransitionZoomFlipAngular* create(float t, Scene* s, tOrientation o);
static TransitionZoomFlipAngular* create(float t, Scene* s);
//
// Overrides
//
virtual void onEnter() override;
};
/** @brief TransitionFade:
@ -415,26 +457,28 @@ Fade out the outgoing scene and then fade in the incoming scene.'''
*/
class CC_DLL TransitionFade : public TransitionScene
{
protected:
Color4B _color;
public:
TransitionFade();
virtual ~TransitionFade();
/** creates the transition with a duration and with an RGB 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);
TransitionFade();
virtual ~TransitionFade();
/** 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);
//
// Overrides
//
virtual bool initWithDuration(float t,Scene* scene);
virtual void onEnter();
virtual void onExit();
protected:
Color4B _color;
};
class RenderTexture;
@ -445,15 +489,18 @@ Cross fades two scenes using the RenderTexture object.
class CC_DLL TransitionCrossFade : public TransitionScene
{
public :
static TransitionCrossFade* create(float t, Scene* scene);
TransitionCrossFade();
virtual ~TransitionCrossFade();
virtual void draw();
virtual void onEnter();
virtual void onExit();
//
// Overrides
//
virtual void draw() override;
virtual void onEnter() override;
virtual void onExit() override;
public:
static TransitionCrossFade* create(float t, Scene* scene);
};
/** @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
{
public :
static TransitionTurnOffTiles* create(float t, Scene* scene);
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:
virtual void sceneOrder();
virtual void sceneOrder() override;
};
/** @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
{
public:
static TransitionSplitCols* create(float t, Scene* scene);
TransitionSplitCols();
virtual ~TransitionSplitCols();
virtual ActionInterval* action(void);
virtual void onEnter();
virtual ActionInterval * easeActionWithAction(ActionInterval * action);
public:
static TransitionSplitCols* create(float t, Scene* scene);
//
// Overrides
//
virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
};
/** @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
{
public:
static TransitionSplitRows* create(float t, Scene* scene);
TransitionSplitRows();
virtual ~TransitionSplitRows();
virtual ActionInterval* action(void);
public:
static TransitionSplitRows* create(float t, Scene* scene);
//
// Overrides
//
virtual ActionInterval* action(void) override;
};
/** @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
{
public:
static TransitionFadeTR* create(float t, Scene* scene);
TransitionFadeTR();
virtual ~TransitionFadeTR();
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:
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
{
public:
static TransitionFadeBL* create(float t, Scene* scene);
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:
@ -548,13 +607,15 @@ public:
class CC_DLL TransitionFadeUp : public TransitionFadeTR
{
public:
static TransitionFadeUp* create(float t, Scene* scene);
TransitionFadeUp();
virtual ~TransitionFadeUp();
virtual ActionInterval* actionWithSize(const Size& size);
public:
static TransitionFadeUp* create(float t, Scene* scene);
//
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
};
/** @brief TransitionFadeDown:
@ -563,13 +624,15 @@ public:
class CC_DLL TransitionFadeDown : public TransitionFadeTR
{
public:
static TransitionFadeDown* create(float t, Scene* scene);
TransitionFadeDown();
virtual ~TransitionFadeDown();
virtual ActionInterval* actionWithSize(const Size& size);
public:
static TransitionFadeDown* create(float t, Scene* scene);
//
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
};
// end of transition group

View File

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

View File

@ -48,20 +48,17 @@ is turned on in Director using:
*/
class CC_DLL TransitionPageTurn : public TransitionScene
{
protected:
bool _back;
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();
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.
* 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);
virtual void onEnter();
//
// Overrides
//
virtual void onEnter() override;
protected:
virtual void sceneOrder();
virtual void sceneOrder() override;
protected:
bool _back;
};
// end of transition group

View File

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

View File

@ -38,19 +38,27 @@ class RenderTexture;
* @addtogroup transition
* @{
*/
class CC_DLL TransitionProgress : public TransitionScene
{
public:
static TransitionProgress* create(float t, Scene* scene);
TransitionProgress();
virtual void onEnter();
virtual void onExit();
//
// Overrides
//
virtual void onEnter() override;
virtual void onExit() override;
protected:
virtual void sceneOrder() override;
protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture);
virtual void setupTransition();
virtual void sceneOrder();
protected:
float _to;
float _from;
Scene* _sceneToBeModified;
@ -64,8 +72,12 @@ class CC_DLL TransitionProgressRadialCCW : public TransitionProgress
{
public:
static TransitionProgressRadialCCW* create(float t, Scene* scene);
protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture);
//
// Overrides
//
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
};
@ -77,8 +89,12 @@ class CC_DLL TransitionProgressRadialCW : public TransitionProgress
{
public:
static TransitionProgressRadialCW* create(float t, Scene* scene);
protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture);
//
// Overrides
//
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
};
@ -88,41 +104,51 @@ protected:
class CC_DLL TransitionProgressHorizontal : public TransitionProgress
{
public:
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
{
public:
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
{
public:
static TransitionProgressInOut* create(float t, Scene* scene);
protected:
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture);
virtual void sceneOrder();
virtual void setupTransition();
//
// Overrides
//
virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override;
virtual void sceneOrder() override;
virtual void setupTransition() override;
};
class CC_DLL TransitionProgressOutIn : public TransitionProgress
{
public:
static TransitionProgressOutIn* create(float t, Scene* scene);
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);
/// @} 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
@ -486,7 +442,54 @@ public:
void setFlipY(bool bFlipY);
/// @} 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:
void updateColor(void);
virtual void setTextureCoords(Rect rect);

View File

@ -128,22 +128,26 @@ public:
unsigned int atlasIndexForChild(Sprite *sprite, int z);
/* Sprites use this to start sortChildren, don't call this manually */
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);
virtual void addChild(Node * child, int zOrder);
virtual void addChild(Node * child, int zOrder, int tag);
virtual void reorderChild(Node * child, int zOrder);
//
// Overrides
//
// TextureProtocol
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 removeAllChildrenWithCleanup(bool cleanup);
virtual void sortAllChildren();
virtual void draw(void);
virtual void removeChild(Node* child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void sortAllChildren() override;
virtual void draw(void) override;
protected:
/** 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
#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:
Texture2D();
virtual ~Texture2D();
@ -195,45 +230,12 @@ public:
*/
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 */
const Size& getContentSizeInPixels();
bool hasPremultipliedAlpha() const;
bool hasMipmaps() const;
private:
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
{
public:
TextureCache();
virtual ~TextureCache();
const char* description(void) const;
Dictionary* snapshotTextures();
/** Returns the shared instance of the cache */
static TextureCache * getInstance();
@ -80,6 +72,19 @@ public:
/** @deprecated Use destroyInstance() instead */
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
* 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.
@ -153,11 +158,6 @@ public:
*/
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:
void addImageAsyncCallBack(float dt);
void loadImage();
@ -206,13 +206,13 @@ protected:
class VolatileTexture
{
typedef enum {
kInvalid = 0,
kImageFile,
kImageData,
kString,
kImage,
}ccCachedImageType;
typedef enum {
kInvalid = 0,
kImageFile,
kImageData,
kString,
kImage,
}ccCachedImageType;
public:
VolatileTexture(Texture2D *t);

View File

@ -148,15 +148,20 @@ public:
/** Creates the tiles */
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 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:
Point positionForIsoAt(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
CCBSequence *seq = getSequence(nSeqId);
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);
// Set the running scene

View File

@ -218,7 +218,7 @@ void ScrollView::setContentOffsetInDuration(Point offset, float dt)
FiniteTimeAction *scroll, *expire;
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));
this->schedule(schedule_selector(ScrollView::performedAnimatedScroll));
}

View File

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

View File

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

View File

@ -132,7 +132,7 @@ void CrashTest::onEnter()
//After 1.5 second, self will be removed.
runAction( Sequence::create(
DelayTime::create(1.4f),
CallFunc::create(this, callfunc_selector(CrashTest::removeThis)),
CallFunc::create( CC_CALLBACK_0(CrashTest::removeThis,this)),
NULL)
);
}
@ -164,7 +164,7 @@ void LogicTest::onEnter()
grossini->runAction( Sequence::create(
MoveBy::create(1, Point(150,0)),
CallFuncN::create(this, callfuncN_selector(LogicTest::bugMe)),
CallFuncN::create(CC_CALLBACK_1(LogicTest::bugMe,this)),
NULL)
);
}
@ -242,7 +242,7 @@ void RemoveTest::onEnter()
l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75) );
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);
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));
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");
}
else if (id.compare("FireMax") == 0)
{
ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y));
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");
}
}

View File

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

View File

@ -303,7 +303,7 @@ LabelAtlasColorTest::LabelAtlasColorTest()
ActionInterval* fade = FadeOut::create(1.0f);
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);
Action* repeat = RepeatForever::create( seq );
label2->runAction( repeat );

View File

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

View File

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

View File

@ -338,7 +338,7 @@ TMXReadWriteTest::TMXReadWriteTest()
ActionInterval* opacity = FadeOut::create(2);
ActionInterval* fadein = FadeIn::create(2);
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);
ActionInterval* seq1 = seq0->clone();
ActionInterval* seq2 = seq0->clone();