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
|
2017-02-14 14:36:57 +08:00
|
|
|
Copyright (c) 2013-2017 Chukong Technologies Inc.
|
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
|
|
|
*/
|
2012-08-01 15:30:12 +08:00
|
|
|
float getAmplitudeRate(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
|
|
|
virtual bool isDone(void) 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.
|
|
|
|
*/
|
2015-05-09 00:19:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
|
|
|
// VS2013 does not support nullptr in variable args lists and variadic templates are also not supported
|
2014-03-25 06:09:24 +08:00
|
|
|
typedef FiniteTimeAction* M;
|
|
|
|
static Sequence* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, M m3, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
|
|
|
|
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
|
|
|
|
|
|
|
|
// On WP8 for variable argument lists longer than 10 items, use the other create functions or variadicCreate with NULL as the last argument
|
|
|
|
static Sequence* variadicCreate(FiniteTimeAction* item, ...);
|
|
|
|
#else
|
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
|
|
|
#endif
|
|
|
|
|
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;
|
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 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
|
|
|
*/
|
2015-05-09 00:19:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
|
|
|
// VS2013 does not support nullptr in variable args lists and variadic templates are also not supported.
|
2014-03-25 06:09:24 +08:00
|
|
|
typedef FiniteTimeAction* M;
|
|
|
|
static Spawn* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, M m3, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
|
|
|
|
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
|
|
|
|
|
2015-03-18 20:40:29 +08:00
|
|
|
// On WP8 for variable argument lists longer than 10 items, use the other create functions or createSpawn with NULL as the last argument.
|
2014-03-25 06:09:24 +08:00
|
|
|
static Spawn* variadicCreate(FiniteTimeAction* item, ...);
|
|
|
|
#else
|
2013-12-18 17:47:20 +08:00
|
|
|
static Spawn* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION;
|
2014-03-25 06:09:24 +08:00
|
|
|
#endif
|
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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual Spawn* reverse(void) 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-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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual RotateBy* 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 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual MoveBy* 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
|
|
|
/**
|
|
|
|
* @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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual SkewTo* 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 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual SkewBy* reverse(void) 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;
|
|
|
|
virtual ResizeBy* reverse(void) const override;
|
|
|
|
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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual JumpBy* 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 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual JumpTo* reverse(void) 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual BezierBy* 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 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual BezierTo* reverse(void) 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual ScaleTo* 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 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual ScaleBy* reverse(void) 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
|
|
|
*/
|
2014-02-25 15:30:54 +08:00
|
|
|
static FadeTo* create(float duration, GLubyte opacity);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2014-02-25 15:30:54 +08:00
|
|
|
virtual FadeTo* clone() const override;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual FadeTo* reverse(void) 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
|
|
|
|
*/
|
2014-02-25 15:30:54 +08:00
|
|
|
bool initWithDuration(float duration, GLubyte opacity);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2014-02-25 15:30:54 +08:00
|
|
|
GLubyte _toOpacity;
|
|
|
|
GLubyte _fromOpacity;
|
|
|
|
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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual FadeTo* reverse(void) 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual FadeTo* reverse(void) 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
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
static TintTo* create(float duration, GLubyte red, GLubyte green, GLubyte 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;
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual TintTo* 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 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 */
|
|
|
|
bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue);
|
|
|
|
|
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
|
|
|
*/
|
2013-07-16 03:43:22 +08:00
|
|
|
static TintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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 */
|
|
|
|
bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
GLshort _deltaR;
|
|
|
|
GLshort _deltaG;
|
|
|
|
GLshort _deltaB;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
GLshort _fromR;
|
|
|
|
GLshort _fromG;
|
|
|
|
GLshort _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;
|
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 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();
|
|
|
|
virtual ~ReverseTime(void);
|
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;
|
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 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:
|
2013-06-15 14:03:30 +08:00
|
|
|
std::vector<float>* _splitTimes;
|
2013-07-20 04:16:38 +08:00
|
|
|
int _nextFrame;
|
|
|
|
SpriteFrame* _origFrame;
|
2015-07-13 10:40:43 +08:00
|
|
|
int _currFrameIndex;
|
2013-07-07 13:01:21 +08:00
|
|
|
unsigned int _executedLoops;
|
2013-07-20 04:16:38 +08:00
|
|
|
Animation* _animation;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-05-13 17:29:05 +08:00
|
|
|
EventCustom* _frameDisplayedEvent;
|
|
|
|
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;
|
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 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__
|