Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.

특수 액션 (Special Actions)

CallFunc / CallBlock Family 액션

CCCallFunc 액션은 액션에서 메소드를 호출할 수 있게 합니다. sequence 액션의 끝에 사용할 수 있는 유용한 액션입니다.

예제:

id actionTo = [CCMoveTo actionWithDuration: 2 position: ccp(s.width-40, s.height-40)];
id actionBy = [CCMoveBy actionWithDuration: 2 position: ccp(80,80)];
id actionCallFunc = [CCCallFunc actionWithTarget:self selector:@selector(doATask)];
 
id actionSequence = [CCSequence actions: actionTo, actionBy, actionCallFunc, nil];
 
-(void) doATask
{
//some code
}

CallFuncN 과 CallFuncND 액션

CCCallFunc과 비슷한 CCCallFuncNCCCallFuncND 액션이 있습니다.

CCCallFuncN은 인자로 노드를 삽입하는 것이고, CCCallFuncND는 노드와 포인터를 다른 데이터로 인자를 사용합니다.

예제: id actionCallFuncN = [CCCallFuncN actionWithTarget:self selector:@selector(doATaskN:)]; make sure you notice the trailing : id actionCallFuncND = [CCCallFuncND actionWithTarget:self selector:@selector(doATaskND:data:) data:pointerToSomeData]; - (void) doATaskN: (id)node { some code }

- (void) doATaskND: (id)node data:(void*)d { some code } </code> ==== CallBlock / CallBlockN ==== since v0.99.2 <code objc> BCA is cocos2d macro that means: Block Copy Autorelease

CCCallBlock (no arguments) id blockAction = [CCCallBlock actionWithBlock:BCA(^{ [label setString:@“Called Block!”]; })]; CCCallBlockN (passes the Node as an argument) void (^block)(CCNode*) = BCA(^(CCNode *n) {

	// do something generic with node
	CCLOG(@"called block for %@", n);

}); id blockAction2 = [CCCallBlockN actionWithBlock:block]

</code>

CCFollow

since v0.99.2

Simulates a “Camera”. The followed node will be centered.

// create an sprite
id sprite = [CCSprite xxxx];
 
[self addChild:sprite];
 
[self runAction: [CCFollow actionWithTarget:sprite worldBoundary:CGRectMake(0, 0, (winSize.width*2)-100, winSize.height)]];

CCPropertyAction

since v0.99.2

It's a “generic” action that lets you modify any property of any objective-c class.

 // It will modify the "rotation" property from 0 to -270 in 2 seconds, and then it will run the reverse action.
	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];
ko/prog_guide/actions_special.txt · Last modified: 2011/06/23 14:07 by o_o
Trace: hello_events hello_actions basic_concepts labels actions effects tiled_maps actions_ease basic_concepts actions_special
Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0