Contenu connexe
Similaire à cocos2d入門 (6)
cocos2d入門
- 24. / .::::::::::::::::::::::::;;:;;::, ::::
l , rj,r '"'"'" l :::::::
Y ,! :::::::
| ::::::::
| __ -- i::::,r
`'' - ' ´ , }::;! , .
""""´ L_
/ i , /| r
≡ - ´ ,,.._ i 't-' | , ,r
, yx=''" { ,- ; l ' r '
`-- /! `
_,, - '' ; `
-''"_,, -''" ;;' ,' /
-''" ` '' ;;;;' ,'
2011/6/25 24
/ _ =
- 26. #import “YourScene.h”
id transition = [CCTransitionFade transitionWithDuration:0.5f
scene:[YourScene scene];
[[CCDirector sharedDirector] replaceScene:transition];
2011/6/25 26
- 29. -(id) init{
if( (self=[super init])) {
// create and initialize a Label
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker
Felt" fontSize:64];
// ask director the the window size
CGSize size = [[CCDirector sharedDirector] winSize];
// position the label on the center of the screen
label.position = ccp( size.width /2 , size.height/2 );
// add the label as a child to this Layer
[self addChild: label];
self.isTouchEnabled = YES;
}
return self;
}
-(void) registerWithTouchDispatcher{
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0
swallowsTouches:YES];
}
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{
id transition = [CCTransitionFade transitionWithDuration:0.5f scene:[YourScene scene];
[[CCDirector sharedDirector] replaceScene:transition];
return YES;
}
2011/6/25 29
- 30. CCSprite sprite = [CCSprite spriteWithFile:@”sprite.png”];
//
sprite.position = ccp(100, 100); //
[self addChild:sprite]; // Sprite
2011/6/25 30
- 31. // 240, 160 3 Action
id move = [CCMoveTo actionWithDuration:3 position:ccp(240, 160)];
// 2 360 Action
id rotate = [CCRotateBy actionWithDuration:2 angle:360];
// 4 127 Action
id fade = [CCFadeTo actionWithDuration:4 opacity:127];
// Action Sequence
CCSequence* sequence = [CCSequence actions:move, rotate, fade, nil];
// Sequence Sprite
[sprite runAction:sequence];
2011/6/25 31
Notes de l'éditeur
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n