forked from cocos2d/cocos2d-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCCActionInterval.h
768 lines (634 loc) · 23 KB
/
CCActionInterval.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2008-2011 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
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 "base_nodes/CCNode.h"
#include "CCAction.h"
#include "CCProtocols.h"
#include "sprite_nodes/CCSpriteFrame.h"
#include "sprite_nodes/CCAnimation.h"
#include <vector>
NS_CC_BEGIN
/**
* @addtogroup actions
* @{
*/
/**
@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 CCActionInterval 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:
CCAction *pingPongAction = CCSequence::actions(action, action->reverse(), NULL);
*/
class CC_DLL CCActionInterval : public CCFiniteTimeAction
{
public:
/** how many seconds had elapsed since the actions started to run. */
inline float getElapsed(void) { return m_elapsed; }
/** initializes the action */
bool initWithDuration(float d);
/** returns true if the action has finished */
virtual bool isDone(void);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void step(float dt);
virtual void startWithTarget(CCNode *pTarget);
/** returns a reversed action */
virtual CCActionInterval* reverse(void);
public:
/** creates the action */
static CCActionInterval* create(float d);
public:
//extension in CCGridAction
void setAmplitudeRate(float amp);
float getAmplitudeRate(void);
protected:
float m_elapsed;
bool m_bFirstTick;
};
/** @brief Runs actions sequentially, one after another
*/
class CC_DLL CCSequence : public CCActionInterval
{
public:
~CCSequence(void);
/** initializes the action */
bool initWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void stop(void);
virtual void update(float t);
virtual CCActionInterval* reverse(void);
public:
/** helper constructor to create an array of sequenceable actions */
static CCSequence* create(CCFiniteTimeAction *pAction1, ...);
/** helper constructor to create an array of sequenceable actions given an array */
static CCSequence* create(CCArray *arrayOfActions);
/** helper constructor to create an array of sequence-able actions */
static CCSequence* createWithVariableList(CCFiniteTimeAction *pAction1, va_list args);
/** creates the action */
static CCSequence* createWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
protected:
CCFiniteTimeAction *m_pActions[2];
float m_split;
int m_last;
};
/** @brief Repeats an action a number of times.
* To repeat an action forever use the CCRepeatForever action.
*/
class CC_DLL CCRepeat : public CCActionInterval
{
public:
~CCRepeat(void);
/** initializes a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
bool initWithAction(CCFiniteTimeAction *pAction, unsigned int times);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void stop(void);
virtual void update(float dt);
virtual bool isDone(void);
virtual CCActionInterval* reverse(void);
inline void setInnerAction(CCFiniteTimeAction *pAction)
{
if (m_pInnerAction != pAction)
{
CC_SAFE_RETAIN(pAction);
CC_SAFE_RELEASE(m_pInnerAction);
m_pInnerAction = pAction;
}
}
inline CCFiniteTimeAction* getInnerAction()
{
return m_pInnerAction;
}
public:
/** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
static CCRepeat* create(CCFiniteTimeAction *pAction, unsigned int times);
protected:
unsigned int m_uTimes;
unsigned int m_uTotal;
float m_fNextDt;
bool m_bActionInstant;
/** Inner action */
CCFiniteTimeAction *m_pInnerAction;
};
/** @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 CCRepeatForever : public CCActionInterval
{
public:
CCRepeatForever()
: m_pInnerAction(NULL)
{}
virtual ~CCRepeatForever();
/** initializes the action */
bool initWithAction(CCActionInterval *pAction);
virtual CCObject* copyWithZone(CCZone *pZone);
virtual void startWithTarget(CCNode* pTarget);
virtual void step(float dt);
virtual bool isDone(void);
virtual CCActionInterval* reverse(void);
inline void setInnerAction(CCActionInterval *pAction)
{
if (m_pInnerAction != pAction)
{
CC_SAFE_RELEASE(m_pInnerAction);
m_pInnerAction = pAction;
CC_SAFE_RETAIN(m_pInnerAction);
}
}
inline CCActionInterval* getInnerAction()
{
return m_pInnerAction;
}
public:
/** creates the action */
static CCRepeatForever* create(CCActionInterval *pAction);
protected:
/** Inner action */
CCActionInterval *m_pInnerAction;
};
/** @brief Spawn a new action immediately
*/
class CC_DLL CCSpawn : public CCActionInterval
{
public:
~CCSpawn(void);
/** initializes the Spawn action with the 2 actions to spawn */
bool initWithTwoActions(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void stop(void);
virtual void update(float time);
virtual CCActionInterval* reverse(void);
public:
/** helper constructor to create an array of spawned actions */
static CCSpawn* create(CCFiniteTimeAction *pAction1, ...);
/** helper constructor to create an array of spawned actions */
static CCSpawn* createWithVariableList(CCFiniteTimeAction *pAction1, va_list args);
/** helper constructor to create an array of spawned actions given an array */
static CCSpawn* create(CCArray *arrayOfActions);
/** creates the Spawn action */
static CCSpawn* createWithTwoActions(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2);
protected:
CCFiniteTimeAction *m_pOne;
CCFiniteTimeAction *m_pTwo;
};
/** @brief Rotates a CCNode object to a certain angle by modifying it's
rotation attribute.
The direction will be decided by the shortest angle.
*/
class CC_DLL CCRotateTo : public CCActionInterval
{
public:
/** creates the action */
static CCRotateTo* create(float fDuration, float fDeltaAngle);
/** initializes the action */
bool initWithDuration(float fDuration, float fDeltaAngle);
/** creates the action with separate rotation angles */
static CCRotateTo* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
virtual bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
protected:
float m_fDstAngleX;
float m_fStartAngleX;
float m_fDiffAngleX;
float m_fDstAngleY;
float m_fStartAngleY;
float m_fDiffAngleY;
};
/** @brief Rotates a CCNode object clockwise a number of degrees by modifying it's rotation attribute.
*/
class CC_DLL CCRotateBy : public CCActionInterval
{
public:
/** creates the action */
static CCRotateBy* create(float fDuration, float fDeltaAngle);
/** initializes the action */
bool initWithDuration(float fDuration, float fDeltaAngle);
static CCRotateBy* create(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
virtual CCActionInterval* reverse(void);
protected:
float m_fAngleX;
float m_fStartAngleX;
float m_fAngleY;
float m_fStartAngleY;
};
/** Moves a CCNode object x,y pixels by modifying it's position attribute.
x and y are relative to the position of the object.
Several CCMoveBy actions can be concurrently called, and the resulting
movement will be the sum of individual movements.
@since v2.1beta2-custom
*/
class CC_DLL CCMoveBy : public CCActionInterval
{
public:
/** initializes the action */
bool initWithDuration(float duration, const CCPoint& deltaPosition);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual CCActionInterval* reverse(void);
virtual void update(float time);
public:
/** creates the action */
static CCMoveBy* create(float duration, const CCPoint& deltaPosition);
protected:
CCPoint m_positionDelta;
CCPoint m_startPosition;
CCPoint m_previousPosition;
};
/** Moves a CCNode object to the position x,y. x and y are absolute coordinates by modifying it's position attribute.
Several CCMoveTo actions can be concurrently called, and the resulting
movement will be the sum of individual movements.
@since v2.1beta2-custom
*/
class CC_DLL CCMoveTo : public CCMoveBy
{
public:
/** initializes the action */
bool initWithDuration(float duration, const CCPoint& position);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
public:
/** creates the action */
static CCMoveTo* create(float duration, const CCPoint& position);
protected:
CCPoint m_endPosition;
};
/** Skews a CCNode object to given angles by modifying it's skewX and skewY attributes
@since v1.0
*/
class CC_DLL CCSkewTo : public CCActionInterval
{
public:
CCSkewTo();
virtual bool initWithDuration(float t, float sx, float sy);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
public:
/** creates the action */
static CCSkewTo* create(float t, float sx, float sy);
protected:
float m_fSkewX;
float m_fSkewY;
float m_fStartSkewX;
float m_fStartSkewY;
float m_fEndSkewX;
float m_fEndSkewY;
float m_fDeltaX;
float m_fDeltaY;
};
/** Skews a CCNode object by skewX and skewY degrees
@since v1.0
*/
class CC_DLL CCSkewBy : public CCSkewTo
{
public:
virtual bool initWithDuration(float t, float sx, float sy);
virtual void startWithTarget(CCNode *pTarget);
virtual CCActionInterval* reverse(void);
public:
/** creates the action */
static CCSkewBy* create(float t, float deltaSkewX, float deltaSkewY);
};
/** @brief Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute.
*/
class CC_DLL CCJumpBy : public CCActionInterval
{
public:
/** initializes the action */
bool initWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
virtual CCActionInterval* reverse(void);
public:
/** creates the action */
static CCJumpBy* create(float duration, const CCPoint& position, float height, unsigned int jumps);
protected:
CCPoint m_startPosition;
CCPoint m_delta;
float m_height;
unsigned int m_nJumps;
CCPoint m_previousPos;
};
/** @brief Moves a CCNode object to a parabolic position simulating a jump movement by modifying it's position attribute.
*/
class CC_DLL CCJumpTo : public CCJumpBy
{
public:
virtual void startWithTarget(CCNode *pTarget);
virtual CCObject* copyWithZone(CCZone* pZone);
public:
/** creates the action */
static CCJumpTo* create(float duration, const CCPoint& position, float height, int jumps);
};
/** @typedef bezier configuration structure
*/
typedef struct _ccBezierConfig {
//! end position of the bezier
CCPoint endPosition;
//! Bezier control point 1
CCPoint controlPoint_1;
//! Bezier control point 2
CCPoint controlPoint_2;
} ccBezierConfig;
/** @brief An action that moves the target with a cubic Bezier curve by a certain distance.
*/
class CC_DLL CCBezierBy : public CCActionInterval
{
public:
/** initializes the action with a duration and a bezier configuration */
bool initWithDuration(float t, const ccBezierConfig& c);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
virtual CCActionInterval* reverse(void);
public:
/** creates the action with a duration and a bezier configuration */
static CCBezierBy* create(float t, const ccBezierConfig& c);
protected:
ccBezierConfig m_sConfig;
CCPoint m_startPosition;
CCPoint m_previousPosition;
};
/** @brief An action that moves the target with a cubic Bezier curve to a destination point.
@since v0.8.2
*/
class CC_DLL CCBezierTo : public CCBezierBy
{
public:
virtual void startWithTarget(CCNode *pTarget);
virtual CCObject* copyWithZone(CCZone* pZone);
public:
/** creates the action with a duration and a bezier configuration */
static CCBezierTo* create(float t, const ccBezierConfig& c);
bool initWithDuration(float t, const ccBezierConfig &c);
protected:
ccBezierConfig m_sToConfig;
};
/** @brief Scales a CCNode object to a zoom factor by modifying it's scale attribute.
@warning This action doesn't support "reverse"
*/
class CC_DLL CCScaleTo : public CCActionInterval
{
public:
/** initializes the action with the same scale factor for X and Y */
bool initWithDuration(float duration, float s);
/** initializes the action with and X factor and a Y factor */
bool initWithDuration(float duration, float sx, float sy);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
public:
/** creates the action with the same scale factor for X and Y */
static CCScaleTo* create(float duration, float s);
/** creates the action with and X factor and a Y factor */
static CCScaleTo* create(float duration, float sx, float sy);
protected:
float m_fScaleX;
float m_fScaleY;
float m_fStartScaleX;
float m_fStartScaleY;
float m_fEndScaleX;
float m_fEndScaleY;
float m_fDeltaX;
float m_fDeltaY;
};
/** @brief Scales a CCNode object a zoom factor by modifying it's scale attribute.
*/
class CC_DLL CCScaleBy : public CCScaleTo
{
public:
virtual void startWithTarget(CCNode *pTarget);
virtual CCActionInterval* reverse(void);
virtual CCObject* copyWithZone(CCZone* pZone);
public:
/** creates the action with the same scale factor for X and Y */
static CCScaleBy* create(float duration, float s);
/** creates the action with and X factor and a Y factor */
static CCScaleBy* create(float duration, float sx, float sy);
};
/** @brief Blinks a CCNode object by modifying it's visible attribute
*/
class CC_DLL CCBlink : public CCActionInterval
{
public:
/** initializes the action */
bool initWithDuration(float duration, unsigned int uBlinks);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void update(float time);
virtual CCActionInterval* reverse(void);
public:
/** creates the action */
static CCBlink* create(float duration, unsigned int uBlinks);
virtual void startWithTarget(CCNode *pTarget);
virtual void stop();
protected:
unsigned int m_nTimes;
bool m_bOriginalState;
};
/** @brief Fades In an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 0 to 255.
The "reverse" of this action is FadeOut
*/
class CC_DLL CCFadeIn : public CCActionInterval
{
public:
virtual void update(float time);
virtual CCActionInterval* reverse(void);
virtual CCObject* copyWithZone(CCZone* pZone);
public:
/** creates the action */
static CCFadeIn* create(float d);
};
/** @brief Fades Out an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 255 to 0.
The "reverse" of this action is FadeIn
*/
class CC_DLL CCFadeOut : public CCActionInterval
{
public:
virtual void update(float time);
virtual CCActionInterval* reverse(void);
virtual CCObject* copyWithZone(CCZone* pZone);
public:
/** creates the action */
static CCFadeOut* create(float d);
};
/** @brief Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
@warning This action doesn't support "reverse"
*/
class CC_DLL CCFadeTo : public CCActionInterval
{
public:
/** initializes the action with duration and opacity */
bool initWithDuration(float duration, GLubyte opacity);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
public:
/** creates an action with duration and opacity */
static CCFadeTo* create(float duration, GLubyte opacity);
protected:
GLubyte m_toOpacity;
GLubyte m_fromOpacity;
};
/** @brief Tints a CCNode that implements the CCNodeRGB protocol from current tint to a custom one.
@warning This action doesn't support "reverse"
@since v0.7.2
*/
class CC_DLL CCTintTo : public CCActionInterval
{
public:
/** initializes the action with duration and color */
bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
public:
/** creates an action with duration and color */
static CCTintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue);
protected:
ccColor3B m_to;
ccColor3B m_from;
};
/** @brief Tints a CCNode that implements the CCNodeRGB protocol from current tint to a custom one.
@since v0.7.2
*/
class CC_DLL CCTintBy : public CCActionInterval
{
public:
/** initializes the action with duration and color */
bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
virtual CCActionInterval* reverse(void);
public:
/** creates an action with duration and color */
static CCTintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue);
protected:
GLshort m_deltaR;
GLshort m_deltaG;
GLshort m_deltaB;
GLshort m_fromR;
GLshort m_fromG;
GLshort m_fromB;
};
/** @brief Delays the action a certain amount of seconds
*/
class CC_DLL CCDelayTime : public CCActionInterval
{
public:
virtual void update(float time);
virtual CCActionInterval* reverse(void);
virtual CCObject* copyWithZone(CCZone* pZone);
public:
/** creates the action */
static CCDelayTime* create(float d);
};
/** @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 CCReverseTime : public CCActionInterval
{
public:
~CCReverseTime(void);
CCReverseTime();
/** initializes the action */
bool initWithAction(CCFiniteTimeAction *pAction);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void stop(void);
virtual void update(float time);
virtual CCActionInterval* reverse(void);
public:
/** creates the action */
static CCReverseTime* create(CCFiniteTimeAction *pAction);
protected:
CCFiniteTimeAction *m_pOther;
};
class CCTexture2D;
/** @brief Animates a sprite given the name of an Animation */
class CC_DLL CCAnimate : public CCActionInterval
{
public:
CCAnimate();
~CCAnimate();
/** initializes the action with an Animation and will restore the original frame when the animation is over */
bool initWithAnimation(CCAnimation *pAnimation);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void stop(void);
virtual void update(float t);
virtual CCActionInterval* reverse(void);
public:
/** creates the action with an Animation and will restore the original frame when the animation is over */
static CCAnimate* create(CCAnimation *pAnimation);
CC_SYNTHESIZE_RETAIN(CCAnimation*, m_pAnimation, Animation)
protected:
std::vector<float>* m_pSplitTimes;
int m_nNextFrame;
CCSpriteFrame* m_pOrigFrame;
unsigned int m_uExecutedLoops;
};
/** 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 CCTargetedAction : public CCActionInterval
{
public:
CCTargetedAction();
virtual ~CCTargetedAction();
/** Create an action with the specified action and forced target */
static CCTargetedAction* create(CCNode* pTarget, CCFiniteTimeAction* pAction);
/** Init an action with the specified action and forced target */
bool initWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction);
virtual CCObject* copyWithZone(CCZone* pZone);
virtual void startWithTarget(CCNode *pTarget);
virtual void stop(void);
virtual void update(float time);
/** This is the target that the action will be forced to run with */
CC_SYNTHESIZE_RETAIN(CCNode*, m_pForcedTarget, ForcedTarget);
private:
CCFiniteTimeAction* m_pAction;
};
// end of actions group
/// @}
NS_CC_END
#endif //__ACTION_CCINTERVAL_ACTION_H__