【问题标题】:cocos multi touch gamecocos 多点触控游戏
【发布时间】:2009-11-18 07:50:03
【问题描述】:

我正在为 iPhone (cocos) 开发一些使用多点触控的游戏。谁能教我如何开始,从头开始。我不确定从哪里开始或任何可以提供帮助的资源。我非常感谢您的帮助。

@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 并将它们移动到彼此远离的相对两侧。谁能给我一些例子。?

【问题讨论】:

    标签: iphone objective-c cocos2d-iphone


    【解决方案1】:

    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

    在那个对象中。

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-01
      • 2015-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多