2010-11-12 17:26:01 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2011 Zynga Inc.
|
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2010-11-12 17:26:01 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCINSTANT_ACTION_H__
|
|
|
|
#define __CCINSTANT_ACTION_H__
|
|
|
|
|
2011-06-21 10:18:43 +08:00
|
|
|
#include <string>
|
2013-06-04 03:13:24 +08:00
|
|
|
#include <functional>
|
|
|
|
|
2013-06-07 19:14:43 +08:00
|
|
|
#include "CCStdC.h"
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCAction.h"
|
2010-11-12 17:26:01 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup actions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
/**
|
|
|
|
@brief Instant actions are immediate actions. They don't have a duration like
|
2013-06-20 14:13:12 +08:00
|
|
|
the IntervalAction actions.
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ActionInstant : public FiniteTimeAction //<NSCopying>
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual ActionInstant* clone() const override = 0;
|
2013-11-16 21:08:00 +08:00
|
|
|
virtual ActionInstant * reverse() const override = 0;
|
|
|
|
virtual bool isDone() const override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void step(float dt) override;
|
|
|
|
virtual void update(float time) override;
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/** @brief Show the node
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Show : public ActionInstant
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Allocates and initializes the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
static Show * create();
|
2012-04-18 18:43:45 +08:00
|
|
|
|
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual void update(float time) override;
|
2013-11-16 21:08:00 +08:00
|
|
|
virtual ActionInstant* reverse() const override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual Show* clone() const override;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Show(){}
|
|
|
|
virtual ~Show(){}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Show);
|
2013-07-16 03:43:22 +08:00
|
|
|
};
|
2012-04-18 18:43:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Hide the node
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Hide : public ActionInstant
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Allocates and initializes the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
static Hide * create();
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual ActionInstant* reverse() const override;
|
|
|
|
virtual Hide* clone() const override;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Hide(){}
|
|
|
|
virtual ~Hide(){}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Hide);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/** @brief Toggles the visibility of a node
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ToggleVisibility : public ActionInstant
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Allocates and initializes the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
static ToggleVisibility * create();
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual ToggleVisibility* reverse() const override;
|
|
|
|
virtual ToggleVisibility* clone() const override;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ToggleVisibility(){}
|
|
|
|
virtual ~ToggleVisibility(){}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ToggleVisibility);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2013-03-25 11:10:51 +08:00
|
|
|
/**
|
|
|
|
@brief Remove the node
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL RemoveSelf : public ActionInstant
|
2013-03-25 11:10:51 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-03-25 18:18:38 +08:00
|
|
|
/** create the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
static RemoveSelf * create(bool isNeedCleanUp = true);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Override
|
|
|
|
//
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual RemoveSelf* clone() const override;
|
|
|
|
virtual RemoveSelf* reverse() const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
RemoveSelf() : _isNeedCleanUp(true){}
|
|
|
|
virtual ~RemoveSelf(){}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** init the action */
|
|
|
|
bool init(bool isNeedCleanUp);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _isNeedCleanUp;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(RemoveSelf);
|
2013-03-25 11:10:51 +08:00
|
|
|
};
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
/**
|
|
|
|
@brief Flips the sprite horizontally
|
|
|
|
@since v0.99.0
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL FlipX : public ActionInstant
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-16 03:43:22 +08:00
|
|
|
/** create the action */
|
|
|
|
static FlipX * create(bool x);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual FlipX* reverse() const override;
|
|
|
|
virtual FlipX* clone() const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
FlipX() :_flipX(false) {}
|
|
|
|
virtual ~FlipX() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** init the action */
|
|
|
|
bool initWithFlipX(bool x);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _flipX;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(FlipX);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Flips the sprite vertically
|
|
|
|
@since v0.99.0
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL FlipY : public ActionInstant
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-16 03:43:22 +08:00
|
|
|
/** create the action */
|
|
|
|
static FlipY * create(bool y);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual FlipY* reverse() const override;
|
|
|
|
virtual FlipY* clone() const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
FlipY() :_flipY(false) {}
|
|
|
|
virtual ~FlipY() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** init the action */
|
|
|
|
bool initWithFlipY(bool y);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _flipY;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(FlipY);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/** @brief Places the node in a certain position
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Place : public ActionInstant //<NSCopying>
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-12-06 18:51:33 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates a Place action with a position */
|
2014-05-15 01:07:09 +08:00
|
|
|
static Place * create(const Vec2& pos);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual Place* reverse() const override;
|
|
|
|
virtual Place* clone() const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
Place(){}
|
|
|
|
virtual ~Place(){}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** Initializes a Place action with a position */
|
2014-05-15 01:07:09 +08:00
|
|
|
bool initWithPosition(const Vec2& pos);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 _position;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Place);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2013-06-04 03:13:24 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
/** @brief Calls a 'callback'
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL CallFunc : public ActionInstant //<NSCopying>
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-04 03:13:24 +08:00
|
|
|
/** creates the action with the callback of type std::function<void()>.
|
|
|
|
This is the preferred way to create the callback.
|
2013-09-13 11:41:20 +08:00
|
|
|
* When this funtion bound in js or lua ,the input param will be changed
|
|
|
|
* In js: var create(var func, var this, var [data]) or var create(var func)
|
|
|
|
* In lua:local create(local funcID)
|
2013-06-04 03:13:24 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static CallFunc * create(const std::function<void()>& func);
|
2013-06-04 03:13:24 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
/** creates the action with the callback
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
typedef void (Ref::*SEL_CallFunc)();
|
2013-06-04 03:13:24 +08:00
|
|
|
@deprecated Use the std::function API instead.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2013-07-16 03:43:22 +08:00
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Ref* target, SEL_CallFunc selector);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
/** executes the callback */
|
|
|
|
virtual void execute();
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
inline Ref* getTargetCallback()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _selectorTarget;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
inline void setTargetCallback(Ref* sel)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-11-16 21:08:00 +08:00
|
|
|
if (sel != _selectorTarget)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-11-16 21:08:00 +08:00
|
|
|
CC_SAFE_RETAIN(sel);
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_selectorTarget);
|
2013-11-16 21:08:00 +08:00
|
|
|
_selectorTarget = sel;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual CallFunc* reverse() const override;
|
|
|
|
virtual CallFunc* clone() const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
CallFunc()
|
2013-12-18 17:47:20 +08:00
|
|
|
: _selectorTarget(nullptr)
|
|
|
|
, _callFunc(nullptr)
|
2013-11-22 09:06:06 +08:00
|
|
|
, _function(nullptr)
|
2013-11-26 05:59:24 +08:00
|
|
|
{
|
|
|
|
}
|
2013-11-22 09:06:06 +08:00
|
|
|
virtual ~CallFunc();
|
|
|
|
|
|
|
|
/** initializes the action with the callback
|
2014-02-20 10:53:49 +08:00
|
|
|
typedef void (Ref::*SEL_CallFunc)();
|
2013-11-22 09:06:06 +08:00
|
|
|
@deprecated Use the std::function API instead.
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Ref* target);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action with the std::function<void()>
|
2013-11-26 05:59:24 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2013-11-22 09:06:06 +08:00
|
|
|
*/
|
|
|
|
bool initWithFunction(const std::function<void()>& func);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Target that will be called */
|
2014-02-20 10:53:49 +08:00
|
|
|
Ref* _selectorTarget;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
union
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
SEL_CallFunc _callFunc;
|
|
|
|
SEL_CallFuncN _callFuncN;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
2013-06-04 11:57:32 +08:00
|
|
|
|
|
|
|
/** function that will be called */
|
|
|
|
std::function<void()> _function;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(CallFunc);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Calls a 'callback' with the node as the first argument
|
|
|
|
N means Node
|
|
|
|
*/
|
2013-08-22 18:16:50 +08:00
|
|
|
class CC_DLL CallFuncN : public CallFunc
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-22 05:58:52 +08:00
|
|
|
/** creates the action with the callback of type std::function<void()>.
|
|
|
|
This is the preferred way to create the callback.
|
|
|
|
*/
|
|
|
|
static CallFuncN * create(const std::function<void(Node*)>& func);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** creates the action with the callback
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
typedef void (Ref::*SEL_CallFuncN)(Node*);
|
2013-06-22 05:58:52 +08:00
|
|
|
@deprecated Use the std::function API instead.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static CallFuncN * create(Ref* target, SEL_CallFuncN selector);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual CallFuncN* clone() const override;
|
|
|
|
virtual void execute() override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
CallFuncN():_functionN(nullptr){}
|
|
|
|
virtual ~CallFuncN(){}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action with the std::function<void(Node*)> */
|
|
|
|
bool initWithFunction(const std::function<void(Node*)>& func);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action with the callback
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
typedef void (Ref::*SEL_CallFuncN)(Node*);
|
2013-11-22 09:06:06 +08:00
|
|
|
@deprecated Use the std::function API instead.
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Ref* target, SEL_CallFuncN selector);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-22 05:58:52 +08:00
|
|
|
/** function that will be called with the "sender" as the 1st argument */
|
|
|
|
std::function<void(Node*)> _functionN;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(CallFuncN);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
2010-12-23 16:47:29 +08:00
|
|
|
|
2013-07-24 16:45:11 +08:00
|
|
|
/**
|
|
|
|
@deprecated Please use CallFuncN instead.
|
|
|
|
@brief Calls a 'callback' with the node as the first argument and the 2nd argument is data
|
|
|
|
* ND means: Node and Data. Data is void *, so it could be anything.
|
|
|
|
*/
|
2013-07-25 13:45:02 +08:00
|
|
|
|
2013-07-25 15:03:44 +08:00
|
|
|
class CC_DLL __CCCallFuncND : public CallFunc
|
2013-07-24 16:45:11 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** creates the action with the callback and the data to pass as an argument */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static __CCCallFuncND * create(Ref* target, SEL_CallFuncND selector, void* d);
|
2013-07-24 16:45:11 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2013-07-25 15:03:44 +08:00
|
|
|
virtual __CCCallFuncND* clone() const override;
|
2013-07-24 16:45:11 +08:00
|
|
|
virtual void execute() override;
|
|
|
|
|
|
|
|
protected:
|
2013-11-22 09:06:06 +08:00
|
|
|
__CCCallFuncND() {}
|
|
|
|
virtual ~__CCCallFuncND() {}
|
|
|
|
|
|
|
|
/** initializes the action with the callback and the data to pass as an argument */
|
2014-02-20 10:53:49 +08:00
|
|
|
bool initWithTarget(Ref* target, SEL_CallFuncND selector, void* d);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2013-07-24 16:45:11 +08:00
|
|
|
SEL_CallFuncND _callFuncND;
|
|
|
|
void* _data;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(__CCCallFuncND);
|
2013-07-24 16:45:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@deprecated Please use CallFuncN instead.
|
|
|
|
@brief Calls a 'callback' with an object as the first argument.
|
|
|
|
O means Object.
|
|
|
|
@since v0.99.5
|
|
|
|
*/
|
|
|
|
|
2013-08-22 18:16:50 +08:00
|
|
|
class CC_DLL __CCCallFuncO : public CallFunc
|
2013-07-24 16:45:11 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** creates the action with the callback
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
typedef void (Ref::*SEL_CallFuncO)(Ref*);
|
2013-07-24 16:45:11 +08:00
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Ref* target, SEL_CallFuncO selector, Ref* object);
|
2013-07-24 16:45:11 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2013-07-25 15:03:44 +08:00
|
|
|
virtual __CCCallFuncO* clone() const override;
|
2013-07-24 16:45:11 +08:00
|
|
|
virtual void execute() override;
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
Ref* getObject() const;
|
|
|
|
void setObject(Ref* obj);
|
2013-07-24 16:45:11 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-22 09:06:06 +08:00
|
|
|
__CCCallFuncO();
|
|
|
|
virtual ~__CCCallFuncO();
|
|
|
|
/** initializes the action with the callback
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
typedef void (Ref::*SEL_CallFuncO)(Ref*);
|
2013-11-22 09:06:06 +08:00
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
bool initWithTarget(Ref* target, SEL_CallFuncO selector, Ref* object);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
|
2013-07-24 16:45:11 +08:00
|
|
|
/** object to be passed as argument */
|
2014-02-20 10:53:49 +08:00
|
|
|
Ref* _object;
|
2013-07-24 16:45:11 +08:00
|
|
|
SEL_CallFuncO _callFuncO;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(__CCCallFuncO);
|
2013-07-24 16:45:11 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of actions group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|
2010-08-05 17:22:47 +08:00
|
|
|
|
2010-11-12 17:26:01 +08:00
|
|
|
#endif //__CCINSTANT_ACTION_H__
|