cocos2d for i Phoneの紹介

3,772 views
3,665 views

Published on

2011/7/15に福井で開催されたiPhoneアプリ開発者勉強会の発表スライドです。
http://atnd.org/events/16933

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,772
On SlideShare
0
From Embeds
0
Number of Embeds
86
Actions
Shares
0
Downloads
1
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

cocos2d for i Phoneの紹介

  1. 1. cocos2d for iPhone
  2. 2. • cocos2d iPhone&iPad• cocos2d – – – RPG•• Game Center•••
  3. 3. cocos2d for iPhone• 2D• Objective-C•• – MIT • OK OK
  4. 4. cocos2d••
  5. 5. • – – OpenGL• – – –• – – –• –
  6. 6. • – –
  7. 7. //CCScene* scene = [CCScene node];//CCLayer* background = [MyBGLayer node];[scene addChild: background];CCLayer* mainlayer = [MyMainLayer node];[scene addChild: mainlayer];//// (0,0)CCSprite* playersprite = [CCSprite spriteWithFile:@”Player.png”];[mainlayer addChild: playersprite];
  8. 8. • Parallax•• →
  9. 9. //CCParallaxNode* paraNode = [CCParallaxNode node];[paraNode addChild:spriteSky z:1 parallaxRatio:CGPointMake(0.5f, 0) positionOffset:topOffset];[paraNode addChild:spriteMountain z:2 parallaxRatio:CGPointMake(1, 0) positionOffset:midOffset];[paraNode addChild:spriteTree z:4 parallaxRatio:CGPointMake(3, 0) positionOffset:downOffset];
  10. 10. •••••
  11. 11. // (100,200) 3CCMoveTo* move = [CCMoveTo actionWithDuration:3 position:CGPointMake(100,200)];[myNode runAction:move];//CCMoveTo* move = [CCMoveTo actionWithDuration:3 position:CGPointMake(100,200)];CCEaseInOut* ease = [CCEaseInOut actionWithAction:move rate:4];[myNode runAction:ease]//CCRotateBy* rotateBy = [CCRotateBy actionWithDuration:2 angle:360];//CCRepeatForever* repeat = [CCRepeatForever actionWithAction:rotateBy];[myNode runAction:repeat];//CCSequence* sequence = [CCSequence actions: at1, at2, at3, nil];[myNode runAction:sequence];
  12. 12. •• http://www.youtube.com/watch ?v=zMCKQl5uSYw•••
  13. 13. Particle Designer($7.99)
  14. 14. // plistCCParticleSystem* particle =[CCParticleSystemQuad particleWithFile:@”particle1.plist”];//CGSize winSize = [[CCDirector sharedDirector]winSize];particle.position = CGPointMake( winSize.width/ 2, winSize.height / 2 );[myLayer addChild:particle z:1 tag:1];
  15. 15. • 1••
  16. 16. Zwoptex• plist•
  17. 17. // plistCCSpriteFrameCache* frameCache =[CCSpriteFrameCachesharedSpriteFrameCache];[frameCache addSpriteFramesWithFile: @”texture-atlas1.plist”];//CCSpriteFrame* sprite = [frameCachespriteFrameByName:@”sprite1.png”];
  18. 18. •• –•
  19. 19. Tiled Map Editor
  20. 20. //CCTMXTiledMap* tileMap = [CCTMXTiledMaptiledMapWithFile:@”tilemap.tmx”];[myLayer addChild:tileMap z:-1 tag:1]
  21. 21. • box2d chipmunk••• box2d C++ chipmunk C
  22. 22. •••//[[CCDirector sharedDirector] pause];//[[CCDirector sharedDirector] resume];
  23. 23. •• cocos2d –
  24. 24. cocos2d1. main appDelegate2. appDelegate 1. EAGLView 2. Director [Direcotor sharedDirector]; EAGLView director 3. runWithScene [director runWithScene: firstScene]; ※ scene
  25. 25. • Layer• Layer CCTouchDispatcher• UIKit [[CCDirector sharedDirector] convertToGL:touchLocation];
  26. 26. // Layerself.isTouchEnabled = YES;self.isAccelerometerEnabled = YES;// Layer-(void) ccTouchesBegan: (NSSet *)touches withEvent:(UIEvent *)event-(void) accelerometer:(UIAccelerometer *)accelerometerdidAccelerate:(UIAcceleration *)acceleration
  27. 27. • update –1 60 1 update 60• update• n
  28. 28. // update[self scheduleUpdate];-(void) update:(ccTime)delta { //}// interval update[self schedule:@selector(myUpdate1:)interval :0.1f];-(void) myUpdate1:(ccTime)delta { // 0.1}
  29. 29. #import “SimpleAudioEngine.h”[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@”bgm.mp3” loop:YES][[SimpleAudioEngine sharedEngine] playEffect:@”se01.caf”];※ mp3
  30. 30. cocos2d iPhone&iPad• – – –•• amazon

×