At the WWDC 2015 conference held in the early morning of June 9, Apple announced iOS 9 and launched two very important tools, namely GameplayKit and ReplayKit. Judging from the company's introduction, these two tools may have a relatively large impact on iOS mobile game developers and European and American game video related fields. Simply put, GameplayKit is a basic tool and technical framework that helps novice developers create games on OS X and iOS platforms. It provides game resources, modules, gameplay design, and system rules, but does not include visual rendering and other functions. Therefore, for some experienced developers, a game development framework that supports multi-platform releases and has more complex functions may be more suitable. Few details about ReplayKit have been revealed. On Apple's official website, we can see that players can use this feature to record, edit and share games online, but there is no further explanation. The following is the official Apple GameplayKit Reference and Programming Guide (due to space limitations, only the concept part is translated here. If you want to understand the examples, please go to Apple's official website and download the sample game code): Part 1: Framework Reference Tip: This is an overview of an API or technology under development. Apple provides this information primarily to help you plan your use of these technologies or programming interfaces with Apple products. This information may change in the future. The software mentioned in this article should be subject to the final release of the operating system testing and final documentation. New versions of the documentation may be provided in the future. GameplayKit is an object-oriented framework that provides basic tools and technologies for building games on OS X and iOS platforms. GameplayKit includes tools and reusable frameworks for designing game features, as well as technologies developed to create and improve gameplay features, such as character movement and enemy behavior design. Getting Started with GameplayKit The GameplayKit framework includes a number of independent branch systems that cover multiple areas of game design and development.
Part 2: GameplayKit Programming Guide GameplayKit is a set of basic tools and technologies developed for making games on iOS and OS X. Unlike the more advanced SpriteKit and SceneKit game engines, GameplayKit does not include animation and visual rendering. GameplayKit mainly helps developers develop game play and design modular components to create scalable game architecture with minimal effort. GameplayKit Features Building, improving, and maintaining a complex game requires very good game design. GameplayKit provides an entity component architecture to help you design reusable gameplay code and a state machine system for solving complex process-oriented code. GameplayKit also includes some randomization tools that can provide basic resources for many kinds of gameplay. Creating an excellent game also requires the use of complex algorithms to solve many common gameplay problems. With GameplayKit, you no longer need to write your own algorithms, but can directly use the resources provided by GameplayKit, so that developers have more time to focus on making the gameplay more unique. For example, you can use the Minmax Strategist feature to build an AI system for a turn-based game, design navigation routes for game characters through the pathfinding function, set up automatic walking for high-level game characters, or use a rule system separated from the code and implement fuzzy logic reasoning. Since GameplayKit exists independently of advanced game engines in iOS and OS X, you can integrate it with any technology that can make a complete game, such as SpriteKit for 2D games, SceneKit for 3D games, or third-party game engines customized using Metal/OpenGL ES. For games with low image quality requirements, you can even create games directly using only GamePlayKit and UIKit (in iOS) or AppKit (in OS X). #p# Randomization There are many ways to play games that are based on probability and chance. In board games, players use dice to determine the number of moves, card games have a shuffle method, hostile creatures in arcade games appear at unpredictable times, every action in RPG games has the possibility of success or failure, and background characters in open world games move naturally. There are too many examples to prove this. Unexpected surprises can make a game more interesting, and changing behaviors at each step can increase the replay value of the game. Elements that imitate natural systems can make the game more vivid and realistic. To make a game that relies on probability, you usually need to use a pseudo-random number generator, or random resource. However, not all random resources are equal, and if used improperly they can defeat the purpose of the developer. To create excellent pseudo-random behavior in a game, you usually need to achieve the following features:
Transparent allocation mechanism : For randomization in many gameplays, numbers should use a uniform allocation mechanism, that is, everyone should have the same probability of generating a specific number. For other purposes, these random numbers should follow a specific allocation mechanism. For example, many games have added a normal allocation mechanism, and random samples often produce numbers close to the average. GameplayKit includes several randomization classes that are sufficient to meet these goals of developers. How to use randomization in your game All randomization classes in GameplayKit follow the GKRandom protocol, which can generate random numbers with a minimal interface. First, you need to choose a random generator that suits your game task: In most cases, you need some random numbers that are fixedly distributed in a specific range. For this kind of task, use GKRandomDistribution. If you want to customize the random behavior while maintaining a uniform distribution, you can choose different GKRandomSource subclasses to provide basic random values for the GKRandomDistribution object. To customize the random number distribution, use the GK GaussianDistribution or GKShuffledDistribution class. If you don't need a specific range or distribution of random numbers, you can use GKRandomSource subclasses directly. You can also use one of the GKRandomSource classes to shuffle a sequence of numbers, such as shuffling a deck of cards. First, select the random source object you want, then put the sequence into the source. This method returns the original sequence of numbers, but in shuffled order. Entities and Components Like any software, designing a complex game requires planning a good architecture. As your game grows larger and richer, some of the decisions made when you first created a sample game demo may become obstacles on the road to game development. GameplayKit can provide a framework that you can reuse from the beginning, separating different aspects of your game. In this architecture, an entity is a general term for the types of game-related objects. Entities can represent objects that are very important to the gameplay, such as players and enemy characters; they can also be objects that only exist in the game and rarely interact with the player, such as animated decorations in a level. Entities can also be creative or game UI elements, such as a system that determines where to place local characters or a system that manages player character equipment, etc. An entity only works after it contains game components. A component is an object that handles a specific and limited aspect of appearance or behavior. Since the functional scope of a component is limited and it is not affiliated with a specific entity, you can reuse the same component in multiple entities. State Machines In almost every game, gameplay-related logic is highly dependent on the current state of the game. For example, animation code may change depending on whether a player character is currently walking, jumping, or standing. Enemy movement code may depend on the simulation decisions you make for it, such as whether to chase weaker players or avoid stronger ones. Even the frame rate code that your game runs at a particular time may update depending on whether the game is playing, paused, or in a menu or cutscene interface. When you're starting out developing a game, it's tempting to put all the code that depends on the game state in one place. However, as your game grows in complexity, a single approach becomes difficult to scale. State machines can help you define the rules for different game states. These definitions are called state machines. Then, you can associate related states with any code, and switch modes in different game states. Using state machines to manage code makes it easier for you to rationally deal with complex behaviors in the game. State machines can be used in any part of your game. Minmax Strategist Features Many games were popular before the advent of video games, especially board games, such as backgammon, chess, rock-paper-scissors, and Go, which are all games in a logical sense. To win in these games, players need to plan the best moves at each opportunity, taking into account the opponent's moves. These games are very exciting to play, whether the opponent is another person or a computer player. In GameplayKit, Strategist is a simple form of AI that you can create computer opponents for this type of game. Games that use Minmax strategy should use the GKMinmax class and supporting APIs with the following characteristics: Sequentiality: Each player needs to act in sequence, that is, players take turns to experience. Adversarial: For one player to win, other players must lose. The design concept of this type of game is that every step a player takes should bring him or her closer to victory, or bring other players closer to failure. Knowability: Players can confidently guess what consequences each of their steps will bring, that is, players' actions do not depend on chance and probability. Perfect Information: All information important to the outcome of the game must be available to all players at all times. For example, chess is won or lost based on the positions of the two players on the board, but most players can see these positions most of the time. If someone hides the chess pieces during the process, then it is not perfect information because one player's actions become unknown. Pathfinding Navigation is a very important concept in many games. Some turn-based games require players to choose a path to a goal. Many action and adventure games put characters in mazes that players must solve to achieve gameplay goals. Enemy characters must challenge players in a predetermined way. The process of deciding how to set up a game maze or other navigation aspects is pathfinding. GameplayKit provides a series of maps and pathfinding tools for your game that you can use to move characters or other game components. Using GameplayKit pathfinding tools requires describing the navigation area in the game as a graph with different locations or nodes. The path a component takes to move from one location to another is different. Since most 2D games are suitable, it is very easy to make a pathfinding system for these games. Agents, Goals, and Behaviors In many games, the real-time movement of game components is automated to a certain extent. For example, a player can drag a character to a specific area in a game, and the character will automatically walk and reach the location. Enemy characters may attack in the map, planning to interrupt the player's actions. Allied players can tell the player to keep a parallel distance through messages. In all cases, the movement of each component may have real control, so the game character can still move and change direction in real time. The proxy system in GameplayKit can provide an efficient way to automatically move. An agent means that the components in the game will move in 2D space according to the characteristics of the situation, such as size, position and speed, and of course the resistance when the speed changes. The movement of a component depends on its action target. A goal is something that can affect the agent's mobility behavior in the long term. Behaviors are associated with one or more goals that cause a game component to move. For example, a goal might include moving directly to a point, avoiding all obstacles along the way. When you combine multiple goals in a behavior, you can assign weights to each goal that has a relevant impact. Rule Systems Some games contain very complex rules. For example, a turn-based RPG combat game may dictate how opposing characters react when they arrive in the same area, such as who strikes first, whether they can attack each other, and what happens if a character tries to attack or interact with another character. Some of the most interesting games involve emergent behavior, where interactions between simple individuals can generate interest for the entire system. In GameplayKit, the rule system solves these problems. By comparing game logic data, the rule system can help you decompose the game into functional, reusable, and extensible components, and simple rules can also lead to complex behaviors. GameplayKit contains two main rule system building classes, namely GKRule, which represents specific decision rules under permanent state, and GKRuleSystem, which determines the rules of some specific aspects of state data. |
<<: When the whole world is talking about Swift open source - 2015 Objective-C new features
Every year when the Spring Festival is approachin...
《Cotton Swab Medical Science Popularization》 Yang...
Preface There are two characteristics of the seco...
The first public crusade against facial recogniti...
If you want to do a marketing campaign that will ...
In the field of new energy vehicles, China's ...
In mid-April, between Qingming and Guyu, the wist...
Recently, Volkswagen (China) Sales Co., Ltd. file...
Introduction: It is said that to see whether a pe...
...
Every time you sell a product, you should keep re...
[Original article from 51CTO.com] Cloud computing...
Reviewer of this article: Xu Qibin, associate chi...
1. How to formulate an operation plan for a new a...
Earlier, the media reported that Atsushi Sakurai,...