(No. 00005) iOS pop-up games (4): Game data initialization (1)

Source: Internet
Author: User

(No. 00005) iOS pop-up games (4): Game data initialization (1)

 

In the previous article, we initially looked at the initialization methods of the MainScene class, where the Randomization map was done in the initGameDataFromGD method. Let's take a closer look at this method.

This method is a long method, which calls several other methods. I will list the main code below:

// Use game data to initialize the data of the current level-(void) initGameDataFromGD {[_ gd loadGameData]; // omitting a lot of code _ player that initializes the TAG content of the HUD layer. canw.ssbrick = _ gd. canplayerjavasssbrick; _ player. canw.ssbomb = _ gd. canPlayerAcorssBomb; _ isPlayerSpeedUp = _ gd. isPlayerSpeedUp; if (_ isPlayerSpeedUp) {_ player. speedPerStep = 0.4;} [self updateStateLabel]; _ totalSec = _ gd. curLevelLeftTime; [_ hudLayer updateTimeLabel: _ totalSec]; [self initNoWallTiles]; // random map method [self randomCreateMap]; [self initWalkableTiles]; // initialize the names of all FS classes [FireSprite initClassNames]; [self spawnFireSprites3];}

This method is more "Miscellaneous". It mainly does the following:

Read the data stored in the iOS device to the memory so that the record and content of each play can be saved and reloaded. This is done in the loadGameData method, next we will introduce how to set the corresponding tags in the HUD Layer Based on Game data. The HUD is the dashboard in our game:

The tags include the remaining lifetime, bomb count, current Accumulated Score, power of current bomb, remaining time of the game, and so on. The following is displayed in the actual game:

The vertical bar on the far left is actually displayed outside the visible range of the screen. If necessary, it will pop in. No need to worry about it here.

Based on Game data, set the attributes of the game's main character: whether the game can wear walls and bombs, whether the status labels in the HUD can be updated at high speed, and the updateStateLabel method is called, we will refer to the subsequent initialization of all the tile coordinates that can be laid out. The call method is the initNoWallTiles method and then the randomCreateMap method to create a random map. Don't worry about initializing all the reachable tiles immediately, the call method is the initWalkableTiles method. Initialize all class names in the FireSprite enemy class and generate "Enemies" based on the data in the level. The spawnFireSprites3 method is called.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.