简体   繁体   English

如何将简介/主屏幕/标题屏幕添加到iOS游戏

[英]How to add Intro/Home/Title screen to iOS Game

Got a simple game up and running but as soon as the game opens it starts. 启动并运行了一个简单的游戏,但是一旦游戏打开,它就会开始运行。

I realize should have already made the home screen before the rest, but none the less I am here now. 我意识到应该已经做好了主屏幕的准备,但是我现在仍然在这里。

So basically I am asking how do I go about adding a menu so that when the game boots it stops at the menu first therefor enabling the option to press start. 所以基本上我在问我如何添加菜单,以便在游戏启动时它首先在菜单处停止,从而启用按开始的选项。 I have used a combination of apps and google to get where I am now. 我使用了Google Apps和Google Apps的组合来到达现在的位置。 So my programming is limited, but I am not stupid. 所以我的编程很有限,但是我并不傻。

I know I need to make the document representing the menu, add the images to it, and then have the start button call the rest of the app when it is pressed. 我知道我需要制作代表菜单的文档,向其中添加图像,然后在按下该按钮时让开始按钮调用应用程序的其余部分。 But thats it! 就是这样!

Any help is appreciated! 任何帮助表示赞赏! Thank you for your time. 感谢您的时间。

Well, if you are using sprite kit, create another subclass of SKScene, and use SKLabelNode(s) for the "menu items" and do 好吧,如果您使用的是Sprite Kit,请创建另一个SKScene子类,并使用SKLabelNode作为“菜单项”,然后执行

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
     for(UITouch *t in touches) {
        CGPoint location = [t locationInNode:self];

        if(CGRectContainsPoint(*labelNode.frame*, location)) {

            // do action 
        }
     }
 }

you can also do storyboard based items as discussed in comments 您还可以按照评论中的说明进行基于情节提要的项目

hope that helps 希望能有所帮助

in cocos2d games are defined by scenes, layers and sprites. 在cocos2d游戏中,它们是由场景,图层和精灵定义的。 So I suggest thinking about how you would like to break your game down. 因此,我建议您考虑如何分解游戏。 Think about main menu scene, game scene, game over scene, leaderboard scene, and so on. 考虑一下主菜单场景,游戏场景,游戏结束场景,排行榜场景等等。 Then think about how you want to link these scenes together. 然后考虑如何将这些场景链接在一起。 Which will lead to which and what conditions need to be met before such transition occurs. 在这种过渡发生之前,这将导致需要满足哪些条件。

Once you have a high level idea of how you want to break it down take a look at what you have. 一旦有了关于如何分解的高级概念,请看看您拥有什么。 You most likely have an initial scene class that's called from your AppDelegate as your first scene. 您很可能具有从您的AppDelegate调用的初始场景类作为您的第一个场景。

So create a new scene, add your main menu items (like play, choose level, options etc) and have that scene become your initial scene called from AppDelegate. 因此,创建一个新场景,添加您的主菜单项(例如播放,选择级别,选项等),并使该场景成为您从AppDelegate调用的初始场景。

For more detail on how to do this give this a read " Create a simple menu... " I know that tutorial is a bit outdated and may not work as intended with cocos2d v3. 有关如何执行此操作的更多详细信息,请阅读“ 创建简单菜单... ”,我知道该教程有些过时了,可能无法按预期使用cocos2d v3。 But reading it will give you a better understanding of how cocos2d works and how to solve your problem. 但是阅读它可以使您更好地了解cocos2d的工作原理以及如何解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM