cocos2d                HungryMaster

xionchannel software
cocos2d                HungryMaster

xionchannel software
twitter: @ajinotataki

email: xionchannel@gmail.com


Solid Dots, ElectroMaster,
HungryMaster
…
              CCLayer




         CCLayer

CCMenu
http://xionchannel.no-ip.org/
http://xionchannel.no-ip.org/
OverTopLayer
OverTopLayer
OverTopLayer
OverTopLayer
OverTopLayer
OverTopLayer
OverTopLayer
CCScene                 CCLayer



CCScene                 CCLayer



          touch event
CCScene                 CCLayer




CCScene

   LayerBelow

          OverTopLayer
CCScene                 CCLayer




CCScene

   LayerBelow

          OverTopLayer
CCScene   CCLayer
CCScene   CCLayer
CCScene   CCLayer
CCScene                                    CCLayer



+(MainScene*)sceneWithLayerTop:(CCLayer*)layerTop
           layerBelow:(CCLayer*)layerBelow
{

 MainScene *scene = [MainScene node];


   layerTop.tag = kLayerTop;

   layerBelow.tag = kLayerBelow;


   [scene addChild:layerBelow z:0];

   [scene addChild:layerTop z:2];


 return scene;
}
CCLayer




- (BOOL)transitionFadeWithLayer:(CCLayer*)layer
               duration:(ccTime)d;

- (BOOL)transitionFlowerWithLayer:(CCLayer*)layer
                duration:(ccTime)d;
touch event
emFontProportional
emFontProportional
emFontProportional
emFontProportional

plist

                    pngSplitter

        plist



                …
plist
pngSplitter
plist

        →
…

@”This is <B>blue<> and <G>green<>.”
→“This is blue and green.”


- (void) setColor:(ccColor3B)_color;

- (void) setCentering:(CGPoint)center;
- (void) setRighting:(CGPoint)right;

- (BOOL) isHitByPosition:(CGPoint)pos;

- (void) transferAllChildrenToNewParent:(CCNode*)node;
- (void) transferAllChildrenToNewParent:(CCNode*)node
                          z:(int)z;

- (void) runEachNodeWithAction:(id)action;
emScrollLayer
touch moved
- (void)setScrollAreaWithMinPosition:(CGPoint)min
                 maxPosition:(CGPoint)max;


- (void)setVerticalScrollEnable:(BOOL)enable;

- (void)setHorizontalScrollEnable:(BOOL)enable;
CGPoint uiViewPos = [myTouch locationInView:[myTouch view]];
CGPoint cocosPos = [[CCDirector sharedDirector] convertToGL:uiViewPos];

//
cocosPos = ccpSub(cocosPos, self.position);

 
if ([nextButton isHitByPosition:cocosPos]) {

 //
}
emMenu

CCMenu

emFontProportional
CCMenu
CCMenuItems



Align




              selector
CCMenu
CCMenu
CCMenu
emFontProportional



NSString *txt[] = {

 @"0:                                  ",

 @"1:                   ",

 @"2: Third Item",

 @"3: 4th Item",
};
for(int i=0; i<4; i++) {

 f = [emFontProportional fontWithText:txt[i]];

 f.position = ccp(size.width/2-80,
              size.height/2-i*32);

 [self addChild:f];

 [menu addItem:f];
}
[menu selectMenuWithNumber:0];
emFontProportional




CGPoint uiViewPos = [myTouch locationInView:[myTouch view]];
CGPoint cocosPos = [[CCDirector sharedDirector]
             convertToGL:uiViewPos];

int num = [menu getHitItemNumberWithPosition:cocosPos];
[selectedNumberText setText:
 [NSString stringWithFormat:@"Selected Number: %d",num]];
+ (emMenu*)menuWithCursor:(CCNode*)tcursor;

- (void)addItem:(id)item;
- (void)addItem:(id)item enable:(BOOL)isEnable;

- (int)getHitItemNumberWithPosition:(CGPoint)pos;
- (int)getHitItemNumberWithPosition:(CGPoint)pos
                withSelection:(BOOL)selection;

- (void)selectMenuWithNumber:(int)num;
iPhone
Target Point


ElectroMaster

MMO

emChara
Virtual Pad Relative




emChara
Virtual Pad Fixed
One more thing...
One more thing...
iCade

iCade    Bluetooth

KeyDown, KeyUp



SDK
            delegate
iCade

@protocol iCadeEventDelegate <NSObject>

@optional
- (void)stateChanged:(iCadeState)state;
- (void)buttonDown:(iCadeState)button;
- (void)buttonUp:(iCadeState)button;

@end
iCade
typedef enum iCadeState {
   iCadeJoystickNone    = 0x000,
   iCadeJoystickUp     = 0x001,
   iCadeJoystickRight  = 0x002,
   iCadeJoystickDown     = 0x004,
   iCadeJoystickLeft  = 0x008,

  iCadeJoystickUpRight = iCadeJoystickUp | iCadeJoystickRight,
  iCadeJoystickDownRight = iCadeJoystickDown | iCadeJoystickRight,
  iCadeJoystickUpLeft  = iCadeJoystickUp | iCadeJoystickLeft,
  iCadeJoystickDownLeft = iCadeJoystickDown | iCadeJoystickLeft,

  iCadeButtonA       = 0x010,
  iCadeButtonB       = 0x020,
  iCadeButtonC       = 0x040,
  iCadeButtonD       = 0x080,
  iCadeButtonE       = 0x100,
  iCadeButtonF       = 0x200,
  iCadeButtonG       = 0x400,
  iCadeButtonH       = 0x800,

} iCadeState;
iCade
iCadeState s = iCadeControl.iCadeState;
if (s) {

 CGPoint acc = ccp(0,0);

 if (s & iCadeJoystickUp) acc.y = 0.25f;

 if (s & iCadeJoystickDown) acc.y = -0.25f;

 if (s & iCadeJoystickLeft) acc.x = -0.25f;

 if (s & iCadeJoystickRight) acc.x = 0.25f;

 CGPoint vec = ccpMult(ccpNormalize(acc), 40);

 if (acc.x==0 && acc.y==0) {

 
      controlArrowDirection.visible = NO;

 }

 else {

 
      if (controlMethod==kControlVirtualPadFixed) {

 
      
 controlArrowDirection.visible = YES;

 
      
 controlArrowDirection.position =
                           ccpAdd(vec, controlArrow.position);

 
      }

 
      [chara setCharaAccelVector:vec];

 }
}
cocos2d 事例編 HungryMasterの実装から

cocos2d 事例編 HungryMasterの実装から