How to use CCActionProperty, Does it not exist in Cocos2d 3.0?

87 views Asked by At

I was looking up the different abilities of Cocos2d, and don't quite understand what property is being modified here:

id rot = [CCPropertyAction actionWithDuration:2 key:@"rotation" from:0 to:-270];
id rot_back = [rot reverse];
id rot_seq = [CCSequence actions:rot, rot_back, nil];

Specifically, the "rotation" of what sprite? Rotation is a property of CCSprite, but I see no CCSprite here, so I'm very confused.

Furthermore, it seems to have existed in an earlier version of Cocos2d, so what has happened to it?

1

There are 1 answers

0
mattblessed On

I've never seen CCPropertyAction used... I'll show you how I would do what you exampled.

// Create rotate action
CCActionRotateBy *rotateAction = [CCActionRotateBy actionWithDuration:2.0f angle:-270];

// Create a copy of that action and reverse it
id reverseAction = [[rotateAction copy] reverse];

// Create a sequence of actions in order
CCActionSequence *sequenceAction = [CCActionSequence actions:rotateAction,reverseAction, nil];

// mySprite will run actions in order
[mySprite runAction:sequenceAction];

In previous versions of cocos2d the actions were CCRotateBy and CCSequence, they just changed names for the sake of confusion.

All cocos2d actions will have CCAction... before them to classify them as actions.