SlideShare une entreprise Scribd logo
1  sur  58
Télécharger pour lire hors ligne
iOS DevCamp
                         Produced by CSDN
                         Website: http://devcamp.csdn.net
                         Weibo: http://weibo.com/cmdnclub




Thursday, August 2, 12
怎样灵活使用Cocos2D




    秦春林

Thursday, August 2, 12
Don’t reinvent the wheel




Thursday, August 2, 12
“In the summer of 2008, several "pythoneros" went to a camp
   program called PyCamp: Python outdoors. This camp
   held in Cordoba, in the town of Los Cocos. We were about
   50 people. It covered different topics, one of which was seeking
   way of not having to "reinvent the wheel" in each jurisdiction
   Pyweek.
   In this way a group of friends and I decided to put together a
   framework to make games. We call cocos2d, since the framework
   is designed to make 2D games, and the word "coconut" emulates
   the place where the camp took place.”



                            Ricardo Quesada

Thursday, August 2, 12
4,000+ games




Thursday, August 2, 12
It is free!
        Without having to learn OpenGL ES to get
        started
        Active community & tests
        Lots of tools
        It is Simple


                            Why Cocos2d?

Thursday, August 2, 12
How simple?




Thursday, August 2, 12
sprite: player




                                                Action: CCMoveTo




                         layer: GameLayer

                                      scene: GameScene
                                                         UIView:EAGLView


Thursday, August 2, 12
Game has Scenes
       Each Scene has some number of Layers
       Layers capture user interaction and contain
       sprites
       Director manages the scenes


                           Cocos2d Basics
Thursday, August 2, 12
Anything thats gets drawn
              or contains things that get
              drawn is a CCNode



Thursday, August 2, 12
CCLayer              CCMenu

                                             CCMenuItemLabel

                         CCMenuItem          CCMenuItemSprite

                                             CCMenuItemToggle
                         CCParticleSystem


            CCNode

                         CCScene             CCTransitionScene



                         CCSprite            CCLabelTTF


                                             CCLabelBMFont
                         CCSpriteBatchNode
                                             CCTMXLayer


Thursday, August 2, 12
Just like UIView




Thursday, August 2, 12
They can contain other CCNode nodes
         (addChild, getChildByTag, removeChild, etc)

         They can schedule periodic callback
         (schedule, unschedule, etc)

         They can execute actions (runAction,
         stopAction, etc)

                                main features

Thursday, August 2, 12
Features of CCNode:

           - position
           - scale (x, y)
           - rotation (in degrees, clockwise)
           - CCCamera (an interface to gluLookAt )
           - CCGridBase (to do mesh transformations)
           - anchor point
           - size
           - visible
           - z-order
           - openGL z position



Thursday, August 2, 12
- (CGAffineTransform)nodeToParentTransform;
       - (CGAffineTransform)parentToNodeTransform;

       - (CGAffineTransform)nodeToWorldTransform;
       - (CGAffineTransform)worldToNodeTransform;

       - (CGPoint)convertToNodeSpace:(CGPoint)worldPoint;
       - (CGPoint)convertToWorldSpace:(CGPoint)nodePoint;

       - (CGPoint)convertTouchToNodeSpace:(UITouch *)touch;


                                   transformation
Thursday, August 2, 12
CCLayer
                          GamePlay
                                      CCScene




                         CCLayer      GamePlayScene


                         Background




Thursday, August 2, 12
CCLayer is a subclass of CCNode that
         implements:

         - UIAccelerometerDelegate
         - CCStandardTouchDelegate
         - CCTargetedTouchDelegate




Thursday, August 2, 12
Thursday, August 2, 12
(NSSet*)touches

                                                          NO
                    targetedHandlersCount>o
                                                               standardHandlersCount>o
                                     YES

                         foreach...in touches                               YES

                                                                 foreach...in
                                                                 mutablesTouches
                    foreach...in handlers


                                                                 ccTouchesBegan/Move/
                                                                 End
                                                NO
                           ccTouchBegan


                                    YES

                         ccTouchMove/End
                                                     NO
                                                                        End
                           swallowsTouches           NO


                                    YES

                         remove from
                         mutableTouches

Thursday, August 2, 12
!    //
      !    // process the target handlers 1st
      !    //
      !    if( targetedHandlersCount > 0 ) {
      !    !   for( UITouch *touch in touches ) {
      !    !   ! for(CCTargetedTouchHandler *handler in targetedHandlers) {

      !    !      !      !   BOOL claimed = NO;
      !    !      !      !   if( idx == kCCTouchBegan ) {
      !    !      !      !   ! claimed = [handler.delegate ccTouchBegan:touch withEvent:event];
      !    !      !      !   ! if( claimed )
      !    !      !      !   ! ! [handler.claimedTouches addObject:touch];
      !    !      !      !   }

      ! !    ! ! // else (moved, ended, cancelled)
      ! !    ! ! else if( [handler.claimedTouches containsObject:touch] ) {
      ! !    ! ! ! claimed = YES;
      ! !    ! ! ! if( handler.enabledSelectors & helper.type )
      ! !    ! ! ! ! [handler.delegate performSelector:helper.touchSel withObject:touch
      withObject:event];

      ! !    ! ! ! if( helper.type & (kCCTouchSelectorCancelledBit |
      kCCTouchSelectorEndedBit) )
      ! !    ! ! ! ! [handler.claimedTouches removeObject:touch];
      ! !    ! ! }

      !    !      !      !   if( claimed && handler.swallowsTouches ) {
      !    !      !      !   ! if( needsMutableSet )
      !    !      !      !   ! ! [mutableTouches removeObject:touch];
      !    !      !      !   ! break;
      !    !      !      !   }
      !    !      !      }
      !    !      }
      !    }

Thursday, August 2, 12
You must register as a targeted touch delegate
           ccTouchBegan be invoked separately for each of the
           available touches
            The ccTouchBegan method return YES to indicate
            a touch you care about
            The swallowsTouches property return YES to
            indicate only this layer handle the touch

                         Targeted Touch Delegate
Thursday, August 2, 12
A sample:
                         How dose CCMenu work?




Thursday, August 2, 12
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
        {
           ......
        ! selectedItem_ = [self itemForTouch:touch];
        ! [selectedItem_ selected];

        !    if( selectedItem_ ) {
        !    !   state_ = kCCMenuStateTrackingTouch;
        !    !   return YES;
        !    }
        !    return NO;
        }

       -(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
       {
       ! CCMenuItem *currentItem = [self itemForTouch:touch];

       !    if (currentItem != selectedItem_) {
       !    !   [selectedItem_ unselected];
       !    !   selectedItem_ = currentItem;
       !    !   [selectedItem_ selected];
       !    }
       }

      -(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
      {
      ! [selectedItem_ unselected];
      ! [selectedItem_ activate];
      }

                                          CCMenu : CCLayer
Thursday, August 2, 12
Which item is clicked?




Thursday, August 2, 12
-(CCMenuItem *) itemForTouch: (UITouch *) touch
        {
        ! CGPoint touchLocation = [touch locationInView: [touch view]];
        ! touchLocation = [[CCDirector sharedDirector] convertToGL:
        touchLocation];

        !    CCMenuItem* item;
        !    CCARRAY_FOREACH(children_, item){
        !    ! // ignore invisible and disabled items: issue #779, #866
        !    ! if ( [item visible] && [item isEnabled] ) {

        ! ! ! CGPoint local = [item
        convertToNodeSpace:touchLocation];
        ! ! ! CGRect r = [item rect];
        ! ! ! r.origin = CGPointZero;

        !    ! ! if( CGRectContainsPoint( r, local ) )
        !    ! ! ! return item;
        !    ! }
        !    }
        !    return nil;
        }
                         You will like this method
Thursday, August 2, 12
Priority = 2
                           GameLayer

                                           Priority = 1




                                           Priority = 0




                  Which Layer handle touch events?


Thursday, August 2, 12
Return YES to claim the touch.
                         -(BOOL)ccTouchBegan


                 ! //* priority used by the menu for the event handler
                 ! kCCMenuHandlerPriority = -128,




Thursday, August 2, 12
Thursday, August 2, 12
CCSprite is a 2d image




Thursday, August 2, 12
+(id) spriteWithTexture:(CCTexture2D*)texture;

    +(id) spriteWithTexture:(CCTexture2D*)texture rect:(CGRect)rect;

    +(id) spriteWithSpriteFrame:(CCSpriteFrame*)spriteFrame;

    +(id) spriteWithSpriteFrameName:(NSString*)spriteFrameName;

    +(id) spriteWithFile:(NSString*)filename;

    +(id) spriteWithFile:(NSString*)filename rect:(CGRect)rect;

    +(id) spriteWithCGImage: (CGImageRef)image key:(NSString*)key;




Thursday, August 2, 12
CCTexture

                frame

                            0    1

                             2    3
       (setDisplayFrame)




        CCSprite           CCSpriteFrame     CCSpriteFrameCache


Thursday, August 2, 12
CCSpriteSheet
Thursday, August 2, 12
All CCSprites added to a CCSpriteBatchNode are drawn in one
         OpenGL ES draw call.


                                   CCLabelBMFont




                                    CCTMXLayer




                            CCSpriteBatchNode
Thursday, August 2, 12
CCLayer
                         CCScene
               CCLayer
                           GamePlay
                            Scene         CCDirector
               CCLayer

                                              .....
              CCLayer                        startScene
                         CCScene           GameOlayScene

              CCLayer                      CompleteScene
                         LevelCompleted        .....
                              Scene
              CCLayer


Thursday, August 2, 12
-(CGSize) winSize;
    -(CGPoint) convertToGL: (CGPoint) p;
    -(CGPoint) convertToUI:(CGPoint)p;
                        200



    -(void) runWithScene:(CCScene*) scene;    200


                                   100

    -(void) pushScene:(CCScene*) scene;
                                  220

    -(void) popScene;

    -(void) popToRootScene;
                                              200

    -(void) replaceScene: (CCScene*) scene;

    -(void) pause;
    -(void) resume;
                                              CCDirector
Thursday, August 2, 12
How does CCAction
                              work?




Thursday, August 2, 12
@property (nonatomic,readonly,assign) id target;

          +(id) action;

          -(BOOL) isDone;

          -(void) startWithTarget:(id)target;

          -(void) stop;

          -(void) step: (ccTime) dt;

          -(void) update: (ccTime) time;


Thursday, August 2, 12
CCNode                                                                 CCAction                              CCActionManager
                                            +(id)actionWithDuration:(ccTime)d


                -(CCAction*)runAction:(CCAction*)action                                   addAction:action target:self


                                                                                                  -(void) update: (ccTime) dt

                                                      -(void) update: (ccTime) t


                                       [target_ setPosition: ccp(



                  -(void) stopAction: (CCAction*) action;



                                               #pragma mark CCNode - Init & cleanup
                                               -(id) init
                                               {
                                               	

 if ((self=[super init]) ) {
                                               	

 	

     self.actionManager = [director actionManager];
                                               	

 }
                                               	

 return self;
                                               }


Thursday, August 2, 12
Simple,but powerful




Thursday, August 2, 12
Position/rotation/scale/visible/z-order/opacity/flip/color
       CCActionInterval && CCActionInstant
       CCSequence && CCSpawn && CCRepeat
       effect && 3D Action
       CCDelayTime
       CCAnimate
       CCCallFun && CCPropertyAction
       Camera
       CCActionEase
       CCActionProgressTimer
Thursday, August 2, 12
Thursday, August 2, 12
Box2D is C++

          2D rigid physics simulation engine with continuous collision
          detection

         All you files thats touch C++ or include it must be Objective-
         C++(.mm)
         Tuned for 1 meter sized objects

         Box2D v2.2.0 User Manual


                                           COCOS2D+BOX2D

Thursday, August 2, 12
A game in 6 steps




Thursday, August 2, 12
setp 1
Thursday, August 2, 12
what have the template done for us?
           initPhysics
           createMenu
           draw
          addNewSpriteAtPosition
          update
           ccTouchesEnded




Thursday, August 2, 12
!    b2Vec2 gravity;
        !    gravity.Set(0.0f, -10.0f);
        !    world = new b2World(gravity);
        !
        !    // Do we want to let bodies sleep?
        !    world->SetAllowSleeping(true);
        !
        !    world->SetContinuousPhysics(true);
        !
        !    m_debugDraw = new GLESDebugDraw( PTM_RATIO );
        !    world->SetDebugDraw(m_debugDraw);
        !
        !    uint32 flags = 0;
        !    flags += b2Draw::e_shapeBit;
        !    m_debugDraw->SetFlags(flags);! !
        !
        !    // Define the ground body.
        !    b2BodyDef groundBodyDef;
        !    groundBodyDef.position.Set(0, 0); // bottom-left corner
        !
        !    // Call the body factory which allocates memory for the ground body
        !    // from a pool and creates the ground box shape (also from a pool).
        !    // The body is also added to the world.
        !    b2Body* groundBody = world->CreateBody(&groundBodyDef);
        !
        !    // Define the ground box shape.
        !    b2EdgeShape groundBox;! !
        !
        !    // bottom
        !    groundBox.Set(b2Vec2(0,0), b2Vec2(s.width/PTM_RATIO,0));
        !    groundBody->CreateFixture(&groundBox,0);



Thursday, August 2, 12
Create the dynamic blocks




                                    setp 2
Thursday, August 2, 12
sprite = [CCSprite spriteWithFile:spriteFileName];
                        [sprite setPosition:ccp(p.x,p.y)]; // Remember ccp() is macro for
            CGPointMake()
                        [self addChild:sprite];
                    }
            ! }
            !
            ! // Define the dynamic body.
            ! b2BodyDef bodyDef;
            ! bodyDef.type = b2_dynamicBody;

            !    bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO);
            !    bodyDef.userData = sprite;
            !
            !    // Tell the physics world to create the body
            !    b2Body *body = world->CreateBody(&bodyDef);
            !
            !    // Define another box shape for our dynamic body.
            !    b2PolygonShape dynamicBox;

            !    dynamicBox.SetAsBox(boxDimensions.x, boxDimensions.y);
            !    // Define the dynamic body fixture.
            !    b2FixtureDef fixtureDef;
            !    fixtureDef.shape = &dynamicBox;!
            !    fixtureDef.density = boxDensity;
            !    fixtureDef.friction = 0.3f;
            !    fixtureDef.restitution = 0.5f; // 0 is a lead ball, 1 is a super bouncy ball
            !    body->CreateFixture(&fixtureDef);




Thursday, August 2, 12
-(void) update: (ccTime) dt
           {
           ! //It is recommended that a fixed time step is used with Box2D for stability
           ! //of the simulation, however, we are using a variable time step here.
           ! //You need to make an informed choice, the following URL is useful
           ! //http://gafferongames.com/game-physics/fix-your-timestep/
           !
           ! int32 velocityIterations = 8;
           ! int32 positionIterations = 1;    Simulating the world(of Box2D)
           !
           ! // Instruct the world to perform a single step of simulation. It is
           ! // generally best to keep the time step and iterations fixed.
           ! world->Step(1.0f/60.0f, velocityIterations, positionIterations);

           ! //Iterate over the bodies in the physics world
           ! for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())
           ! {
           ! !    if (b->GetUserData() != NULL) {
           ! !    ! //Synchronize the AtlasSprites position and rotation with the
           corresponding body
           ! !    ! CCSprite *myActor = (CCSprite*)b->GetUserData();
           ! !    ! myActor.position = CGPointMake( b->GetPosition().x * PTM_RATIO, b-
           >GetPosition().y * PTM_RATIO);
           ! !    ! myActor.rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle());
           ! !    }!
           ! }!
           }




Thursday, August 2, 12
Touch events




                                        setp 3
Thursday, August 2, 12
-   (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
   {
   !
   !    !
                         1
        for( UITouch *touch in touches ) {
            if (dist > 10.0f) {
   !    !   ! // Create the object and add impulse
   !
   !
        !
                             2
            ! CCSprite *sprite = [CCSprite spriteWithFile:SNOWBALL_FILENAME];

   !    !       ! b2CircleShape circleShape;
   !    !       ! b2FixtureDef fd;
   !    !       ! b2Vec2 initVel;
   !    !       ! b2BodyDef circleBodyDefinition;
   !
   !
        !
        !
                                                        3
                ! circleBodyDefinition.type = b2_dynamicBody;
                ! circleBodyDefinition.position.Set(startPoint.x/PTM_RATIO, startPoint.y/PTM_RATIO);
   !
   !
        !
        !
                                           4
                ! circleBodyDefinition.angle = 0.000000f;
                ! circleBodyDefinition.userData = sprite;
   !    !       ! b2Body *body = world->CreateBody(&circleBodyDefinition);
   !
   !
        !
        !
                                 5
                ! initVel.Set(0.000000f, 0.000000f);
                ! body->SetLinearVelocity(initVel);
   !    !       !
   !    !       ! circleShape.m_radius = 0.5f;
   !    !       ! fd.shape = &circleShape;
   !    !       ! fd.userData = sprite;
   !    !       ! body->CreateFixture(&fd);
   !    !       !
   !    !       ! // 2. Add an impulse on the direction of the flick and with the flick force
   !    !       ! CGPoint forceVector = CGPointMake((endPoint.x-startPoint.x)/PTM_RATIO,(endPoint.y-
   !    !       ! forceVector = CGPointMake(forceVector.x*2, forceVector.y*2);
   !
   !
        !
        !
                !
                                     6
                ! b2Vec2 blockImpulse = b2Vec2(forceVector.x,forceVector.y);
   !    !       ! body->ApplyLinearImpulse(blockImpulse, body->GetPosition());
   !    !       } else {
   !    !       ! //NSLog(@"No Flick occured");
   !    !       }
   !    }
   }
Thursday, August 2, 12
Penguin animation




                                         setp 4
Thursday, August 2, 12
CCSpriteFrame *frame0 = [CCSpriteFrame frameWithTextureFilename:@"penguino1.png" rect:CGRectMake(0, 0, 64, 64)];
       CCSpriteFrame *frame1 = [CCSpriteFrame frameWithTextureFilename:@"penguino2.png" rect:CGRectMake(0, 0, 64, 64)];
       CCSpriteFrame *frame2 = [CCSpriteFrame frameWithTextureFilename:@"penguino3.png" rect:CGRectMake(0, 0, 64, 64)];
       CCSpriteFrame *frame3 = [CCSpriteFrame frameWithTextureFilename:@"penguino4.png" rect:CGRectMake(0, 0, 64, 64)];

       sprite = [CCSprite spriteWithSpriteFrame:frame1];
       [sprite setPosition:ccp(p.x,p.y)]; // Remember ccp() is macro for CGPointMake()
       [self addChild:sprite];

        NSMutableArray *animFrames = [NSMutableArray array];
       [animFrames addObject:frame0];
       [animFrames addObject:frame1];
       [animFrames addObject:frame2];
       [animFrames addObject:frame3];

       CCAnimation *animation = [CCAnimation animationWithSpriteFrames:animFrames delay:0.2f];
       CCAnimate *animate = [CCAnimate actionWithAnimation:animation];
       CCCallFunc *actionCall = [CCCallFunc actionWithTarget:self selector:@selector(playRandomArcticSqueakSound:)];
       CCSequence *seq = [CCSequence actions: animate,actionCall,nil];

       [sprite stopAllActions];
       [sprite runAction:[CCRepeatForever actionWithAction:seq]];




Thursday, August 2, 12
Fun with Particle Systems




                                       setp 5
Thursday, August 2, 12
music & effect

                         [[SimpleAudioEngine sharedEngine]
                         playBackgroundMusic:@"Penguino.mp3"];



                         [[SimpleAudioEngine sharedEngine]
                         playEffect:@"PenguinSqueak3.mp3"];




                                                                 setp 6
Thursday, August 2, 12
Labels and Fonts
          Particle system
          Tiled maps
          Draw & update
          Effects & Grid & Camera
          Transitions
          DrawingPrimitives
          RenderTexture
          Shader (2.0)
          ......

                                    more features
Thursday, August 2, 12
Thursday, August 2, 12
THANK YOU

        ElvisQin@me.com
        weibo.com/hielvis



   Now, how about
        this game?



Thursday, August 2, 12

Contenu connexe

Similaire à 在iOS平台上用Cocos2D做开发 | iOS独立开发者 秦春林

cocos2d 事例編 HungryMasterの実装から
cocos2d 事例編 HungryMasterの実装からcocos2d 事例編 HungryMasterの実装から
cocos2d 事例編 HungryMasterの実装からYuichi Higuchi
 
From Node.js to Design Patterns - BuildPiper
From Node.js to Design Patterns - BuildPiperFrom Node.js to Design Patterns - BuildPiper
From Node.js to Design Patterns - BuildPiperLuciano Mammino
 
Umbra Ignite 2015: Rulon Raymond – The State of Skinning – a dive into modern...
Umbra Ignite 2015: Rulon Raymond – The State of Skinning – a dive into modern...Umbra Ignite 2015: Rulon Raymond – The State of Skinning – a dive into modern...
Umbra Ignite 2015: Rulon Raymond – The State of Skinning – a dive into modern...Umbra Software
 
UIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconfUIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconfShuichi Tsutsumi
 
iOS Game Development with Cocos2D
iOS Game Development with Cocos2DiOS Game Development with Cocos2D
iOS Game Development with Cocos2DGreenwell
 
Chipmunk physics presentation
Chipmunk physics presentationChipmunk physics presentation
Chipmunk physics presentationCarl Brown
 
Modeling Scenarios with Sequence Diagrams
Modeling Scenarios with Sequence DiagramsModeling Scenarios with Sequence Diagrams
Modeling Scenarios with Sequence DiagramsMustafa Isik
 
Box2D with SIMD in JavaScript
Box2D with SIMD in JavaScriptBox2D with SIMD in JavaScript
Box2D with SIMD in JavaScriptIntel® Software
 
Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...
Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...
Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...Igalia
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Takao Wada
 
How to autorun graphic application
How to autorun graphic applicationHow to autorun graphic application
How to autorun graphic applicationytanno
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Jay Coskey
 
Debugging, a step away from the console
Debugging, a step away from the consoleDebugging, a step away from the console
Debugging, a step away from the consoleAdam Weeks
 
Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018
Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018
Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018Codemotion
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09Guy Korland
 
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...Volodymyr Bogdanov
 

Similaire à 在iOS平台上用Cocos2D做开发 | iOS独立开发者 秦春林 (18)

cocos2d 事例編 HungryMasterの実装から
cocos2d 事例編 HungryMasterの実装からcocos2d 事例編 HungryMasterの実装から
cocos2d 事例編 HungryMasterの実装から
 
From Node.js to Design Patterns - BuildPiper
From Node.js to Design Patterns - BuildPiperFrom Node.js to Design Patterns - BuildPiper
From Node.js to Design Patterns - BuildPiper
 
Umbra Ignite 2015: Rulon Raymond – The State of Skinning – a dive into modern...
Umbra Ignite 2015: Rulon Raymond – The State of Skinning – a dive into modern...Umbra Ignite 2015: Rulon Raymond – The State of Skinning – a dive into modern...
Umbra Ignite 2015: Rulon Raymond – The State of Skinning – a dive into modern...
 
UIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconfUIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconf
 
iOS Game Development with Cocos2D
iOS Game Development with Cocos2DiOS Game Development with Cocos2D
iOS Game Development with Cocos2D
 
Chipmunk physics presentation
Chipmunk physics presentationChipmunk physics presentation
Chipmunk physics presentation
 
Modeling Scenarios with Sequence Diagrams
Modeling Scenarios with Sequence DiagramsModeling Scenarios with Sequence Diagrams
Modeling Scenarios with Sequence Diagrams
 
Box2D with SIMD in JavaScript
Box2D with SIMD in JavaScriptBox2D with SIMD in JavaScript
Box2D with SIMD in JavaScript
 
Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...
Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...
Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5
 
Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014
 
How to autorun graphic application
How to autorun graphic applicationHow to autorun graphic application
How to autorun graphic application
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3
 
Debugging, a step away from the console
Debugging, a step away from the consoleDebugging, a step away from the console
Debugging, a step away from the console
 
Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018
Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018
Pablo Magaz | ECMAScript 2018 y más allá | Codemotion Madrid 2018
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09
 
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Lyon/Kyiv 2018...
 

Plus de imShining @DevCamp

如何创建更加灵活的App | 大众点评 屠毅敏
如何创建更加灵活的App | 大众点评 屠毅敏如何创建更加灵活的App | 大众点评 屠毅敏
如何创建更加灵活的App | 大众点评 屠毅敏imShining @DevCamp
 
Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐imShining @DevCamp
 
Android程序的编译,安装和运行 | 小米科技 汪文俊
Android程序的编译,安装和运行 | 小米科技 汪文俊Android程序的编译,安装和运行 | 小米科技 汪文俊
Android程序的编译,安装和运行 | 小米科技 汪文俊imShining @DevCamp
 
和Android源代码一起工作 | 海豚浏览器 胡继堂
和Android源代码一起工作 | 海豚浏览器 胡继堂和Android源代码一起工作 | 海豚浏览器 胡继堂
和Android源代码一起工作 | 海豚浏览器 胡继堂imShining @DevCamp
 
Android消息推送实现 | 友盟 徐仙明
Android消息推送实现 | 友盟 徐仙明 Android消息推送实现 | 友盟 徐仙明
Android消息推送实现 | 友盟 徐仙明 imShining @DevCamp
 
千万级并发在线推送系统架构解析 | 个信互动 叶新江
千万级并发在线推送系统架构解析 | 个信互动 叶新江千万级并发在线推送系统架构解析 | 个信互动 叶新江
千万级并发在线推送系统架构解析 | 个信互动 叶新江imShining @DevCamp
 
发现和建立多设备之间的数据通信 | 豌豆荚实验室 孙桥
发现和建立多设备之间的数据通信 | 豌豆荚实验室 孙桥发现和建立多设备之间的数据通信 | 豌豆荚实验室 孙桥
发现和建立多设备之间的数据通信 | 豌豆荚实验室 孙桥imShining @DevCamp
 
Android音频口数据通信开发 | 爱图腾 李鹏军
Android音频口数据通信开发 | 爱图腾 李鹏军Android音频口数据通信开发 | 爱图腾 李鹏军
Android音频口数据通信开发 | 爱图腾 李鹏军imShining @DevCamp
 
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山imShining @DevCamp
 
Android账户同步备份框架 | 盛大乐众ROM 郭振
Android账户同步备份框架 | 盛大乐众ROM 郭振 Android账户同步备份框架 | 盛大乐众ROM 郭振
Android账户同步备份框架 | 盛大乐众ROM 郭振 imShining @DevCamp
 
简单中的不简单,iPhone应用开发实践总结:《社区类iPhone应用开发的技术实践》| 麻麻帮 陈剑飞
简单中的不简单,iPhone应用开发实践总结:《社区类iPhone应用开发的技术实践》| 麻麻帮 陈剑飞简单中的不简单,iPhone应用开发实践总结:《社区类iPhone应用开发的技术实践》| 麻麻帮 陈剑飞
简单中的不简单,iPhone应用开发实践总结:《社区类iPhone应用开发的技术实践》| 麻麻帮 陈剑飞imShining @DevCamp
 
在iOS平台上实现全功能视频处理 | 盛大微酷 赵志猛
在iOS平台上实现全功能视频处理 | 盛大微酷 赵志猛在iOS平台上实现全功能视频处理 | 盛大微酷 赵志猛
在iOS平台上实现全功能视频处理 | 盛大微酷 赵志猛imShining @DevCamp
 
iOS平台应用详解:《Siri:I,robot! Siri语音识别系统详解》| 新浪 张俊林
iOS平台应用详解:《Siri:I,robot! Siri语音识别系统详解》| 新浪 张俊林iOS平台应用详解:《Siri:I,robot! Siri语音识别系统详解》| 新浪 张俊林
iOS平台应用详解:《Siri:I,robot! Siri语音识别系统详解》| 新浪 张俊林imShining @DevCamp
 
逆向工程技术详解:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 | iOS DevCamp
逆向工程技术详解:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 | iOS DevCamp逆向工程技术详解:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 | iOS DevCamp
逆向工程技术详解:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 | iOS DevCampimShining @DevCamp
 
《Passbook实战详解》| 爱图腾 廉洁 | iOS DevCamp
《Passbook实战详解》| 爱图腾 廉洁 | iOS DevCamp《Passbook实战详解》| 爱图腾 廉洁 | iOS DevCamp
《Passbook实战详解》| 爱图腾 廉洁 | iOS DevCampimShining @DevCamp
 
从知乎 iPhone 端重构说开去:Web 为主的复杂社交产品的 iOS 端开发策略及实践
从知乎 iPhone 端重构说开去:Web 为主的复杂社交产品的 iOS 端开发策略及实践从知乎 iPhone 端重构说开去:Web 为主的复杂社交产品的 iOS 端开发策略及实践
从知乎 iPhone 端重构说开去:Web 为主的复杂社交产品的 iOS 端开发策略及实践imShining @DevCamp
 

Plus de imShining @DevCamp (16)

如何创建更加灵活的App | 大众点评 屠毅敏
如何创建更加灵活的App | 大众点评 屠毅敏如何创建更加灵活的App | 大众点评 屠毅敏
如何创建更加灵活的App | 大众点评 屠毅敏
 
Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐
 
Android程序的编译,安装和运行 | 小米科技 汪文俊
Android程序的编译,安装和运行 | 小米科技 汪文俊Android程序的编译,安装和运行 | 小米科技 汪文俊
Android程序的编译,安装和运行 | 小米科技 汪文俊
 
和Android源代码一起工作 | 海豚浏览器 胡继堂
和Android源代码一起工作 | 海豚浏览器 胡继堂和Android源代码一起工作 | 海豚浏览器 胡继堂
和Android源代码一起工作 | 海豚浏览器 胡继堂
 
Android消息推送实现 | 友盟 徐仙明
Android消息推送实现 | 友盟 徐仙明 Android消息推送实现 | 友盟 徐仙明
Android消息推送实现 | 友盟 徐仙明
 
千万级并发在线推送系统架构解析 | 个信互动 叶新江
千万级并发在线推送系统架构解析 | 个信互动 叶新江千万级并发在线推送系统架构解析 | 个信互动 叶新江
千万级并发在线推送系统架构解析 | 个信互动 叶新江
 
发现和建立多设备之间的数据通信 | 豌豆荚实验室 孙桥
发现和建立多设备之间的数据通信 | 豌豆荚实验室 孙桥发现和建立多设备之间的数据通信 | 豌豆荚实验室 孙桥
发现和建立多设备之间的数据通信 | 豌豆荚实验室 孙桥
 
Android音频口数据通信开发 | 爱图腾 李鹏军
Android音频口数据通信开发 | 爱图腾 李鹏军Android音频口数据通信开发 | 爱图腾 李鹏军
Android音频口数据通信开发 | 爱图腾 李鹏军
 
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
凡客移动应用之Android + HTML5技术运用 | 凡客 汪健飞 徐金山
 
Android账户同步备份框架 | 盛大乐众ROM 郭振
Android账户同步备份框架 | 盛大乐众ROM 郭振 Android账户同步备份框架 | 盛大乐众ROM 郭振
Android账户同步备份框架 | 盛大乐众ROM 郭振
 
简单中的不简单,iPhone应用开发实践总结:《社区类iPhone应用开发的技术实践》| 麻麻帮 陈剑飞
简单中的不简单,iPhone应用开发实践总结:《社区类iPhone应用开发的技术实践》| 麻麻帮 陈剑飞简单中的不简单,iPhone应用开发实践总结:《社区类iPhone应用开发的技术实践》| 麻麻帮 陈剑飞
简单中的不简单,iPhone应用开发实践总结:《社区类iPhone应用开发的技术实践》| 麻麻帮 陈剑飞
 
在iOS平台上实现全功能视频处理 | 盛大微酷 赵志猛
在iOS平台上实现全功能视频处理 | 盛大微酷 赵志猛在iOS平台上实现全功能视频处理 | 盛大微酷 赵志猛
在iOS平台上实现全功能视频处理 | 盛大微酷 赵志猛
 
iOS平台应用详解:《Siri:I,robot! Siri语音识别系统详解》| 新浪 张俊林
iOS平台应用详解:《Siri:I,robot! Siri语音识别系统详解》| 新浪 张俊林iOS平台应用详解:《Siri:I,robot! Siri语音识别系统详解》| 新浪 张俊林
iOS平台应用详解:《Siri:I,robot! Siri语音识别系统详解》| 新浪 张俊林
 
逆向工程技术详解:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 | iOS DevCamp
逆向工程技术详解:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 | iOS DevCamp逆向工程技术详解:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 | iOS DevCamp
逆向工程技术详解:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 | iOS DevCamp
 
《Passbook实战详解》| 爱图腾 廉洁 | iOS DevCamp
《Passbook实战详解》| 爱图腾 廉洁 | iOS DevCamp《Passbook实战详解》| 爱图腾 廉洁 | iOS DevCamp
《Passbook实战详解》| 爱图腾 廉洁 | iOS DevCamp
 
从知乎 iPhone 端重构说开去:Web 为主的复杂社交产品的 iOS 端开发策略及实践
从知乎 iPhone 端重构说开去:Web 为主的复杂社交产品的 iOS 端开发策略及实践从知乎 iPhone 端重构说开去:Web 为主的复杂社交产品的 iOS 端开发策略及实践
从知乎 iPhone 端重构说开去:Web 为主的复杂社交产品的 iOS 端开发策略及实践
 

Dernier

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Dernier (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

在iOS平台上用Cocos2D做开发 | iOS独立开发者 秦春林

  • 1. iOS DevCamp Produced by CSDN Website: http://devcamp.csdn.net Weibo: http://weibo.com/cmdnclub Thursday, August 2, 12
  • 2. 怎样灵活使用Cocos2D 秦春林 Thursday, August 2, 12
  • 3. Don’t reinvent the wheel Thursday, August 2, 12
  • 4. “In the summer of 2008, several "pythoneros" went to a camp program called PyCamp: Python outdoors. This camp held in Cordoba, in the town of Los Cocos. We were about 50 people. It covered different topics, one of which was seeking way of not having to "reinvent the wheel" in each jurisdiction Pyweek. In this way a group of friends and I decided to put together a framework to make games. We call cocos2d, since the framework is designed to make 2D games, and the word "coconut" emulates the place where the camp took place.” Ricardo Quesada Thursday, August 2, 12
  • 6. It is free! Without having to learn OpenGL ES to get started Active community & tests Lots of tools It is Simple Why Cocos2d? Thursday, August 2, 12
  • 8. sprite: player Action: CCMoveTo layer: GameLayer scene: GameScene UIView:EAGLView Thursday, August 2, 12
  • 9. Game has Scenes Each Scene has some number of Layers Layers capture user interaction and contain sprites Director manages the scenes Cocos2d Basics Thursday, August 2, 12
  • 10. Anything thats gets drawn or contains things that get drawn is a CCNode Thursday, August 2, 12
  • 11. CCLayer CCMenu CCMenuItemLabel CCMenuItem CCMenuItemSprite CCMenuItemToggle CCParticleSystem CCNode CCScene CCTransitionScene CCSprite CCLabelTTF CCLabelBMFont CCSpriteBatchNode CCTMXLayer Thursday, August 2, 12
  • 13. They can contain other CCNode nodes (addChild, getChildByTag, removeChild, etc) They can schedule periodic callback (schedule, unschedule, etc) They can execute actions (runAction, stopAction, etc) main features Thursday, August 2, 12
  • 14. Features of CCNode: - position - scale (x, y) - rotation (in degrees, clockwise) - CCCamera (an interface to gluLookAt ) - CCGridBase (to do mesh transformations) - anchor point - size - visible - z-order - openGL z position Thursday, August 2, 12
  • 15. - (CGAffineTransform)nodeToParentTransform; - (CGAffineTransform)parentToNodeTransform; - (CGAffineTransform)nodeToWorldTransform; - (CGAffineTransform)worldToNodeTransform; - (CGPoint)convertToNodeSpace:(CGPoint)worldPoint; - (CGPoint)convertToWorldSpace:(CGPoint)nodePoint; - (CGPoint)convertTouchToNodeSpace:(UITouch *)touch; transformation Thursday, August 2, 12
  • 16. CCLayer GamePlay CCScene CCLayer GamePlayScene Background Thursday, August 2, 12
  • 17. CCLayer is a subclass of CCNode that implements: - UIAccelerometerDelegate - CCStandardTouchDelegate - CCTargetedTouchDelegate Thursday, August 2, 12
  • 19. (NSSet*)touches NO targetedHandlersCount>o standardHandlersCount>o YES foreach...in touches YES foreach...in mutablesTouches foreach...in handlers ccTouchesBegan/Move/ End NO ccTouchBegan YES ccTouchMove/End NO End swallowsTouches NO YES remove from mutableTouches Thursday, August 2, 12
  • 20. ! // ! // process the target handlers 1st ! // ! if( targetedHandlersCount > 0 ) { ! ! for( UITouch *touch in touches ) { ! ! ! for(CCTargetedTouchHandler *handler in targetedHandlers) { ! ! ! ! BOOL claimed = NO; ! ! ! ! if( idx == kCCTouchBegan ) { ! ! ! ! ! claimed = [handler.delegate ccTouchBegan:touch withEvent:event]; ! ! ! ! ! if( claimed ) ! ! ! ! ! ! [handler.claimedTouches addObject:touch]; ! ! ! ! } ! ! ! ! // else (moved, ended, cancelled) ! ! ! ! else if( [handler.claimedTouches containsObject:touch] ) { ! ! ! ! ! claimed = YES; ! ! ! ! ! if( handler.enabledSelectors & helper.type ) ! ! ! ! ! ! [handler.delegate performSelector:helper.touchSel withObject:touch withObject:event]; ! ! ! ! ! if( helper.type & (kCCTouchSelectorCancelledBit | kCCTouchSelectorEndedBit) ) ! ! ! ! ! ! [handler.claimedTouches removeObject:touch]; ! ! ! ! } ! ! ! ! if( claimed && handler.swallowsTouches ) { ! ! ! ! ! if( needsMutableSet ) ! ! ! ! ! ! [mutableTouches removeObject:touch]; ! ! ! ! ! break; ! ! ! ! } ! ! ! } ! ! } ! } Thursday, August 2, 12
  • 21. You must register as a targeted touch delegate ccTouchBegan be invoked separately for each of the available touches The ccTouchBegan method return YES to indicate a touch you care about The swallowsTouches property return YES to indicate only this layer handle the touch Targeted Touch Delegate Thursday, August 2, 12
  • 22. A sample: How dose CCMenu work? Thursday, August 2, 12
  • 23. -(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event { ...... ! selectedItem_ = [self itemForTouch:touch]; ! [selectedItem_ selected]; ! if( selectedItem_ ) { ! ! state_ = kCCMenuStateTrackingTouch; ! ! return YES; ! } ! return NO; } -(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event { ! CCMenuItem *currentItem = [self itemForTouch:touch]; ! if (currentItem != selectedItem_) { ! ! [selectedItem_ unselected]; ! ! selectedItem_ = currentItem; ! ! [selectedItem_ selected]; ! } } -(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event { ! [selectedItem_ unselected]; ! [selectedItem_ activate]; } CCMenu : CCLayer Thursday, August 2, 12
  • 24. Which item is clicked? Thursday, August 2, 12
  • 25. -(CCMenuItem *) itemForTouch: (UITouch *) touch { ! CGPoint touchLocation = [touch locationInView: [touch view]]; ! touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation]; ! CCMenuItem* item; ! CCARRAY_FOREACH(children_, item){ ! ! // ignore invisible and disabled items: issue #779, #866 ! ! if ( [item visible] && [item isEnabled] ) { ! ! ! CGPoint local = [item convertToNodeSpace:touchLocation]; ! ! ! CGRect r = [item rect]; ! ! ! r.origin = CGPointZero; ! ! ! if( CGRectContainsPoint( r, local ) ) ! ! ! ! return item; ! ! } ! } ! return nil; } You will like this method Thursday, August 2, 12
  • 26. Priority = 2 GameLayer Priority = 1 Priority = 0 Which Layer handle touch events? Thursday, August 2, 12
  • 27. Return YES to claim the touch. -(BOOL)ccTouchBegan ! //* priority used by the menu for the event handler ! kCCMenuHandlerPriority = -128, Thursday, August 2, 12
  • 29. CCSprite is a 2d image Thursday, August 2, 12
  • 30. +(id) spriteWithTexture:(CCTexture2D*)texture; +(id) spriteWithTexture:(CCTexture2D*)texture rect:(CGRect)rect; +(id) spriteWithSpriteFrame:(CCSpriteFrame*)spriteFrame; +(id) spriteWithSpriteFrameName:(NSString*)spriteFrameName; +(id) spriteWithFile:(NSString*)filename; +(id) spriteWithFile:(NSString*)filename rect:(CGRect)rect; +(id) spriteWithCGImage: (CGImageRef)image key:(NSString*)key; Thursday, August 2, 12
  • 31. CCTexture frame 0 1 2 3 (setDisplayFrame) CCSprite CCSpriteFrame CCSpriteFrameCache Thursday, August 2, 12
  • 33. All CCSprites added to a CCSpriteBatchNode are drawn in one OpenGL ES draw call. CCLabelBMFont CCTMXLayer CCSpriteBatchNode Thursday, August 2, 12
  • 34. CCLayer CCScene CCLayer GamePlay Scene CCDirector CCLayer ..... CCLayer startScene CCScene GameOlayScene CCLayer CompleteScene LevelCompleted ..... Scene CCLayer Thursday, August 2, 12
  • 35. -(CGSize) winSize; -(CGPoint) convertToGL: (CGPoint) p; -(CGPoint) convertToUI:(CGPoint)p; 200 -(void) runWithScene:(CCScene*) scene; 200 100 -(void) pushScene:(CCScene*) scene; 220 -(void) popScene; -(void) popToRootScene; 200 -(void) replaceScene: (CCScene*) scene; -(void) pause; -(void) resume; CCDirector Thursday, August 2, 12
  • 36. How does CCAction work? Thursday, August 2, 12
  • 37. @property (nonatomic,readonly,assign) id target; +(id) action; -(BOOL) isDone; -(void) startWithTarget:(id)target; -(void) stop; -(void) step: (ccTime) dt; -(void) update: (ccTime) time; Thursday, August 2, 12
  • 38. CCNode CCAction CCActionManager +(id)actionWithDuration:(ccTime)d -(CCAction*)runAction:(CCAction*)action addAction:action target:self -(void) update: (ccTime) dt -(void) update: (ccTime) t [target_ setPosition: ccp( -(void) stopAction: (CCAction*) action; #pragma mark CCNode - Init & cleanup -(id) init { if ((self=[super init]) ) { self.actionManager = [director actionManager]; } return self; } Thursday, August 2, 12
  • 40. Position/rotation/scale/visible/z-order/opacity/flip/color CCActionInterval && CCActionInstant CCSequence && CCSpawn && CCRepeat effect && 3D Action CCDelayTime CCAnimate CCCallFun && CCPropertyAction Camera CCActionEase CCActionProgressTimer Thursday, August 2, 12
  • 42. Box2D is C++ 2D rigid physics simulation engine with continuous collision detection All you files thats touch C++ or include it must be Objective- C++(.mm) Tuned for 1 meter sized objects Box2D v2.2.0 User Manual COCOS2D+BOX2D Thursday, August 2, 12
  • 43. A game in 6 steps Thursday, August 2, 12
  • 45. what have the template done for us? initPhysics createMenu draw addNewSpriteAtPosition update ccTouchesEnded Thursday, August 2, 12
  • 46. ! b2Vec2 gravity; ! gravity.Set(0.0f, -10.0f); ! world = new b2World(gravity); ! ! // Do we want to let bodies sleep? ! world->SetAllowSleeping(true); ! ! world->SetContinuousPhysics(true); ! ! m_debugDraw = new GLESDebugDraw( PTM_RATIO ); ! world->SetDebugDraw(m_debugDraw); ! ! uint32 flags = 0; ! flags += b2Draw::e_shapeBit; ! m_debugDraw->SetFlags(flags);! ! ! ! // Define the ground body. ! b2BodyDef groundBodyDef; ! groundBodyDef.position.Set(0, 0); // bottom-left corner ! ! // Call the body factory which allocates memory for the ground body ! // from a pool and creates the ground box shape (also from a pool). ! // The body is also added to the world. ! b2Body* groundBody = world->CreateBody(&groundBodyDef); ! ! // Define the ground box shape. ! b2EdgeShape groundBox;! ! ! ! // bottom ! groundBox.Set(b2Vec2(0,0), b2Vec2(s.width/PTM_RATIO,0)); ! groundBody->CreateFixture(&groundBox,0); Thursday, August 2, 12
  • 47. Create the dynamic blocks setp 2 Thursday, August 2, 12
  • 48. sprite = [CCSprite spriteWithFile:spriteFileName]; [sprite setPosition:ccp(p.x,p.y)]; // Remember ccp() is macro for CGPointMake() [self addChild:sprite]; } ! } ! ! // Define the dynamic body. ! b2BodyDef bodyDef; ! bodyDef.type = b2_dynamicBody; ! bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO); ! bodyDef.userData = sprite; ! ! // Tell the physics world to create the body ! b2Body *body = world->CreateBody(&bodyDef); ! ! // Define another box shape for our dynamic body. ! b2PolygonShape dynamicBox; ! dynamicBox.SetAsBox(boxDimensions.x, boxDimensions.y); ! // Define the dynamic body fixture. ! b2FixtureDef fixtureDef; ! fixtureDef.shape = &dynamicBox;! ! fixtureDef.density = boxDensity; ! fixtureDef.friction = 0.3f; ! fixtureDef.restitution = 0.5f; // 0 is a lead ball, 1 is a super bouncy ball ! body->CreateFixture(&fixtureDef); Thursday, August 2, 12
  • 49. -(void) update: (ccTime) dt { ! //It is recommended that a fixed time step is used with Box2D for stability ! //of the simulation, however, we are using a variable time step here. ! //You need to make an informed choice, the following URL is useful ! //http://gafferongames.com/game-physics/fix-your-timestep/ ! ! int32 velocityIterations = 8; ! int32 positionIterations = 1; Simulating the world(of Box2D) ! ! // Instruct the world to perform a single step of simulation. It is ! // generally best to keep the time step and iterations fixed. ! world->Step(1.0f/60.0f, velocityIterations, positionIterations); ! //Iterate over the bodies in the physics world ! for (b2Body* b = world->GetBodyList(); b; b = b->GetNext()) ! { ! ! if (b->GetUserData() != NULL) { ! ! ! //Synchronize the AtlasSprites position and rotation with the corresponding body ! ! ! CCSprite *myActor = (CCSprite*)b->GetUserData(); ! ! ! myActor.position = CGPointMake( b->GetPosition().x * PTM_RATIO, b- >GetPosition().y * PTM_RATIO); ! ! ! myActor.rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle()); ! ! }! ! }! } Thursday, August 2, 12
  • 50. Touch events setp 3 Thursday, August 2, 12
  • 51. - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { ! ! ! 1 for( UITouch *touch in touches ) { if (dist > 10.0f) { ! ! ! // Create the object and add impulse ! ! ! 2 ! CCSprite *sprite = [CCSprite spriteWithFile:SNOWBALL_FILENAME]; ! ! ! b2CircleShape circleShape; ! ! ! b2FixtureDef fd; ! ! ! b2Vec2 initVel; ! ! ! b2BodyDef circleBodyDefinition; ! ! ! ! 3 ! circleBodyDefinition.type = b2_dynamicBody; ! circleBodyDefinition.position.Set(startPoint.x/PTM_RATIO, startPoint.y/PTM_RATIO); ! ! ! ! 4 ! circleBodyDefinition.angle = 0.000000f; ! circleBodyDefinition.userData = sprite; ! ! ! b2Body *body = world->CreateBody(&circleBodyDefinition); ! ! ! ! 5 ! initVel.Set(0.000000f, 0.000000f); ! body->SetLinearVelocity(initVel); ! ! ! ! ! ! circleShape.m_radius = 0.5f; ! ! ! fd.shape = &circleShape; ! ! ! fd.userData = sprite; ! ! ! body->CreateFixture(&fd); ! ! ! ! ! ! // 2. Add an impulse on the direction of the flick and with the flick force ! ! ! CGPoint forceVector = CGPointMake((endPoint.x-startPoint.x)/PTM_RATIO,(endPoint.y- ! ! ! forceVector = CGPointMake(forceVector.x*2, forceVector.y*2); ! ! ! ! ! 6 ! b2Vec2 blockImpulse = b2Vec2(forceVector.x,forceVector.y); ! ! ! body->ApplyLinearImpulse(blockImpulse, body->GetPosition()); ! ! } else { ! ! ! //NSLog(@"No Flick occured"); ! ! } ! } } Thursday, August 2, 12
  • 52. Penguin animation setp 4 Thursday, August 2, 12
  • 53. CCSpriteFrame *frame0 = [CCSpriteFrame frameWithTextureFilename:@"penguino1.png" rect:CGRectMake(0, 0, 64, 64)]; CCSpriteFrame *frame1 = [CCSpriteFrame frameWithTextureFilename:@"penguino2.png" rect:CGRectMake(0, 0, 64, 64)]; CCSpriteFrame *frame2 = [CCSpriteFrame frameWithTextureFilename:@"penguino3.png" rect:CGRectMake(0, 0, 64, 64)]; CCSpriteFrame *frame3 = [CCSpriteFrame frameWithTextureFilename:@"penguino4.png" rect:CGRectMake(0, 0, 64, 64)]; sprite = [CCSprite spriteWithSpriteFrame:frame1]; [sprite setPosition:ccp(p.x,p.y)]; // Remember ccp() is macro for CGPointMake() [self addChild:sprite]; NSMutableArray *animFrames = [NSMutableArray array]; [animFrames addObject:frame0]; [animFrames addObject:frame1]; [animFrames addObject:frame2]; [animFrames addObject:frame3]; CCAnimation *animation = [CCAnimation animationWithSpriteFrames:animFrames delay:0.2f]; CCAnimate *animate = [CCAnimate actionWithAnimation:animation]; CCCallFunc *actionCall = [CCCallFunc actionWithTarget:self selector:@selector(playRandomArcticSqueakSound:)]; CCSequence *seq = [CCSequence actions: animate,actionCall,nil]; [sprite stopAllActions]; [sprite runAction:[CCRepeatForever actionWithAction:seq]]; Thursday, August 2, 12
  • 54. Fun with Particle Systems setp 5 Thursday, August 2, 12
  • 55. music & effect [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"Penguino.mp3"]; [[SimpleAudioEngine sharedEngine] playEffect:@"PenguinSqueak3.mp3"]; setp 6 Thursday, August 2, 12
  • 56. Labels and Fonts Particle system Tiled maps Draw & update Effects & Grid & Camera Transitions DrawingPrimitives RenderTexture Shader (2.0) ...... more features Thursday, August 2, 12
  • 58. THANK YOU ElvisQin@me.com weibo.com/hielvis Now, how about this game? Thursday, August 2, 12