12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688 |
- /****************************************************************************
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011 Zynga Inc.
- Copyright (c) 2010-2012 cocos2d-x.org
- Copyright (c) 2013-2016 Chukong Technologies Inc.
- Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
- 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__
- #include <vector>
- #include "2d/CCAction.h"
- #include "2d/CCAnimation.h"
- #include "base/CCProtocols.h"
- #include "base/CCVector.h"
- NS_CC_BEGIN
- class Node;
- class SpriteFrame;
- class EventCustom;
- /**
- * @addtogroup actions
- * @{
- */
- /** @class ActionInterval
- @brief An interval action is an action that takes place within a certain period of time.
- It has an start time, and a finish time. The finish time is the parameter
- duration plus the start time.
- These ActionInterval actions have some interesting properties, like:
- - 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.
- For example, you can simulate a Ping Pong effect running the action normally and
- then running it again in Reverse mode.
- Example:
- @code
- auto action = MoveBy::create(1.0f, Vec2::ONE);
- auto pingPongAction = Sequence::create(action, action->reverse(), nullptr);
- @endcode
- */
- class CC_DLL ActionInterval : public FiniteTimeAction
- {
- public:
- /** How many seconds had elapsed since the actions started to run.
- *
- * @return The seconds had elapsed since the actions started to run.
- */
- float getElapsed() { return _elapsed; }
- /** Sets the amplitude rate, extension in GridAction
- *
- * @param amp The amplitude rate.
- */
- void setAmplitudeRate(float amp);
-
- /** Gets the amplitude rate, extension in GridAction
- *
- * @return The amplitude rate.
- */
- float getAmplitudeRate();
- //
- // Overrides
- //
- virtual bool isDone() const override;
- /**
- * @param dt in seconds
- */
- virtual void step(float dt) override;
- virtual void startWithTarget(Node *target) override;
- virtual ActionInterval* reverse() const override
- {
- CC_ASSERT(0);
- return nullptr;
- }
- virtual ActionInterval *clone() const override
- {
- CC_ASSERT(0);
- return nullptr;
- }
- CC_CONSTRUCTOR_ACCESS:
- /** initializes the action */
- bool initWithDuration(float d);
- protected:
- float _elapsed;
- bool _firstTick;
- bool _done;
-
- protected:
- bool sendUpdateEventToScript(float dt, Action *actionObject);
- };
- /** @class Sequence
- * @brief Runs actions sequentially, one after another.
- */
- class CC_DLL Sequence : public ActionInterval
- {
- public:
- /** Helper constructor to create an array of sequenceable actions.
- *
- * @return An autoreleased Sequence object.
- */
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
- // VS2013 does not support nullptr in variable args lists and variadic templates are also not supported
- 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
- static Sequence* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION;
- #endif
- /** Helper constructor to create an array of sequenceable actions given an array.
- * @code
- * When this function bound to the js or lua,the input params changed
- * in js :var create(var object1,var object2, ...)
- * in lua :local create(local object1,local object2, ...)
- * @endcode
- *
- * @param arrayOfActions An array of sequenceable actions.
- * @return An autoreleased Sequence object.
- */
- static Sequence* create(const Vector<FiniteTimeAction*>& arrayOfActions);
- /** 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.
- * @js NA
- */
- static Sequence* createWithVariableList(FiniteTimeAction *action1, va_list args);
- /** Creates the action.
- * @param actionOne The first sequenceable action.
- * @param actionTwo The second sequenceable action.
- * @return An autoreleased Sequence object.
- * @js NA
- */
- static Sequence* createWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo);
- //
- // Overrides
- //
- virtual Sequence* clone() const override;
- virtual Sequence* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- virtual void stop() override;
- virtual bool isDone() const override;
- /**
- * @param t In seconds.
- */
- virtual void update(float t) override;
-
- CC_CONSTRUCTOR_ACCESS:
- Sequence();
- virtual ~Sequence();
- /** initializes the action */
- bool initWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo);
- bool init(const Vector<FiniteTimeAction*>& arrayOfActions);
- protected:
- FiniteTimeAction *_actions[2];
- float _split;
- int _last;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(Sequence);
- };
- /** @class Repeat
- * @brief Repeats an action a number of times.
- * To repeat an action forever use the RepeatForever action.
- */
- class CC_DLL Repeat : public ActionInterval
- {
- public:
- /** 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.
- */
- static Repeat* create(FiniteTimeAction *action, unsigned int times);
- /** Sets the inner action.
- *
- * @param action The inner action.
- */
- void setInnerAction(FiniteTimeAction *action)
- {
- if (_innerAction != action)
- {
- CC_SAFE_RETAIN(action);
- CC_SAFE_RELEASE(_innerAction);
- _innerAction = action;
- }
- }
- /** Gets the inner action.
- *
- * @return The inner action.
- */
- FiniteTimeAction* getInnerAction()
- {
- return _innerAction;
- }
- //
- // Overrides
- //
- virtual Repeat* clone() const override;
- virtual Repeat* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- virtual void stop(void) override;
- /**
- * @param dt In seconds.
- */
- virtual void update(float dt) override;
- virtual bool isDone(void) const override;
-
- CC_CONSTRUCTOR_ACCESS:
- Repeat() {}
- virtual ~Repeat();
- /** initializes a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */
- bool initWithAction(FiniteTimeAction *pAction, unsigned int times);
- protected:
- unsigned int _times;
- unsigned int _total;
- float _nextDt;
- bool _actionInstant;
- /** Inner action */
- FiniteTimeAction *_innerAction;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(Repeat);
- };
- /** @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.
- */
- class CC_DLL RepeatForever : public ActionInterval
- {
- public:
- /** Creates the action.
- *
- * @param action The action need to repeat forever.
- * @return An autoreleased RepeatForever object.
- */
- static RepeatForever* create(ActionInterval *action);
- /** Sets the inner action.
- *
- * @param action The inner action.
- */
- void setInnerAction(ActionInterval *action)
- {
- if (_innerAction != action)
- {
- CC_SAFE_RELEASE(_innerAction);
- _innerAction = action;
- CC_SAFE_RETAIN(_innerAction);
- }
- }
- /** Gets the inner action.
- *
- * @return The inner action.
- */
- ActionInterval* getInnerAction()
- {
- return _innerAction;
- }
- //
- // Overrides
- //
- virtual RepeatForever* clone() const override;
- virtual RepeatForever* reverse(void) const override;
- virtual void startWithTarget(Node* target) override;
- /**
- * @param dt In seconds.
- */
- virtual void step(float dt) override;
- virtual bool isDone(void) const override;
-
- CC_CONSTRUCTOR_ACCESS:
- RepeatForever()
- : _innerAction(nullptr)
- {}
- virtual ~RepeatForever();
- /** initializes the action */
- bool initWithAction(ActionInterval *action);
- protected:
- /** Inner action */
- ActionInterval *_innerAction;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(RepeatForever);
- };
- /** @class Spawn
- * @brief Spawn a new action immediately
- */
- class CC_DLL Spawn : public ActionInterval
- {
- public:
- /** Helper constructor to create an array of spawned actions.
- * @code
- * When this function bound to the js or lua, the input params changed.
- * in js :var create(var object1,var object2, ...)
- * in lua :local create(local object1,local object2, ...)
- * @endcode
- *
- * @return An autoreleased Spawn object.
- */
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
- // VS2013 does not support nullptr in variable args lists and variadic templates are also not supported.
- 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); }
- // On WP8 for variable argument lists longer than 10 items, use the other create functions or createSpawn with NULL as the last argument.
- static Spawn* variadicCreate(FiniteTimeAction* item, ...);
- #else
- static Spawn* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION;
- #endif
- /** 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.
- * @js NA
- */
- static Spawn* createWithVariableList(FiniteTimeAction *action1, va_list args);
- /** Helper constructor to create an array of spawned actions given an array.
- *
- * @param arrayOfActions An array of spawned actions.
- * @return An autoreleased Spawn object.
- */
- static Spawn* create(const Vector<FiniteTimeAction*>& arrayOfActions);
- /** Creates the Spawn action.
- *
- * @param action1 The first spawned action.
- * @param action2 The second spawned action.
- * @return An autoreleased Spawn object.
- * @js NA
- */
- static Spawn* createWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2);
- //
- // Overrides
- //
- virtual Spawn* clone() const override;
- virtual Spawn* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- virtual void stop() override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- Spawn();
- virtual ~Spawn();
- /** initializes the Spawn action with the 2 actions to spawn */
- bool initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2);
- bool init(const Vector<FiniteTimeAction*>& arrayOfActions);
- protected:
- FiniteTimeAction *_one;
- FiniteTimeAction *_two;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(Spawn);
- };
- /** @class RotateTo
- * @brief Rotates a Node object to a certain angle by modifying it's rotation attribute.
- The direction will be decided by the shortest angle.
- */
- class CC_DLL RotateTo : public ActionInterval
- {
- public:
- /**
- * 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.
- */
- static RotateTo* create(float duration, float dstAngleX, float dstAngleY);
- /**
- * Creates the action.
- *
- * @param duration Duration time, in seconds.
- * @param dstAngle In degreesCW.
- * @return An autoreleased RotateTo object.
- */
- static RotateTo* create(float duration, float dstAngle);
- /**
- * Creates the action with 3D rotation angles.
- * @param duration Duration time, in seconds.
- * @param dstAngle3D A Vec3 angle.
- * @return An autoreleased RotateTo object.
- */
- static RotateTo* create(float duration, const Vec3& dstAngle3D);
- //
- // Overrides
- //
- virtual RotateTo* clone() const override;
- virtual RotateTo* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- RotateTo();
- virtual ~RotateTo() {}
- /**
- * initializes the action
- * @param duration in seconds
- * @param dstAngleX in degreesCW
- * @param dstAngleY in degreesCW
- */
- bool initWithDuration(float duration, float dstAngleX, float dstAngleY);
- /**
- * initializes the action
- * @param duration in seconds
- */
- bool initWithDuration(float duration, const Vec3& dstAngle3D);
- /**
- * calculates the start and diff angles
- * @param dstAngle in degreesCW
- */
- void calculateAngles(float &startAngle, float &diffAngle, float dstAngle);
-
- protected:
- bool _is3D;
- Vec3 _dstAngle;
- Vec3 _startAngle;
- Vec3 _diffAngle;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(RotateTo);
- };
- /** @class RotateBy
- * @brief Rotates a Node object clockwise a number of degrees by modifying it's rotation attribute.
- */
- class CC_DLL RotateBy : public ActionInterval
- {
- public:
- /**
- * Creates the action.
- *
- * @param duration Duration time, in seconds.
- * @param deltaAngle In degreesCW.
- * @return An autoreleased RotateBy object.
- */
- static RotateBy* create(float duration, float deltaAngle);
- /**
- * 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.
- * @warning The physics body contained in Node doesn't support rotate with different x and y angle.
- */
- static RotateBy* create(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
- /** Creates the action with 3D rotation angles.
- *
- * @param duration Duration time, in seconds.
- * @param deltaAngle3D A Vec3 angle.
- * @return An autoreleased RotateBy object.
- */
- static RotateBy* create(float duration, const Vec3& deltaAngle3D);
- //
- // Override
- //
- virtual RotateBy* clone() const override;
- virtual RotateBy* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- RotateBy();
- virtual ~RotateBy() {}
- /** initializes the action */
- bool initWithDuration(float duration, float deltaAngle);
- /**
- * @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
- */
- bool initWithDuration(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
- bool initWithDuration(float duration, const Vec3& deltaAngle3D);
-
- protected:
- bool _is3D;
- Vec3 _deltaAngle;
- Vec3 _startAngle;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(RotateBy);
- };
- /** @class MoveBy
- * @brief Moves a Node object x,y pixels by modifying it's position attribute.
- x and y are relative to the position of the object.
- Several MoveBy actions can be concurrently called, and the resulting
- movement will be the sum of individual movements.
- @since v2.1beta2-custom
- */
- class CC_DLL MoveBy : public ActionInterval
- {
- public:
- /**
- * 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.
- */
- static MoveBy* create(float duration, const Vec2& deltaPosition);
- /**
- * 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.
- */
- static MoveBy* create(float duration, const Vec3& deltaPosition);
- //
- // Overrides
- //
- virtual MoveBy* clone() const override;
- virtual MoveBy* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time in seconds
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- MoveBy():_is3D(false) {}
- virtual ~MoveBy() {}
- /** initializes the action */
- bool initWithDuration(float duration, const Vec2& deltaPosition);
- bool initWithDuration(float duration, const Vec3& deltaPosition);
- protected:
- bool _is3D;
- Vec3 _positionDelta;
- Vec3 _startPosition;
- Vec3 _previousPosition;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(MoveBy);
- };
- /** @class MoveTo
- * @brief Moves a Node object to the position x,y. x and y are absolute coordinates by modifying it's position attribute.
- Several MoveTo actions can be concurrently called, and the resulting
- movement will be the sum of individual movements.
- @since v2.1beta2-custom
- */
- class CC_DLL MoveTo : public MoveBy
- {
- public:
- /**
- * Creates the action.
- * @param duration Duration time, in seconds.
- * @param position The destination position in 2d.
- * @return An autoreleased MoveTo object.
- */
- static MoveTo* create(float duration, const Vec2& position);
- /**
- * Creates the action.
- * @param duration Duration time, in seconds.
- * @param position The destination position in 3d.
- * @return An autoreleased MoveTo object.
- */
- static MoveTo* create(float duration, const Vec3& position);
- //
- // Overrides
- //
- virtual MoveTo* clone() const override;
- virtual MoveTo* reverse() const override;
- virtual void startWithTarget(Node *target) override;
-
- CC_CONSTRUCTOR_ACCESS:
- MoveTo() {}
- virtual ~MoveTo() {}
- /**
- * initializes the action
- * @param duration in seconds
- */
- bool initWithDuration(float duration, const Vec2& position);
- /**
- * initializes the action
- * @param duration in seconds
- */
- bool initWithDuration(float duration, const Vec3& position);
- protected:
- Vec3 _endPosition;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(MoveTo);
- };
- /** @class SkewTo
- * @brief Skews a Node object to given angles by modifying it's skewX and skewY attributes
- @since v1.0
- */
- class CC_DLL SkewTo : public ActionInterval
- {
- public:
- /**
- * Creates the action.
- * @param t Duration time, in seconds.
- * @param sx Skew x angle.
- * @param sy Skew y angle.
- * @return An autoreleased SkewTo object.
- */
- static SkewTo* create(float t, float sx, float sy);
- //
- // Overrides
- //
- virtual SkewTo* clone() const override;
- virtual SkewTo* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- SkewTo();
- virtual ~SkewTo() {}
- /**
- * @param t In seconds.
- */
- bool initWithDuration(float t, float sx, float sy);
- protected:
- float _skewX;
- float _skewY;
- float _startSkewX;
- float _startSkewY;
- float _endSkewX;
- float _endSkewY;
- float _deltaX;
- float _deltaY;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(SkewTo);
- };
- /** @class SkewBy
- * @brief Skews a Node object by skewX and skewY degrees.
- @since v1.0
- */
- class CC_DLL SkewBy : public SkewTo
- {
- public:
- /**
- * 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.
- */
- static SkewBy* create(float t, float deltaSkewX, float deltaSkewY);
- //
- // Overrides
- //
- virtual void startWithTarget(Node *target) override;
- virtual SkewBy* clone() const override;
- virtual SkewBy* reverse() const override;
-
- CC_CONSTRUCTOR_ACCESS:
- SkewBy() {}
- virtual ~SkewBy() {}
- /**
- * @param t In seconds.
- */
- bool initWithDuration(float t, float sx, float sy);
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(SkewBy);
- };
- /** @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() 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);
- };
- /** @class JumpBy
- * @brief Moves a Node object simulating a parabolic jump movement by modifying it's position attribute.
- */
- class CC_DLL JumpBy : public ActionInterval
- {
- public:
- /**
- * 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.
- */
- static JumpBy* create(float duration, const Vec2& position, float height, int jumps);
- //
- // Overrides
- //
- virtual JumpBy* clone() const override;
- virtual JumpBy* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- JumpBy() {}
- virtual ~JumpBy() {}
- /**
- * initializes the action
- * @param duration in seconds
- */
- bool initWithDuration(float duration, const Vec2& position, float height, int jumps);
- protected:
- Vec2 _startPosition;
- Vec2 _delta;
- float _height;
- int _jumps;
- Vec2 _previousPos;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(JumpBy);
- };
- /** @class JumpTo
- * @brief Moves a Node object to a parabolic position simulating a jump movement by modifying it's position attribute.
- */
- class CC_DLL JumpTo : public JumpBy
- {
- public:
- /**
- * 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.
- */
- static JumpTo* create(float duration, const Vec2& position, float height, int jumps);
- //
- // Override
- //
- virtual void startWithTarget(Node *target) override;
- virtual JumpTo* clone() const override;
- virtual JumpTo* reverse() const override;
- CC_CONSTRUCTOR_ACCESS:
- JumpTo() {}
- virtual ~JumpTo() {}
- /**
- * initializes the action
- * @param duration In seconds.
- */
- bool initWithDuration(float duration, const Vec2& position, float height, int jumps);
- protected:
- Vec2 _endPosition;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(JumpTo);
- };
- /** @struct Bezier configuration structure
- */
- typedef struct _ccBezierConfig {
- //! end position of the bezier
- Vec2 endPosition;
- //! Bezier control point 1
- Vec2 controlPoint_1;
- //! Bezier control point 2
- Vec2 controlPoint_2;
- } ccBezierConfig;
- /** @class BezierBy
- * @brief An action that moves the target with a cubic Bezier curve by a certain distance.
- */
- class CC_DLL BezierBy : public ActionInterval
- {
- public:
- /** 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.
- * @code
- * When this function bound to js or lua,the input params are changed.
- * in js: var create(var t,var table)
- * in lua: local create(local t, local table)
- * @endcode
- */
- static BezierBy* create(float t, const ccBezierConfig& c);
- //
- // Overrides
- //
- virtual BezierBy* clone() const override;
- virtual BezierBy* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- BezierBy() {}
- virtual ~BezierBy() {}
- /**
- * initializes the action with a duration and a bezier configuration
- * @param t in seconds
- */
- bool initWithDuration(float t, const ccBezierConfig& c);
- protected:
- ccBezierConfig _config;
- Vec2 _startPosition;
- Vec2 _previousPosition;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(BezierBy);
- };
- /** @class BezierTo
- * @brief An action that moves the target with a cubic Bezier curve to a destination point.
- @since v0.8.2
- */
- class CC_DLL BezierTo : public BezierBy
- {
- public:
- /** 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.
- * @code
- * when this function bound to js or lua,the input params are changed
- * in js: var create(var t,var table)
- * in lua: local create(local t, local table)
- * @endcode
- */
- static BezierTo* create(float t, const ccBezierConfig& c);
- //
- // Overrides
- //
- virtual void startWithTarget(Node *target) override;
- virtual BezierTo* clone() const override;
- virtual BezierTo* reverse() const override;
-
- CC_CONSTRUCTOR_ACCESS:
- BezierTo() {}
- virtual ~BezierTo() {}
- /**
- * @param t In seconds.
- */
- bool initWithDuration(float t, const ccBezierConfig &c);
- protected:
- ccBezierConfig _toConfig;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(BezierTo);
- };
- /** @class ScaleTo
- @brief Scales a Node object to a zoom factor by modifying it's scale attribute.
- @warning This action doesn't support "reverse".
- @warning The physics body contained in Node doesn't support this action.
- */
- class CC_DLL ScaleTo : public ActionInterval
- {
- public:
- /**
- * 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.
- */
- static ScaleTo* create(float duration, float s);
- /**
- * 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.
- */
- static ScaleTo* create(float duration, float sx, float sy);
- /**
- * 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.
- */
- static ScaleTo* create(float duration, float sx, float sy, float sz);
- //
- // Overrides
- //
- virtual ScaleTo* clone() const override;
- virtual ScaleTo* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- ScaleTo() {}
- virtual ~ScaleTo() {}
- /**
- * initializes the action with the same scale factor for X and Y
- * @param duration in seconds
- */
- bool initWithDuration(float duration, float s);
- /**
- * initializes the action with and X factor and a Y factor
- * @param duration in seconds
- */
- bool initWithDuration(float duration, float sx, float sy);
- /**
- * initializes the action with X Y Z factor
- * @param duration in seconds
- */
- bool initWithDuration(float duration, float sx, float sy, float sz);
- protected:
- float _scaleX;
- float _scaleY;
- float _scaleZ;
- float _startScaleX;
- float _startScaleY;
- float _startScaleZ;
- float _endScaleX;
- float _endScaleY;
- float _endScaleZ;
- float _deltaX;
- float _deltaY;
- float _deltaZ;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(ScaleTo);
- };
- /** @class ScaleBy
- * @brief Scales a Node object a zoom factor by modifying it's scale attribute.
- @warning The physics body contained in Node doesn't support this action.
- */
- class CC_DLL ScaleBy : public ScaleTo
- {
- public:
- /**
- * 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.
- */
- static ScaleBy* create(float duration, float s);
- /**
- * 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.
- */
- static ScaleBy* create(float duration, float sx, float sy);
- /**
- * 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.
- */
- static ScaleBy* create(float duration, float sx, float sy, float sz);
- //
- // Overrides
- //
- virtual void startWithTarget(Node *target) override;
- virtual ScaleBy* clone() const override;
- virtual ScaleBy* reverse() const override;
- CC_CONSTRUCTOR_ACCESS:
- ScaleBy() {}
- virtual ~ScaleBy() {}
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(ScaleBy);
- };
- /** @class Blink
- * @brief Blinks a Node object by modifying it's visible attribute.
- */
- class CC_DLL Blink : public ActionInterval
- {
- public:
- /**
- * Creates the action.
- * @param duration Duration time, in seconds.
- * @param blinks Blink times.
- * @return An autoreleased Blink object.
- */
- static Blink* create(float duration, int blinks);
- //
- // Overrides
- //
- virtual Blink* clone() const override;
- virtual Blink* reverse() const override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
- virtual void startWithTarget(Node *target) override;
- virtual void stop() override;
-
- CC_CONSTRUCTOR_ACCESS:
- Blink() {}
- virtual ~Blink() {}
- /**
- * initializes the action
- * @param duration in seconds
- */
- bool initWithDuration(float duration, int blinks);
-
- protected:
- int _times;
- bool _originalState;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(Blink);
- };
- /** @class FadeTo
- * @brief Fades an object that implements the RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
- @warning This action doesn't support "reverse"
- */
- class CC_DLL FadeTo : public ActionInterval
- {
- public:
- /**
- * 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.
- */
- static FadeTo* create(float duration, GLubyte opacity);
- //
- // Overrides
- //
- virtual FadeTo* clone() const override;
- virtual FadeTo* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- FadeTo() {}
- virtual ~FadeTo() {}
- /**
- * initializes the action with duration and opacity
- * @param duration in seconds
- */
- bool initWithDuration(float duration, GLubyte opacity);
- protected:
- GLubyte _toOpacity;
- GLubyte _fromOpacity;
- friend class FadeOut;
- friend class FadeIn;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(FadeTo);
- };
- /** @class FadeIn
- * @brief Fades In an object that implements the RGBAProtocol protocol. It modifies the opacity from 0 to 255.
- The "reverse" of this action is FadeOut
- */
- class CC_DLL FadeIn : public FadeTo
- {
- public:
- /**
- * Creates the action.
- * @param d Duration time, in seconds.
- * @return An autoreleased FadeIn object.
- */
- static FadeIn* create(float d);
- //
- // Overrides
- //
- virtual void startWithTarget(Node *target) override;
- virtual FadeIn* clone() const override;
- virtual FadeTo* reverse() const override;
- /**
- * @js NA
- */
- void setReverseAction(FadeTo* ac);
- CC_CONSTRUCTOR_ACCESS:
- FadeIn():_reverseAction(nullptr) {}
- virtual ~FadeIn() {}
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(FadeIn);
- FadeTo* _reverseAction;
- };
- /** @class FadeOut
- * @brief Fades Out an object that implements the RGBAProtocol protocol. It modifies the opacity from 255 to 0.
- The "reverse" of this action is FadeIn
- */
- class CC_DLL FadeOut : public FadeTo
- {
- public:
- /**
- * Creates the action.
- * @param d Duration time, in seconds.
- */
- static FadeOut* create(float d);
- //
- // Overrides
- //
- virtual void startWithTarget(Node *target) override;
- virtual FadeOut* clone() const override;
- virtual FadeTo* reverse() const override;
- /**
- * @js NA
- */
- void setReverseAction(FadeTo* ac);
- CC_CONSTRUCTOR_ACCESS:
- FadeOut():_reverseAction(nullptr) {}
- virtual ~FadeOut() {}
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(FadeOut);
- FadeTo* _reverseAction;
- };
- /** @class TintTo
- * @brief Tints a Node that implements the NodeRGB protocol from current tint to a custom one.
- @warning This action doesn't support "reverse"
- @since v0.7.2
- */
- class CC_DLL TintTo : public ActionInterval
- {
- public:
- /**
- * 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.
- */
- static TintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue);
- /**
- * 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.
- */
- static TintTo* create(float duration, const Color3B& color);
- //
- // Overrides
- //
- virtual TintTo* clone() const override;
- virtual TintTo* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- TintTo() {}
- virtual ~TintTo() {}
- /** initializes the action with duration and color */
- bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue);
- protected:
- Color3B _to;
- Color3B _from;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(TintTo);
- };
- /** @class TintBy
- @brief Tints a Node that implements the NodeRGB protocol from current tint to a custom one.
- @since v0.7.2
- */
- class CC_DLL TintBy : public ActionInterval
- {
- public:
- /**
- * 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.
- */
- static TintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
- //
- // Overrides
- //
- virtual TintBy* clone() const override;
- virtual TintBy* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- TintBy() {}
- virtual ~TintBy() {}
- /** initializes the action with duration and color */
- bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
- protected:
- GLshort _deltaR;
- GLshort _deltaG;
- GLshort _deltaB;
- GLshort _fromR;
- GLshort _fromG;
- GLshort _fromB;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(TintBy);
- };
- /** @class DelayTime
- * @brief Delays the action a certain amount of seconds.
- */
- class CC_DLL DelayTime : public ActionInterval
- {
- public:
- /**
- * Creates the action.
- * @param d Duration time, in seconds.
- * @return An autoreleased DelayTime object.
- */
- static DelayTime* create(float d);
- //
- // Overrides
- //
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
- virtual DelayTime* reverse() const override;
- virtual DelayTime* clone() const override;
- CC_CONSTRUCTOR_ACCESS:
- DelayTime() {}
- virtual ~DelayTime() {}
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(DelayTime);
- };
- /** @class ReverseTime
- * @brief Executes an action in reverse order, from time=duration to time=0
-
- @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.
- */
- class CC_DLL ReverseTime : public ActionInterval
- {
- public:
- /** Creates the action.
- *
- * @param action a certain action.
- * @return An autoreleased ReverseTime object.
- */
- static ReverseTime* create(FiniteTimeAction *action);
- //
- // Overrides
- //
- virtual ReverseTime* reverse() const override;
- virtual ReverseTime* clone() const override;
- virtual void startWithTarget(Node *target) override;
- virtual void stop() override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- ReverseTime();
- virtual ~ReverseTime();
- /** initializes the action */
- bool initWithAction(FiniteTimeAction *action);
- protected:
- FiniteTimeAction *_other;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(ReverseTime);
- };
- class Texture2D;
- /** @class Animate
- * @brief Animates a sprite given the name of an Animation.
- */
- class CC_DLL Animate : public ActionInterval
- {
- public:
- /** 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.
- */
- static Animate* create(Animation *animation);
- /** Sets the Animation object to be animated
- *
- * @param animation certain animation.
- */
- void setAnimation( Animation* animation );
- /** returns the Animation object that is being animated
- *
- * @return Gets the animation object that is being animated.
- */
- Animation* getAnimation() { return _animation; }
- const Animation* getAnimation() const { return _animation; }
- /**
- * Gets the index of sprite frame currently displayed.
- * @return int the index of sprite frame currently displayed.
- */
- int getCurrentFrameIndex() { return _currFrameIndex; }
- //
- // Overrides
- //
- virtual Animate* clone() const override;
- virtual Animate* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- virtual void stop() override;
- /**
- * @param t In seconds.
- */
- virtual void update(float t) override;
-
- CC_CONSTRUCTOR_ACCESS:
- Animate();
- virtual ~Animate();
- /** initializes the action with an Animation and will restore the original frame when the animation is over */
- bool initWithAnimation(Animation *animation);
- protected:
- std::vector<float>* _splitTimes;
- int _nextFrame;
- SpriteFrame* _origFrame;
- int _currFrameIndex;
- unsigned int _executedLoops;
- Animation* _animation;
- EventCustom* _frameDisplayedEvent;
- AnimationFrame::DisplayedEventInfo _frameDisplayedEventInfo;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(Animate);
- };
- /** @class TargetedAction
- * @brief Overrides the target of an action so that it always runs on the target
- * specified at action creation rather than the one specified by runAction.
- */
- class CC_DLL TargetedAction : public ActionInterval
- {
- public:
- /** 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.
- */
- static TargetedAction* create(Node* target, FiniteTimeAction* action);
- /** 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.
- */
- void setForcedTarget(Node* forcedTarget);
- /** returns the target that the action is forced to run with.
- *
- * @return The target that the action is forced to run with.
- */
- Node* getForcedTarget() { return _forcedTarget; }
- const Node* getForcedTarget() const { return _forcedTarget; }
- //
- // Overrides
- //
- virtual TargetedAction* clone() const override;
- virtual TargetedAction* reverse() const override;
- virtual void startWithTarget(Node *target) override;
- virtual void stop() override;
- /**
- * @param time In seconds.
- */
- virtual void update(float time) override;
-
- CC_CONSTRUCTOR_ACCESS:
- TargetedAction();
- virtual ~TargetedAction();
- /** Init an action with the specified action and forced target */
- bool initWithTarget(Node* target, FiniteTimeAction* action);
- protected:
- FiniteTimeAction* _action;
- Node* _forcedTarget;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(TargetedAction);
- };
- /**
- * @class ActionFloat
- * @brief Action used to animate any value in range [from,to] over specified time interval
- */
- class CC_DLL ActionFloat : public ActionInterval
- {
- public:
- /**
- * Callback function used to report back result
- */
- typedef std::function<void(float value)> ActionFloatCallback;
- /**
- * Creates FloatAction with specified duration, from value, to value and callback to report back
- * results
- * @param duration of the action
- * @param from value to start from
- * @param to value to be at the end of the action
- * @param callback to report back result
- *
- * @return An autoreleased ActionFloat object
- */
- static ActionFloat* create(float duration, float from, float to, ActionFloatCallback callback);
- /**
- * Overridden ActionInterval methods
- */
- void startWithTarget(Node* target) override;
- void update(float delta) override;
- ActionFloat* reverse() const override;
- ActionFloat* clone() const override;
- CC_CONSTRUCTOR_ACCESS:
- ActionFloat() {};
- virtual ~ActionFloat() {};
- bool initWithDuration(float duration, float from, float to, ActionFloatCallback callback);
- protected:
- /* From value */
- float _from;
- /* To value */
- float _to;
- /* delta time */
- float _delta;
- /* Callback to report back results */
- ActionFloatCallback _callback;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(ActionFloat);
- };
- // end of actions group
- /// @}
- NS_CC_END
- #endif //__ACTION_CCINTERVAL_ACTION_H__
|