3. Suspend the game
Pause Game Overview:
When the game is in progress, the player may encounter a variety of unexpected events. In the cool game of sudden situation of the impact of the game more, the game is played when the player died, the game can only start from scratch, so if the external factors affecting the game, it is obviously unreasonable. Developers change according to this demand, no game added pause function. Next we'll learn how to implement the Pause function in genesis-3d.
Principle:
As shown in Figure 3-1.
Figure 3-1
Implementation method:
Step 1:
Passive pause. When the game is carried out, encounter low electricity warning, telephone, SMS and other unpredictable factors, such as mobile phone equipment switching applications. The developer needs to ScriptRoot.cs the script file, add the stopped () function, and define its own function-related functions by invoking the stopped () function.
1 public override void Stopped ()
2 {
3//pause ();
4//save ();
5}
Step 2:
Game active paused. Players in the game, due to their own reasons need to suspend the game. If the developer's thinking is not clear, then the factors to consider are more complex. It is recommended that developers in the top-level ScriptRoot.cs script file to manage the logic of the entire game, so it is more convenient to achieve the entire game suspend function, can refer to the ScriptRoot.cs file in the logical relationship.
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/