More Related Content
Similar to cocos2d 事例編 HungryMasterの実装から
Similar to cocos2d 事例編 HungryMasterの実装から (20)
cocos2d 事例編 HungryMasterの実装から
- 1. cocos2d HungryMaster
xionchannel software
- 2. cocos2d HungryMaster
xionchannel software
- 10. …
CCLayer
CCLayer
CCMenu
- 20. CCScene CCLayer
CCScene
LayerBelow
OverTopLayer
- 21. CCScene CCLayer
CCScene
LayerBelow
OverTopLayer
- 25. 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;
}
- 35. …
@”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;
- 42. CGPoint uiViewPos = [myTouch locationInView:[myTouch view]];
CGPoint cocosPos = [[CCDirector sharedDirector] convertToGL:uiViewPos];
//
cocosPos = ccpSub(cocosPos, self.position);
if ([nextButton isHitByPosition:cocosPos]) {
//
}
- 48. 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];
- 49. 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]];
- 69. 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;
- 70. 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];
}
}
Editor's Notes
- \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
- \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