2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
Copyright (c) 2011 Zynga Inc.
|
2012-09-24 21:22:20 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2012-04-19 14:35:52 +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 __ACTION_CCINTERVAL_ACTION_H__
|
|
|
|
#define __ACTION_CCINTERVAL_ACTION_H__
|
|
|
|
|
2014-05-17 05:36:00 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCAction.h"
|
2014-05-01 10:09:13 +08:00
|
|
|
#include "2d/CCAnimation.h"
|
2014-05-17 05:36:00 +08:00
|
|
|
#include "base/CCProtocols.h"
|
2014-04-27 01:35:57 +08:00
|
|
|
#include "base/CCVector.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2014-08-26 18:19:28 +08:00
|
|
|
class Node;
|
|
|
|
class SpriteFrame;
|
|
|
|
class EventCustom;
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup actions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class ActionInterval
|
2010-09-28 18:27:33 +08:00
|
|
|
@brief An interval action is an action that takes place within a certain period of time.
|
2010-08-06 10:51:40 +08:00
|
|
|
It has an start time, and a finish time. The finish time is the parameter
|
|
|
|
duration plus the start time.
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
These ActionInterval actions have some interesting properties, like:
|
2012-04-19 14:35:52 +08:00
|
|
|
- They can run normally (default)
|
|
|
|
- They can run reversed with the reverse method
|
|
|
|
- They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
For example, you can simulate a Ping Pong effect running the action normally and
|
|
|
|
then running it again in Reverse mode.
|
|
|
|
|
|
|
|
Example:
|
2010-09-28 16:18:05 +08:00
|
|
|
|
2016-01-18 06:01:03 +08:00
|
|
|
@code
|
|
|
|
auto action = MoveBy::create(1.0f, Vec2::ONE);
|
|
|
|
auto pingPongAction = Sequence::create(action, action->reverse(), nullptr);
|
|
|
|
@endcode
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ActionInterval : public FiniteTimeAction
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** How many seconds had elapsed since the actions started to run.
|
|
|
|
*
|
2015-09-22 16:08:23 +08:00
|
|
|
* @return The seconds had elapsed since the actions started to run.
|
2015-03-18 20:40:29 +08:00
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getElapsed() { return _elapsed; }
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-09-22 16:08:23 +08:00
|
|
|
/** Sets the amplitude rate, extension in GridAction
|
2015-03-18 20:40:29 +08:00
|
|
|
*
|
2015-09-22 16:08:23 +08:00
|
|
|
* @param amp The amplitude rate.
|
2015-03-18 20:40:29 +08:00
|
|
|
*/
|
2012-08-01 15:30:12 +08:00
|
|
|
void setAmplitudeRate(float amp);
|
2015-03-18 20:40:29 +08:00
|
|
|
|
2015-09-22 16:08:23 +08:00
|
|
|
/** Gets the amplitude rate, extension in GridAction
|
2015-03-18 20:40:29 +08:00
|
|
|
*
|
2015-09-22 16:08:23 +08:00
|
|
|
* @return The amplitude rate.
|
2015-03-18 20:40:29 +08:00
|
|
|
*/
|
2017-06-08 17:07:43 +08:00
|
|
|
float getAmplitudeRate();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual bool isDone() const override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* @param dt in seconds
|
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void step(float dt) override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2014-07-11 10:19:49 +08:00
|
|
|
virtual ActionInterval* reverse() const override
|
|
|
|
{
|
|
|
|
CC_ASSERT(0);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual ActionInterval *clone() const override
|
2014-07-11 10:19:49 +08:00
|
|
|
{
|
|
|
|
CC_ASSERT(0);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2014-07-10 17:56:20 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action */
|
|
|
|
bool initWithDuration(float d);
|
|
|
|
|
2014-07-10 17:56:20 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _elapsed;
|
2017-03-22 14:17:49 +08:00
|
|
|
bool _firstTick;
|
|
|
|
bool _done;
|
|
|
|
|
2015-08-27 17:55:38 +08:00
|
|
|
protected:
|
|
|
|
bool sendUpdateEventToScript(float dt, Action *actionObject);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class Sequence
|
|
|
|
* @brief Runs actions sequentially, one after another.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Sequence : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Helper constructor to create an array of sequenceable actions.
|
|
|
|
*
|
|
|
|
* @return An autoreleased Sequence object.
|
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static Sequence* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION;
|
2014-03-25 06:09:24 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Helper constructor to create an array of sequenceable actions given an array.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @code
|
2015-09-22 16:08:23 +08:00
|
|
|
* When this function bound to the js or lua,the input params changed
|
2013-09-13 11:41:20 +08:00
|
|
|
* in js :var create(var object1,var object2, ...)
|
|
|
|
* in lua :local create(local object1,local object2, ...)
|
|
|
|
* @endcode
|
2015-03-18 20:40:29 +08:00
|
|
|
*
|
|
|
|
* @param arrayOfActions An array of sequenceable actions.
|
|
|
|
* @return An autoreleased Sequence object.
|
2013-09-13 11:41:20 +08:00
|
|
|
*/
|
2013-11-28 11:04:39 +08:00
|
|
|
static Sequence* create(const Vector<FiniteTimeAction*>& arrayOfActions);
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Helper constructor to create an array of sequence-able actions.
|
|
|
|
*
|
|
|
|
* @param action1 The first sequenceable action.
|
|
|
|
* @param args The va_list variable.
|
|
|
|
* @return An autoreleased Sequence object.
|
2015-03-19 18:41:11 +08:00
|
|
|
* @js NA
|
2015-03-18 20:40:29 +08:00
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static Sequence* createWithVariableList(FiniteTimeAction *action1, va_list args);
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates the action.
|
|
|
|
* @param actionOne The first sequenceable action.
|
|
|
|
* @param actionTwo The second sequenceable action.
|
|
|
|
* @return An autoreleased Sequence object.
|
2015-03-19 18:41:11 +08:00
|
|
|
* @js NA
|
2015-03-18 20:40:29 +08:00
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static Sequence* createWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual Sequence* clone() const override;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual Sequence* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual void stop() override;
|
2017-06-08 14:52:36 +08:00
|
|
|
virtual bool isDone() const override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param t In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float t) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2016-04-08 13:40:36 +08:00
|
|
|
Sequence();
|
|
|
|
virtual ~Sequence();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action */
|
|
|
|
bool initWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo);
|
2015-12-04 04:16:21 +08:00
|
|
|
bool init(const Vector<FiniteTimeAction*>& arrayOfActions);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-20 14:13:12 +08:00
|
|
|
FiniteTimeAction *_actions[2];
|
2013-06-15 14:03:30 +08:00
|
|
|
float _split;
|
|
|
|
int _last;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Sequence);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class Repeat
|
|
|
|
* @brief Repeats an action a number of times.
|
2013-06-20 14:13:12 +08:00
|
|
|
* To repeat an action forever use the RepeatForever action.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Repeat : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30).
|
|
|
|
*
|
|
|
|
* @param action The action needs to repeat.
|
|
|
|
* @param times The repeat times.
|
|
|
|
* @return An autoreleased Repeat object.
|
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static Repeat* create(FiniteTimeAction *action, unsigned int times);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Sets the inner action.
|
|
|
|
*
|
|
|
|
* @param action The inner action.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setInnerAction(FiniteTimeAction *action)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
if (_innerAction != action)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
CC_SAFE_RETAIN(action);
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_innerAction);
|
2013-12-18 17:47:20 +08:00
|
|
|
_innerAction = action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Gets the inner action.
|
|
|
|
*
|
|
|
|
* @return The inner action.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
FiniteTimeAction* getInnerAction()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _innerAction;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual Repeat* clone() const override;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual Repeat* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void stop(void) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param dt In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float dt) override;
|
|
|
|
virtual bool isDone(void) const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
Repeat() {}
|
|
|
|
virtual ~Repeat();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */
|
|
|
|
bool initWithAction(FiniteTimeAction *pAction, unsigned int times);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
unsigned int _times;
|
|
|
|
unsigned int _total;
|
|
|
|
float _nextDt;
|
|
|
|
bool _actionInstant;
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Inner action */
|
2013-06-20 14:13:12 +08:00
|
|
|
FiniteTimeAction *_innerAction;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Repeat);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class RepeatForever
|
|
|
|
* @brief Repeats an action for ever.
|
|
|
|
To repeat the an action for a limited number of times use the Repeat action.
|
|
|
|
* @warning This action can't be Sequenceable because it is not an IntervalAction.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL RepeatForever : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates the action.
|
|
|
|
*
|
|
|
|
* @param action The action need to repeat forever.
|
|
|
|
* @return An autoreleased RepeatForever object.
|
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static RepeatForever* create(ActionInterval *action);
|
2013-07-08 23:05:47 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Sets the inner action.
|
|
|
|
*
|
|
|
|
* @param action The inner action.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setInnerAction(ActionInterval *action)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-12-18 17:47:20 +08:00
|
|
|
if (_innerAction != action)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_innerAction);
|
2013-12-18 17:47:20 +08:00
|
|
|
_innerAction = action;
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RETAIN(_innerAction);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Gets the inner action.
|
|
|
|
*
|
|
|
|
* @return The inner action.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
ActionInterval* getInnerAction()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _innerAction;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual RepeatForever* clone() const override;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual RepeatForever* reverse(void) const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node* target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param dt In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void step(float dt) override;
|
|
|
|
virtual bool isDone(void) const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
RepeatForever()
|
|
|
|
: _innerAction(nullptr)
|
|
|
|
{}
|
|
|
|
virtual ~RepeatForever();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action */
|
2013-12-18 17:47:20 +08:00
|
|
|
bool initWithAction(ActionInterval *action);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Inner action */
|
2013-06-20 14:13:12 +08:00
|
|
|
ActionInterval *_innerAction;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(RepeatForever);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class Spawn
|
|
|
|
* @brief Spawn a new action immediately
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Spawn : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Helper constructor to create an array of spawned actions.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @code
|
2015-09-22 16:08:23 +08:00
|
|
|
* When this function bound to the js or lua, the input params changed.
|
2013-09-13 11:41:20 +08:00
|
|
|
* in js :var create(var object1,var object2, ...)
|
|
|
|
* in lua :local create(local object1,local object2, ...)
|
|
|
|
* @endcode
|
2015-03-18 20:40:29 +08:00
|
|
|
*
|
|
|
|
* @return An autoreleased Spawn object.
|
2013-09-13 11:41:20 +08:00
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static Spawn* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION;
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Helper constructor to create an array of spawned actions.
|
|
|
|
*
|
|
|
|
* @param action1 The first sequenceable action.
|
|
|
|
* @param args The va_list variable.
|
|
|
|
* @return An autoreleased Spawn object.
|
2015-03-19 18:41:11 +08:00
|
|
|
* @js NA
|
2015-03-18 20:40:29 +08:00
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static Spawn* createWithVariableList(FiniteTimeAction *action1, va_list args);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Helper constructor to create an array of spawned actions given an array.
|
|
|
|
*
|
|
|
|
* @param arrayOfActions An array of spawned actions.
|
|
|
|
* @return An autoreleased Spawn object.
|
|
|
|
*/
|
2013-11-28 11:04:39 +08:00
|
|
|
static Spawn* create(const Vector<FiniteTimeAction*>& arrayOfActions);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates the Spawn action.
|
|
|
|
*
|
|
|
|
* @param action1 The first spawned action.
|
2015-12-03 20:00:51 +08:00
|
|
|
* @param action2 The second spawned action.
|
2015-03-18 20:40:29 +08:00
|
|
|
* @return An autoreleased Spawn object.
|
2015-03-19 18:41:11 +08:00
|
|
|
* @js NA
|
2015-03-18 20:40:29 +08:00
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static Spawn* createWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual Spawn* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual Spawn* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual void stop() override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-27 12:07:19 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2016-04-08 13:40:36 +08:00
|
|
|
Spawn();
|
2013-11-22 09:06:06 +08:00
|
|
|
virtual ~Spawn();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the Spawn action with the 2 actions to spawn */
|
2013-12-18 17:47:20 +08:00
|
|
|
bool initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2);
|
2015-12-04 04:16:21 +08:00
|
|
|
bool init(const Vector<FiniteTimeAction*>& arrayOfActions);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-20 14:13:12 +08:00
|
|
|
FiniteTimeAction *_one;
|
|
|
|
FiniteTimeAction *_two;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Spawn);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class RotateTo
|
|
|
|
* @brief Rotates a Node object to a certain angle by modifying it's rotation attribute.
|
2010-08-06 10:51:40 +08:00
|
|
|
The direction will be decided by the shortest angle.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL RotateTo : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with separate rotation angles.
|
|
|
|
*
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param dstAngleX In degreesCW.
|
|
|
|
* @param dstAngleY In degreesCW.
|
|
|
|
* @return An autoreleased RotateTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-08-01 04:37:21 +08:00
|
|
|
static RotateTo* create(float duration, float dstAngleX, float dstAngleY);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
*
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param dstAngle In degreesCW.
|
|
|
|
* @return An autoreleased RotateTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-08-01 04:37:21 +08:00
|
|
|
static RotateTo* create(float duration, float dstAngle);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with 3D rotation angles.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param dstAngle3D A Vec3 angle.
|
|
|
|
* @return An autoreleased RotateTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-08-01 04:37:21 +08:00
|
|
|
static RotateTo* create(float duration, const Vec3& dstAngle3D);
|
2014-07-31 03:01:18 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual RotateTo* clone() const override;
|
|
|
|
virtual RotateTo* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-27 12:07:19 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2012-11-15 17:16:51 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2014-07-31 03:01:18 +08:00
|
|
|
RotateTo();
|
2013-11-22 09:06:06 +08:00
|
|
|
virtual ~RotateTo() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action
|
|
|
|
* @param duration in seconds
|
|
|
|
* @param dstAngleX in degreesCW
|
|
|
|
* @param dstAngleY in degreesCW
|
|
|
|
*/
|
2014-08-01 04:37:21 +08:00
|
|
|
bool initWithDuration(float duration, float dstAngleX, float dstAngleY);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2014-08-01 04:37:21 +08:00
|
|
|
bool initWithDuration(float duration, const Vec3& dstAngle3D);
|
2014-07-31 03:01:18 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* calculates the start and diff angles
|
|
|
|
* @param dstAngle in degreesCW
|
|
|
|
*/
|
2014-07-31 03:01:18 +08:00
|
|
|
void calculateAngles(float &startAngle, float &diffAngle, float dstAngle);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
protected:
|
2014-07-31 03:01:18 +08:00
|
|
|
bool _is3D;
|
2014-08-01 04:37:21 +08:00
|
|
|
Vec3 _dstAngle;
|
|
|
|
Vec3 _startAngle;
|
|
|
|
Vec3 _diffAngle;
|
2014-07-31 03:01:18 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(RotateTo);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class RotateBy
|
|
|
|
* @brief Rotates a Node object clockwise a number of degrees by modifying it's rotation attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL RotateBy : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
*
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param deltaAngle In degreesCW.
|
|
|
|
* @return An autoreleased RotateBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static RotateBy* create(float duration, float deltaAngle);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with separate rotation angles.
|
|
|
|
*
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param deltaAngleZ_X In degreesCW.
|
|
|
|
* @param deltaAngleZ_Y In degreesCW.
|
|
|
|
* @return An autoreleased RotateBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
* @warning The physics body contained in Node doesn't support rotate with different x and y angle.
|
|
|
|
*/
|
2014-02-23 11:16:42 +08:00
|
|
|
static RotateBy* create(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates the action with 3D rotation angles.
|
|
|
|
*
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param deltaAngle3D A Vec3 angle.
|
|
|
|
* @return An autoreleased RotateBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
static RotateBy* create(float duration, const Vec3& deltaAngle3D);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Override
|
|
|
|
//
|
|
|
|
virtual RotateBy* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual RotateBy* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2012-11-15 17:16:51 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2014-02-23 11:16:42 +08:00
|
|
|
RotateBy();
|
2013-11-22 09:06:06 +08:00
|
|
|
virtual ~RotateBy() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action */
|
2013-12-18 17:47:20 +08:00
|
|
|
bool initWithDuration(float duration, float deltaAngle);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* @warning The physics body contained in Node doesn't support rotate with different x and y angle.
|
|
|
|
* @param deltaAngleZ_X in degreesCW
|
|
|
|
* @param deltaAngleZ_Y in degreesCW
|
|
|
|
*/
|
2014-02-23 11:16:42 +08:00
|
|
|
bool initWithDuration(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
|
2014-05-15 01:07:09 +08:00
|
|
|
bool initWithDuration(float duration, const Vec3& deltaAngle3D);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
protected:
|
2014-02-23 11:16:42 +08:00
|
|
|
bool _is3D;
|
2014-08-01 05:28:33 +08:00
|
|
|
Vec3 _deltaAngle;
|
|
|
|
Vec3 _startAngle;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(RotateBy);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class MoveBy
|
|
|
|
* @brief Moves a Node object x,y pixels by modifying it's position attribute.
|
2013-06-14 08:25:14 +08:00
|
|
|
x and y are relative to the position of the object.
|
2013-06-20 14:13:12 +08:00
|
|
|
Several MoveBy actions can be concurrently called, and the resulting
|
2013-06-14 08:25:14 +08:00
|
|
|
movement will be the sum of individual movements.
|
|
|
|
@since v2.1beta2-custom
|
2012-12-26 18:59:31 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL MoveBy : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
*
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param deltaPosition The delta distance in 2d, it's a Vec2 type.
|
|
|
|
* @return An autoreleased MoveBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
static MoveBy* create(float duration, const Vec2& deltaPosition);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
*
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param deltaPosition The delta distance in 3d, it's a Vec3 type.
|
|
|
|
* @return An autoreleased MoveBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-12-22 14:34:35 +08:00
|
|
|
static MoveBy* create(float duration, const Vec3& deltaPosition);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual MoveBy* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual MoveBy* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* @param time in seconds
|
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2014-12-22 14:34:35 +08:00
|
|
|
MoveBy():_is3D(false) {}
|
2013-11-22 09:06:06 +08:00
|
|
|
virtual ~MoveBy() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action */
|
2014-05-15 01:07:09 +08:00
|
|
|
bool initWithDuration(float duration, const Vec2& deltaPosition);
|
2014-12-22 14:34:35 +08:00
|
|
|
bool initWithDuration(float duration, const Vec3& deltaPosition);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2014-12-22 14:34:35 +08:00
|
|
|
bool _is3D;
|
|
|
|
Vec3 _positionDelta;
|
|
|
|
Vec3 _startPosition;
|
|
|
|
Vec3 _previousPosition;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MoveBy);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class MoveTo
|
|
|
|
* @brief Moves a Node object to the position x,y. x and y are absolute coordinates by modifying it's position attribute.
|
2013-06-20 14:13:12 +08:00
|
|
|
Several MoveTo actions can be concurrently called, and the resulting
|
2013-06-14 08:25:14 +08:00
|
|
|
movement will be the sum of individual movements.
|
|
|
|
@since v2.1beta2-custom
|
2012-12-26 18:59:31 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL MoveTo : public MoveBy
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param position The destination position in 2d.
|
|
|
|
* @return An autoreleased MoveTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
static MoveTo* create(float duration, const Vec2& position);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param position The destination position in 3d.
|
|
|
|
* @return An autoreleased MoveTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-12-22 14:34:35 +08:00
|
|
|
static MoveTo* create(float duration, const Vec3& position);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual MoveTo* clone() const override;
|
2015-03-10 13:50:53 +08:00
|
|
|
virtual MoveTo* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
MoveTo() {}
|
|
|
|
virtual ~MoveTo() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
bool initWithDuration(float duration, const Vec2& position);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2014-12-22 14:34:35 +08:00
|
|
|
bool initWithDuration(float duration, const Vec3& position);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2014-12-22 14:34:35 +08:00
|
|
|
Vec3 _endPosition;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MoveTo);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class SkewTo
|
|
|
|
* @brief Skews a Node object to given angles by modifying it's skewX and skewY attributes
|
2012-04-19 14:35:52 +08:00
|
|
|
@since v1.0
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL SkewTo : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param t Duration time, in seconds.
|
|
|
|
* @param sx Skew x angle.
|
|
|
|
* @param sy Skew y angle.
|
|
|
|
* @return An autoreleased SkewTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
static SkewTo* create(float t, float sx, float sy);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual SkewTo* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual SkewTo* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
SkewTo();
|
|
|
|
virtual ~SkewTo() {}
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param t In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithDuration(float t, float sx, float sy);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _skewX;
|
|
|
|
float _skewY;
|
|
|
|
float _startSkewX;
|
|
|
|
float _startSkewY;
|
|
|
|
float _endSkewX;
|
|
|
|
float _endSkewY;
|
|
|
|
float _deltaX;
|
|
|
|
float _deltaY;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(SkewTo);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class SkewBy
|
|
|
|
* @brief Skews a Node object by skewX and skewY degrees.
|
2012-04-19 14:35:52 +08:00
|
|
|
@since v1.0
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL SkewBy : public SkewTo
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param t Duration time, in seconds.
|
|
|
|
* @param deltaSkewX Skew x delta angle.
|
|
|
|
* @param deltaSkewY Skew y delta angle.
|
|
|
|
* @return An autoreleased SkewBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static SkewBy* create(float t, float deltaSkewX, float deltaSkewY);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual SkewBy* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual SkewBy* reverse() const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
SkewBy() {}
|
|
|
|
virtual ~SkewBy() {}
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param t In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithDuration(float t, float sx, float sy);
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(SkewBy);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2016-08-16 16:55:31 +08:00
|
|
|
/** @class ResizeTo
|
|
|
|
* @brief Resize a Node object to the final size by modifying it's Size attribute.
|
|
|
|
*/
|
|
|
|
class CC_DLL ResizeTo : public ActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates the action.
|
|
|
|
* @brief Resize a Node object to the final size by modifying it's Size attribute. Works on all nodes where setContentSize is effective. But it's mostly useful for nodes where 9-slice is enabled
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param final_size The target size to reach
|
|
|
|
* @return An autoreleased RotateTo object.
|
|
|
|
*/
|
|
|
|
static ResizeTo* create(float duration, const cocos2d::Size& final_size);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual ResizeTo* clone() const override;
|
|
|
|
void startWithTarget(cocos2d::Node* target) override;
|
|
|
|
void update(float time) override;
|
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
|
|
ResizeTo() {}
|
|
|
|
virtual ~ResizeTo() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* initializes the action
|
|
|
|
* @param duration in seconds
|
|
|
|
* @param final_size in Size type
|
|
|
|
*/
|
|
|
|
bool initWithDuration(float duration, const cocos2d::Size& final_size);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
cocos2d::Size _initialSize;
|
|
|
|
cocos2d::Size _finalSize;
|
|
|
|
cocos2d::Size _sizeDelta;
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ResizeTo);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** @class ResizeBy
|
|
|
|
* @brief Resize a Node object by a Size. Works on all nodes where setContentSize is effective. But it's mostly useful for nodes where 9-slice is enabled
|
|
|
|
*/
|
|
|
|
class CC_DLL ResizeBy : public ActionInterval
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates the action.
|
|
|
|
*
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param deltaSize The delta size.
|
|
|
|
* @return An autoreleased ResizeBy object.
|
|
|
|
*/
|
|
|
|
static ResizeBy* create(float duration, const cocos2d::Size& deltaSize);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual ResizeBy* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual ResizeBy* reverse() const override;
|
2016-08-16 16:55:31 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
|
|
|
/**
|
|
|
|
* @param time in seconds
|
|
|
|
*/
|
|
|
|
virtual void update(float time) override;
|
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
|
|
ResizeBy() {}
|
|
|
|
virtual ~ResizeBy() {}
|
|
|
|
|
|
|
|
/** initializes the action */
|
|
|
|
bool initWithDuration(float duration, const cocos2d::Size& deltaSize);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
cocos2d::Size _sizeDelta;
|
|
|
|
cocos2d::Size _startSize;
|
|
|
|
cocos2d::Size _previousSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ResizeBy);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class JumpBy
|
|
|
|
* @brief Moves a Node object simulating a parabolic jump movement by modifying it's position attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL JumpBy : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param position The jumping distance.
|
|
|
|
* @param height The jumping height.
|
|
|
|
* @param jumps The jumping times.
|
|
|
|
* @return An autoreleased JumpBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
static JumpBy* create(float duration, const Vec2& position, float height, int jumps);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual JumpBy* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual JumpBy* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
JumpBy() {}
|
|
|
|
virtual ~JumpBy() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
bool initWithDuration(float duration, const Vec2& position, float height, int jumps);
|
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 _startPosition;
|
|
|
|
Vec2 _delta;
|
2013-06-15 14:03:30 +08:00
|
|
|
float _height;
|
2013-07-20 13:01:27 +08:00
|
|
|
int _jumps;
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 _previousPos;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(JumpBy);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class JumpTo
|
|
|
|
* @brief Moves a Node object to a parabolic position simulating a jump movement by modifying it's position attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL JumpTo : public JumpBy
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param position The jumping destination position.
|
|
|
|
* @param height The jumping height.
|
|
|
|
* @param jumps The jumping times.
|
|
|
|
* @return An autoreleased JumpTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-05-15 01:07:09 +08:00
|
|
|
static JumpTo* create(float duration, const Vec2& position, float height, int jumps);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Override
|
|
|
|
//
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual JumpTo* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual JumpTo* reverse() const override;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-07-10 14:00:23 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
JumpTo() {}
|
|
|
|
virtual ~JumpTo() {}
|
2014-07-10 14:30:08 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param duration In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2015-01-03 00:13:57 +08:00
|
|
|
bool initWithDuration(float duration, const Vec2& position, float height, int jumps);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Vec2 _endPosition;
|
|
|
|
|
2014-07-10 14:30:08 +08:00
|
|
|
private:
|
2013-11-22 09:06:06 +08:00
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(JumpTo);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @struct Bezier configuration structure
|
2010-08-06 10:51:40 +08:00
|
|
|
*/
|
|
|
|
typedef struct _ccBezierConfig {
|
2012-04-19 14:35:52 +08:00
|
|
|
//! end position of the bezier
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 endPosition;
|
2012-04-19 14:35:52 +08:00
|
|
|
//! Bezier control point 1
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 controlPoint_1;
|
2012-04-19 14:35:52 +08:00
|
|
|
//! Bezier control point 2
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 controlPoint_2;
|
2012-04-19 14:35:52 +08:00
|
|
|
} ccBezierConfig;
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class BezierBy
|
|
|
|
* @brief An action that moves the target with a cubic Bezier curve by a certain distance.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL BezierBy : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates the action with a duration and a bezier configuration.
|
|
|
|
* @param t Duration time, in seconds.
|
|
|
|
* @param c Bezier config.
|
|
|
|
* @return An autoreleased BezierBy object.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @code
|
2015-03-18 20:40:29 +08:00
|
|
|
* When this function bound to js or lua,the input params are changed.
|
2013-09-13 11:41:20 +08:00
|
|
|
* in js: var create(var t,var table)
|
2015-12-03 20:00:51 +08:00
|
|
|
* in lua: local create(local t, local table)
|
2013-09-13 11:41:20 +08:00
|
|
|
* @endcode
|
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
static BezierBy* create(float t, const ccBezierConfig& c);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual BezierBy* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual BezierBy* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
BezierBy() {}
|
|
|
|
virtual ~BezierBy() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action with a duration and a bezier configuration
|
|
|
|
* @param t in seconds
|
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithDuration(float t, const ccBezierConfig& c);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
ccBezierConfig _config;
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 _startPosition;
|
|
|
|
Vec2 _previousPosition;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(BezierBy);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class BezierTo
|
|
|
|
* @brief An action that moves the target with a cubic Bezier curve to a destination point.
|
2010-08-06 10:51:40 +08:00
|
|
|
@since v0.8.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL BezierTo : public BezierBy
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates the action with a duration and a bezier configuration.
|
|
|
|
* @param t Duration time, in seconds.
|
|
|
|
* @param c Bezier config.
|
|
|
|
* @return An autoreleased BezierTo object.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @code
|
|
|
|
* when this function bound to js or lua,the input params are changed
|
|
|
|
* in js: var create(var t,var table)
|
2015-12-03 20:00:51 +08:00
|
|
|
* in lua: local create(local t, local table)
|
2013-09-13 11:41:20 +08:00
|
|
|
* @endcode
|
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
static BezierTo* create(float t, const ccBezierConfig& c);
|
2013-07-08 23:05:47 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
|
|
|
virtual BezierTo* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual BezierTo* reverse() const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
BezierTo() {}
|
|
|
|
virtual ~BezierTo() {}
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param t In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithDuration(float t, const ccBezierConfig &c);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
ccBezierConfig _toConfig;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(BezierTo);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class ScaleTo
|
|
|
|
@brief Scales a Node object to a zoom factor by modifying it's scale attribute.
|
|
|
|
@warning This action doesn't support "reverse".
|
2014-06-23 13:55:52 +08:00
|
|
|
@warning The physics body contained in Node doesn't support this action.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ScaleTo : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with the same scale factor for X and Y.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param s Scale factor of x and y.
|
|
|
|
* @return An autoreleased ScaleTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
static ScaleTo* create(float duration, float s);
|
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with and X factor and a Y factor.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param sx Scale factor of x.
|
|
|
|
* @param sy Scale factor of y.
|
|
|
|
* @return An autoreleased ScaleTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
static ScaleTo* create(float duration, float sx, float sy);
|
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with X Y Z factor.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param sx Scale factor of x.
|
|
|
|
* @param sy Scale factor of y.
|
|
|
|
* @param sz Scale factor of z.
|
|
|
|
* @return An autoreleased ScaleTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-03-19 16:23:14 +08:00
|
|
|
static ScaleTo* create(float duration, float sx, float sy, float sz);
|
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual ScaleTo* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual ScaleTo* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
ScaleTo() {}
|
|
|
|
virtual ~ScaleTo() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action with the same scale factor for X and Y
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithDuration(float duration, float s);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action with and X factor and a Y factor
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithDuration(float duration, float sx, float sy);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action with X Y Z factor
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2014-03-19 16:23:14 +08:00
|
|
|
bool initWithDuration(float duration, float sx, float sy, float sz);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _scaleX;
|
|
|
|
float _scaleY;
|
2014-03-19 16:23:14 +08:00
|
|
|
float _scaleZ;
|
2013-06-15 14:03:30 +08:00
|
|
|
float _startScaleX;
|
|
|
|
float _startScaleY;
|
2014-03-19 16:23:14 +08:00
|
|
|
float _startScaleZ;
|
2013-06-15 14:03:30 +08:00
|
|
|
float _endScaleX;
|
|
|
|
float _endScaleY;
|
2014-03-19 16:23:14 +08:00
|
|
|
float _endScaleZ;
|
2013-06-15 14:03:30 +08:00
|
|
|
float _deltaX;
|
|
|
|
float _deltaY;
|
2014-03-19 16:23:14 +08:00
|
|
|
float _deltaZ;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ScaleTo);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class ScaleBy
|
|
|
|
* @brief Scales a Node object a zoom factor by modifying it's scale attribute.
|
2014-06-23 13:55:52 +08:00
|
|
|
@warning The physics body contained in Node doesn't support this action.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ScaleBy : public ScaleTo
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with the same scale factor for X and Y.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param s Scale factor of x and y.
|
|
|
|
* @return An autoreleased ScaleBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static ScaleBy* create(float duration, float s);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with and X factor and a Y factor.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param sx Scale factor of x.
|
|
|
|
* @param sy Scale factor of y.
|
|
|
|
* @return An autoreleased ScaleBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static ScaleBy* create(float duration, float sx, float sy);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action with X Y Z factor.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param sx Scale factor of x.
|
|
|
|
* @param sy Scale factor of y.
|
|
|
|
* @param sz Scale factor of z.
|
|
|
|
* @return An autoreleased ScaleBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-03-19 16:23:14 +08:00
|
|
|
static ScaleBy* create(float duration, float sx, float sy, float sz);
|
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual ScaleBy* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual ScaleBy* reverse() const override;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-07-10 14:00:23 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
ScaleBy() {}
|
|
|
|
virtual ~ScaleBy() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ScaleBy);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class Blink
|
|
|
|
* @brief Blinks a Node object by modifying it's visible attribute.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Blink : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param blinks Blink times.
|
|
|
|
* @return An autoreleased Blink object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-20 13:01:27 +08:00
|
|
|
static Blink* create(float duration, int blinks);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual Blink* clone() const override;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual Blink* reverse() const override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void stop() override;
|
2012-11-15 17:16:51 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
Blink() {}
|
|
|
|
virtual ~Blink() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithDuration(float duration, int blinks);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
protected:
|
2013-07-20 13:01:27 +08:00
|
|
|
int _times;
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _originalState;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Blink);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2014-02-25 15:30:54 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class FadeTo
|
|
|
|
* @brief Fades an object that implements the RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
|
2014-02-25 15:30:54 +08:00
|
|
|
@warning This action doesn't support "reverse"
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2014-02-25 15:30:54 +08:00
|
|
|
class CC_DLL FadeTo : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates an action with duration and opacity.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param opacity A certain opacity, the range is from 0 to 255.
|
|
|
|
* @return An autoreleased FadeTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2019-06-05 17:58:33 +08:00
|
|
|
static FadeTo* create(float duration, uint8_t opacity);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2014-02-25 15:30:54 +08:00
|
|
|
virtual FadeTo* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual FadeTo* reverse() const override;
|
2014-02-25 15:30:54 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2014-02-25 15:30:54 +08:00
|
|
|
FadeTo() {}
|
|
|
|
virtual ~FadeTo() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
|
|
|
* initializes the action with duration and opacity
|
|
|
|
* @param duration in seconds
|
|
|
|
*/
|
2019-06-05 17:58:33 +08:00
|
|
|
bool initWithDuration(float duration, uint8_t opacity);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2019-06-05 17:58:33 +08:00
|
|
|
uint8_t _toOpacity;
|
|
|
|
uint8_t _fromOpacity;
|
2014-02-25 15:30:54 +08:00
|
|
|
friend class FadeOut;
|
|
|
|
friend class FadeIn;
|
2013-11-22 09:06:06 +08:00
|
|
|
private:
|
2014-02-25 15:30:54 +08:00
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(FadeTo);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class FadeIn
|
|
|
|
* @brief Fades In an object that implements the RGBAProtocol protocol. It modifies the opacity from 0 to 255.
|
2014-02-25 15:30:54 +08:00
|
|
|
The "reverse" of this action is FadeOut
|
|
|
|
*/
|
|
|
|
class CC_DLL FadeIn : public FadeTo
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param d Duration time, in seconds.
|
|
|
|
* @return An autoreleased FadeIn object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-02-25 15:30:54 +08:00
|
|
|
static FadeIn* create(float d);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2014-02-25 15:30:54 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
|
|
|
virtual FadeIn* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual FadeTo* reverse() const override;
|
2015-03-19 18:41:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2014-02-25 15:30:54 +08:00
|
|
|
void setReverseAction(FadeTo* ac);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-07-10 14:00:23 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2014-02-25 15:30:54 +08:00
|
|
|
FadeIn():_reverseAction(nullptr) {}
|
|
|
|
virtual ~FadeIn() {}
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
2014-02-25 15:30:54 +08:00
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(FadeIn);
|
|
|
|
FadeTo* _reverseAction;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class FadeOut
|
|
|
|
* @brief Fades Out an object that implements the RGBAProtocol protocol. It modifies the opacity from 255 to 0.
|
2014-02-25 15:30:54 +08:00
|
|
|
The "reverse" of this action is FadeIn
|
|
|
|
*/
|
|
|
|
class CC_DLL FadeOut : public FadeTo
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param d Duration time, in seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2014-02-25 15:30:54 +08:00
|
|
|
static FadeOut* create(float d);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2014-02-25 15:30:54 +08:00
|
|
|
virtual FadeOut* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual FadeTo* reverse() const override;
|
2015-03-19 18:41:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2014-02-25 15:30:54 +08:00
|
|
|
void setReverseAction(FadeTo* ac);
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2014-07-10 14:00:23 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2014-02-25 15:30:54 +08:00
|
|
|
FadeOut():_reverseAction(nullptr) {}
|
|
|
|
virtual ~FadeOut() {}
|
2013-11-22 09:06:06 +08:00
|
|
|
private:
|
2014-02-25 15:30:54 +08:00
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(FadeOut);
|
|
|
|
FadeTo* _reverseAction;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
2015-03-18 20:40:29 +08:00
|
|
|
|
|
|
|
/** @class TintTo
|
|
|
|
* @brief Tints a Node that implements the NodeRGB protocol from current tint to a custom one.
|
2010-08-06 10:51:40 +08:00
|
|
|
@warning This action doesn't support "reverse"
|
|
|
|
@since v0.7.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL TintTo : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates an action with duration and color.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param red Red Color, from 0 to 255.
|
|
|
|
* @param green Green Color, from 0 to 255.
|
|
|
|
* @param blue Blue Color, from 0 to 255.
|
|
|
|
* @return An autoreleased TintTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2019-06-05 17:58:33 +08:00
|
|
|
static TintTo* create(float duration, uint8_t red, uint8_t green, uint8_t blue);
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates an action with duration and color.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param color It's a Color3B type.
|
|
|
|
* @return An autoreleased TintTo object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2015-01-14 17:04:23 +08:00
|
|
|
static TintTo* create(float duration, const Color3B& color);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual TintTo* clone() const override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual TintTo* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
TintTo() {}
|
|
|
|
virtual ~TintTo() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action with duration and color */
|
2019-06-05 17:58:33 +08:00
|
|
|
bool initWithDuration(float duration, uint8_t red, uint8_t green, uint8_t blue);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-07-05 16:49:22 +08:00
|
|
|
Color3B _to;
|
|
|
|
Color3B _from;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(TintTo);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class TintBy
|
|
|
|
@brief Tints a Node that implements the NodeRGB protocol from current tint to a custom one.
|
2010-08-06 10:51:40 +08:00
|
|
|
@since v0.7.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL TintBy : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates an action with duration and color.
|
|
|
|
* @param duration Duration time, in seconds.
|
|
|
|
* @param deltaRed Delta red color.
|
|
|
|
* @param deltaGreen Delta green color.
|
|
|
|
* @param deltaBlue Delta blue color.
|
|
|
|
* @return An autoreleased TintBy object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2019-06-05 17:58:33 +08:00
|
|
|
static TintBy* create(float duration, int16_t deltaRed, int16_t deltaGreen, int16_t deltaBlue);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual TintBy* clone() const override;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual TintBy* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
TintBy() {}
|
|
|
|
virtual ~TintBy() {}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action with duration and color */
|
2019-06-05 17:58:33 +08:00
|
|
|
bool initWithDuration(float duration, int16_t deltaRed, int16_t deltaGreen, int16_t deltaBlue);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2019-06-05 17:58:33 +08:00
|
|
|
int16_t _deltaR;
|
|
|
|
int16_t _deltaG;
|
|
|
|
int16_t _deltaB;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2019-06-05 17:58:33 +08:00
|
|
|
int16_t _fromR;
|
|
|
|
int16_t _fromG;
|
|
|
|
int16_t _fromB;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(TintBy);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class DelayTime
|
|
|
|
* @brief Delays the action a certain amount of seconds.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL DelayTime : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* Creates the action.
|
|
|
|
* @param d Duration time, in seconds.
|
|
|
|
* @return An autoreleased DelayTime object.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static DelayTime* create(float d);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual DelayTime* reverse() const override;
|
|
|
|
virtual DelayTime* clone() const override;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-07-10 14:00:23 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
DelayTime() {}
|
|
|
|
virtual ~DelayTime() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(DelayTime);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class ReverseTime
|
|
|
|
* @brief Executes an action in reverse order, from time=duration to time=0
|
2010-08-06 10:51:40 +08:00
|
|
|
|
|
|
|
@warning Use this action carefully. This action is not
|
|
|
|
sequenceable. Use it as the default "reversed" method
|
|
|
|
of your own actions, but using it outside the "reversed"
|
|
|
|
scope is not recommended.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ReverseTime : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates the action.
|
|
|
|
*
|
|
|
|
* @param action a certain action.
|
|
|
|
* @return An autoreleased ReverseTime object.
|
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static ReverseTime* create(FiniteTimeAction *action);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual ReverseTime* reverse() const override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual ReverseTime* clone() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual void stop() override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
ReverseTime();
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual ~ReverseTime();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action */
|
2013-12-18 17:47:20 +08:00
|
|
|
bool initWithAction(FiniteTimeAction *action);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-20 14:13:12 +08:00
|
|
|
FiniteTimeAction *_other;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ReverseTime);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class Texture2D;
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class Animate
|
|
|
|
* @brief Animates a sprite given the name of an Animation.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Animate : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Creates the action with an Animation and will restore the original frame when the animation is over.
|
|
|
|
*
|
|
|
|
* @param animation A certain animation.
|
|
|
|
* @return An autoreleased Animate object.
|
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static Animate* create(Animation *animation);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Sets the Animation object to be animated
|
|
|
|
*
|
2015-03-27 17:09:54 +08:00
|
|
|
* @param animation certain animation.
|
2015-03-18 20:40:29 +08:00
|
|
|
*/
|
2013-07-20 04:16:38 +08:00
|
|
|
void setAnimation( Animation* animation );
|
2015-03-18 20:40:29 +08:00
|
|
|
/** returns the Animation object that is being animated
|
|
|
|
*
|
|
|
|
* @return Gets the animation object that is being animated.
|
|
|
|
*/
|
2013-07-20 04:16:38 +08:00
|
|
|
Animation* getAnimation() { return _animation; }
|
|
|
|
const Animation* getAnimation() const { return _animation; }
|
|
|
|
|
2015-07-13 10:40:43 +08:00
|
|
|
/**
|
|
|
|
* Gets the index of sprite frame currently displayed.
|
|
|
|
* @return int the index of sprite frame currently displayed.
|
|
|
|
*/
|
|
|
|
int getCurrentFrameIndex() { return _currFrameIndex; }
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual Animate* clone() const override;
|
|
|
|
virtual Animate* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual void stop() override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param t In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float t) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
Animate();
|
|
|
|
virtual ~Animate();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** initializes the action with an Animation and will restore the original frame when the animation is over */
|
2013-12-18 17:47:20 +08:00
|
|
|
bool initWithAnimation(Animation *animation);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
std::vector<float>* _splitTimes = new std::vector<float>;
|
|
|
|
int _nextFrame = 0;
|
|
|
|
SpriteFrame* _origFrame = nullptr;
|
|
|
|
int _currFrameIndex = 0;
|
|
|
|
unsigned int _executedLoops = 0;
|
|
|
|
Animation* _animation = nullptr;
|
|
|
|
|
|
|
|
EventCustom* _frameDisplayedEvent = nullptr;
|
2014-05-13 17:29:05 +08:00
|
|
|
AnimationFrame::DisplayedEventInfo _frameDisplayedEventInfo;
|
2013-11-22 09:06:06 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(Animate);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** @class TargetedAction
|
|
|
|
* @brief Overrides the target of an action so that it always runs on the target
|
2012-04-19 14:35:52 +08:00
|
|
|
* specified at action creation rather than the one specified by runAction.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL TargetedAction : public ActionInterval
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Create an action with the specified action and forced target.
|
|
|
|
*
|
|
|
|
* @param target The target needs to override.
|
|
|
|
* @param action The action needs to override.
|
|
|
|
* @return An autoreleased TargetedAction object.
|
|
|
|
*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static TargetedAction* create(Node* target, FiniteTimeAction* action);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
/** Sets the target that the action will be forced to run with.
|
|
|
|
*
|
|
|
|
* @param forcedTarget The target that the action will be forced to run with.
|
|
|
|
*/
|
2013-07-20 04:16:38 +08:00
|
|
|
void setForcedTarget(Node* forcedTarget);
|
2015-03-18 20:40:29 +08:00
|
|
|
/** returns the target that the action is forced to run with.
|
|
|
|
*
|
|
|
|
* @return The target that the action is forced to run with.
|
|
|
|
*/
|
2013-07-20 04:16:38 +08:00
|
|
|
Node* getForcedTarget() { return _forcedTarget; }
|
|
|
|
const Node* getForcedTarget() const { return _forcedTarget; }
|
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual TargetedAction* clone() const override;
|
|
|
|
virtual TargetedAction* reverse() const override;
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2017-06-08 17:07:43 +08:00
|
|
|
virtual void stop() override;
|
2015-01-20 15:41:59 +08:00
|
|
|
/**
|
2015-03-18 20:40:29 +08:00
|
|
|
* @param time In seconds.
|
2015-01-20 15:41:59 +08:00
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
TargetedAction();
|
|
|
|
virtual ~TargetedAction();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
/** Init an action with the specified action and forced target */
|
2013-12-18 17:47:20 +08:00
|
|
|
bool initWithTarget(Node* target, FiniteTimeAction* action);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-20 14:13:12 +08:00
|
|
|
FiniteTimeAction* _action;
|
2013-07-20 04:16:38 +08:00
|
|
|
Node* _forcedTarget;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(TargetedAction);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2015-04-18 20:35:14 +08:00
|
|
|
/**
|
2015-04-28 17:48:19 +08:00
|
|
|
* @class ActionFloat
|
2015-04-18 20:35:14 +08:00
|
|
|
* @brief Action used to animate any value in range [from,to] over specified time interval
|
|
|
|
*/
|
2015-04-28 17:48:19 +08:00
|
|
|
class CC_DLL ActionFloat : public ActionInterval
|
2015-04-18 20:35:14 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Callback function used to report back result
|
|
|
|
*/
|
2015-04-28 17:48:19 +08:00
|
|
|
typedef std::function<void(float value)> ActionFloatCallback;
|
2015-04-18 20:35:14 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates FloatAction with specified duration, from value, to value and callback to report back
|
|
|
|
* results
|
2015-04-28 17:48:19 +08:00
|
|
|
* @param duration of the action
|
|
|
|
* @param from value to start from
|
|
|
|
* @param to value to be at the end of the action
|
2015-04-18 20:35:14 +08:00
|
|
|
* @param callback to report back result
|
|
|
|
*
|
2015-04-28 17:48:19 +08:00
|
|
|
* @return An autoreleased ActionFloat object
|
2015-04-18 20:35:14 +08:00
|
|
|
*/
|
2015-04-28 17:48:19 +08:00
|
|
|
static ActionFloat* create(float duration, float from, float to, ActionFloatCallback callback);
|
2015-04-18 20:35:14 +08:00
|
|
|
|
|
|
|
/**
|
2015-09-22 16:08:23 +08:00
|
|
|
* Overridden ActionInterval methods
|
2015-04-18 20:35:14 +08:00
|
|
|
*/
|
|
|
|
void startWithTarget(Node* target) override;
|
|
|
|
void update(float delta) override;
|
2015-04-28 17:48:19 +08:00
|
|
|
ActionFloat* reverse() const override;
|
|
|
|
ActionFloat* clone() const override;
|
2015-04-18 20:35:14 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2015-04-28 17:48:19 +08:00
|
|
|
ActionFloat() {};
|
|
|
|
virtual ~ActionFloat() {};
|
2015-04-18 20:35:14 +08:00
|
|
|
|
2015-04-28 17:48:19 +08:00
|
|
|
bool initWithDuration(float duration, float from, float to, ActionFloatCallback callback);
|
2015-04-18 20:35:14 +08:00
|
|
|
|
|
|
|
protected:
|
2015-04-28 17:48:19 +08:00
|
|
|
/* From value */
|
2015-04-18 20:35:14 +08:00
|
|
|
float _from;
|
2015-04-28 17:48:19 +08:00
|
|
|
/* To value */
|
2015-04-18 20:35:14 +08:00
|
|
|
float _to;
|
2015-04-28 17:48:19 +08:00
|
|
|
/* delta time */
|
2015-04-18 20:35:14 +08:00
|
|
|
float _delta;
|
|
|
|
|
2015-04-28 17:48:19 +08:00
|
|
|
/* Callback to report back results */
|
|
|
|
ActionFloatCallback _callback;
|
2015-04-18 20:35:14 +08:00
|
|
|
private:
|
2015-04-28 17:48:19 +08:00
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ActionFloat);
|
2015-04-18 20:35:14 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of actions group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif //__ACTION_CCINTERVAL_ACTION_H__
|