简体   繁体   English

iOS益智游戏的设计模式

[英]Design pattern for iOS Puzzle Game

I am trying to create an iOS based Puzzle game using Objective C. There would be at least 30 different kinds of puzzles/games including mazes, tic tac toe, small crosswords etc., all in one iOS game. 我正在尝试使用Objective C创建一个基于iOS的益智游戏。在一个iOS游戏中,至少会有30种不同的益智/游戏,包括迷宫,井字游戏,小填字游戏等。 How do I proceed with the creation of Views, View Controllers etc., Do I host every puzzle in a separate UIView and load it as subview when necessary, or use separate UIViewControllers for every puzzle and navigate among them? 如何进行视图,视图控制器等的创建?是否将每个拼图托管在单独的UIView中,并在必要时将其加载为子视图,还是对每个拼图使用单独的UIViewControllers并在其中导航? I'll be reusing the puzzle again and again with slight changes during the course of the application - ie, A Tic Tac Toe would be displayed first, followed by a maze, then the same tic tac toe would be displayed, but with different background, colors, etc., Which is the commonly used and best design pattern for this kind of application for creating view, view controllers and holding the images, colors, progress in memory? 在申请过程中,我将一次又一次地重复使用该拼图,并进行一些细微的更改-即先显示一个Tic Tac Toe,然后显示一个迷宫,然后再显示相同的Tic TAC Toe,但背景不同,颜色等,对于创建视图,视图控制器以及保存图像,颜色,内存进度的这种应用程序,哪种是最常用的最佳设计模式?

You first need to make a menu(class) so the player can decide which game they want to play. 首先,您需要制作一个菜单(类),以便玩家可以决定他们要玩哪个游戏。

  1. Create a new class (example mainMenuScene) 创建一个新类(示例mainMenuScene)
  2. make sure the new class displays your menu png and any or all buttons. 确保新类显示菜单png和任何或所有按钮。
  3. Don't forget to import your class (mainMenuScene) on your view controller. 不要忘记在视图控制器上导入类(mainMenuScene)。
  4. Make sure your viewController starts with MainMenuScene first. 确保您的viewController首先以MainMenuScene开头。
  5. Then implement touchesBegan in your MainMenuScene so when the user taps it. 然后在MainMenuScene中实现touchesBegan,以便用户点击时实现。 the app will trans to the game tapped. 该应用程序将转换为点击游戏。
  6. setup all games in different classes and have all classes wired up to the story board. 设置不同类别的所有游戏,并将所有类别连接到故事板上。

That is how I would do it but of course there are a billion ways. 我就是这样做的,但是当然有十亿种方法。

another way would be to use a table view controller listing your games. 另一种方法是使用表视图控制器列出您的游戏。 Then wire up all games in the storyboard. 然后在情节提要中连接所有游戏。

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

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