Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please tell me, if you feel good please support a lot of praise. Thank you! Hopy;)
We initially looked at the Mainscene class initialization method has done the god horse thing, in which the random map is done in the INITGAMEDATAFROMGD method, we have to look at this method in depth.
This method is a relatively long method, and there are several other methods called, I put the main code listed below:
//Initialize data from the current level with game data-(void) initgamedatafromgd{[_gd Loadgamedata];//Omit a lot of code to initialize the contents of the HUD layer's tag_player. Canacrossbrick= _GD. Canplayeracrossbrick; _player. Canacrossbomb= _GD. Canplayeracorssbomb; _isplayerspeedup = _GD. Isplayerspeedup;if(_isplayerspeedup) {_player. Speedperstep=0.4; } [ SelfUpdatestatelabel]; _totalsec = _GD. Curlevellefttime; [_hudlayer updatetimelabel:_totalsec]; [ SelfInitnowalltiles];//Randomized map method[ SelfRANDOMCREATEMAP]; [ SelfInitwalkabletiles];//Initialize names of all FS classes[Firesprite Initclassnames]; [ SelfSPAWNFIRESPRITES3];}
This method is more "miscellaneous", it mainly does the following things:
- Read the data stored in the iOS device into memory so that every record and content you play can be saved and reloaded, which is done in the Loadgamedata method, which is explained later
- Set the corresponding label in the HUD layer according to the game data, the HUD is the dashboard in our game:
These include the remaining number of lives, the number of bombs, the current accumulated score, the current bomb's power size, the remaining time of the game, and so on. The actual game is displayed as follows:
The leftmost column is actually displayed outside the visible range of the screen, when needed to bounce in, here do not tube it.
- Set the character of the game according to the game data: Whether you can wear walls and bombs, whether it is in high-speed mobile state
- Update the status label in the HUD, call the Updatestatelabel method, and refer to the following
- The next step is to initialize all tile coordinates for the layout, and the method to invoke is the Initnowalltiles method
- Then call Randomcreatemap to create a random map, and don't worry about it right away.
- Initializes all the tile that are available, calling the method Initwalkabletiles method
- Initializes all class names in the Firesprite enemy class
- According to the data in the level "output" enemy, call is the SpawnFireSprites3 method
(no.00005) iOS implementation bomber game (IV): Initialization of game data (i)