-2

我正在 Cocos2d 和 SpriteBuilder 中制作游戏。是否可以通过点击屏幕切换到新场景?我知道如何用一个按钮来做到这一点。

所以如果有人可以帮助我,那就太棒了!:)

4

1 回答 1

1

是的,它的工作方式与按钮相同。当您了解如何处理触摸时,实现非常简单:

首先为应接受触摸的节点打开用户交互:

self.userInteractionEnabled = TRUE;

然后实现touchBegan:方法:

- (void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
    // if you want to only react to touches in certain areas add check here
    [[CCDirector sharedDirector] replaceScene:myScene];
}

有关 Cocos2d 3.0 中触摸处理的基本介绍,请阅读:https ://www.makegameswith.us/gamernews/366/touch-handling-in-cocos2d-30

于 2014-03-05T17:21:23.720 回答