椰子多点触控游戏

问题描述:

我正在开发一些使用多点触摸iPhone(科科斯)的游戏。任何人都可以教我如何从头开始。我不确定从哪里开始或有哪些资源可以提供帮助。我非常感谢帮助。椰子多点触控游戏

@implementation GameScene 

- (id)init 
{ 
    if (self = [super init]) 
    { 
     Sprite *background = [Sprite spriteWithFile:@"unzip.png"]; 

     background.position = CGPointMake(240,160); 
     [self addChild:background]; 

     Label *aboutContent = [Label labelWithString:@"Welcome to the game" fontName:@"Helvetica" fontSize:30]; 
     aboutContent.position = CGPointMake(240,160); 
     [self addChild:aboutContent]; 
    } 
    return self; 
} 
@end 

我有这段代码。这导入图像。只需要玩家可以触摸中心的2点A和B,并将它们在彼此相反的两侧移动。任何人都可以给我一些例子。?

Monocle Studios有a whitepaper: introduction to cocos2d iphone。 非常好的地方开始。

触摸可以通过任何图层检测设置isTouchEnabled属性为YES。

任何其他CocosNode类后代可以实现协议TargetedTouchDelegateStandardTouchDelegate,然后用触摸调度员注册自己:

[[TouchDispatcher sharedDispatcher] addTargetedDelegate:self 
            priority: 0 swallowsTouches:YES]; 

然后,必须实现:

  • - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
  • - (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
  • - (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event

在那个对象中。

希望有所帮助。