First Android Game - Part 2 June 14, 2023
This is part 2 of making my first Android Game. If you missed part1, you can find it here It was time to create the Start Menu. Using my Figma design as a reference. See image below The Figma design seemed a little too messy with buttons in random places. I decided to place the buttons in the middle vertically down, and the title in the middle. I also added tomatoes with different skins and potatoes as decorations At first it looked ok, but when I sideloaded the build on to the phone, I noticed the title did not pop out. The decorations were too distracting. I wanted the user to notice the title first, then the buttons, then the decorations. Therefore I made the title background darker so it makes the title text pop out more. Added eyeballs to the tomato title of the "o"s. Made the ALPHA value lower for the buttons and the decorations so they don't pop out as more. Moved the decorations beside the buttons so it corresponds with "1 player" and "2 player", instead of randomly placing the decorations. This allowed the title to be seen first, then the buttons then the decorations and background. The 1 player button brings the user the the Game Scene and the Quit button quits the application I made a build to see how the transition would feel from start menu to game scene. When the user presses the "1 player" button, the game scene loads right away and the players must start playing. This felt a little too sudden. Therefore, I decided to set the Time.timeScale=0 when the user presses the "1 player" button. Then at the beginning of the game scene, there is a countdown that takes about 3 seconds before the enemies appear. This allows the user to think instead of rushing in Now it was time to create a GameOver Menu. The GameOver menu opens when the player has 0 life. When the menu opens, Time.timeScale = 0. In addition, it would display the player's final score and coins collected. They would have the option to quit the start menu or restart the scene. Next was to spawn "text" when the coin collides with the player. The text is using textmesh pro and uses object pooling as well. x number of text is spawned at the beginning under the Canvas gameobject but above all the menus in the hierarchy so that the text is displayed above the menus. When the player collides with the coin, the text displays the number of coins collected. The text transform will be set to where the coin was collided and the text will be moving forward for x amount of seconds before being disabled. The text is using textmesh pro and uses object pooling as well. x number of text is spawned at the beginning under the Canvas gameobject but above all the menus in the hierarchy so that the text is displayed above the menus. In game result of coin collection is shown below The player can switch hat and arm based on the power selected from the menu. Each button on the menu has the sprite that the hat/arm will change to. When the select button is selected, an event gets invoked and the player's hat/arm sprite changes In game result of changing weapons is shown below I wanted to create different enemies. So I made an abstract enemy class where the similar properties are speed, score and number of lives the enemy has. The first enemy was already discussed in part 1. The second enemy is a cannon that shoots out the first enemy. The cannon has animations which are created in the same way as the first enemy. The cannon has 10 lives. At the start the cannon would lerp in and stop at an invisible transform. The reason for lerping them in instead of using a portal or particle system to spawn them is because it looked more natural The last enemy is the big boss with 50 lives. It is an enlarged version of the first potato enemy with two cannon enemies attached. Like the second enemy, it also lerps into an empty transform The level text gets increased. Level 1 is the beginning. Level 2 happens when 5 potato enemies are spawned. Level 3 happens when all 3 cannon enemies get destroyed. I used events to invoke when a level has changed. There is also a Level property with a public get where I can check which level I am currently on when an event is invoked Having that event to see when level changes helps with other things such as when to spawn cannon enemy, boss enemy and letting me change the background. The BackgroundToUse function is subscribed to the LevelIncreaseEvent In the hierarchy I attach different backgrounds. Each time the LevelIncreaseEvent is invoked, it will go to the next sprite to change the background to The 2d explosion that you saw is from the Unity Asset Store 2D flat Explosion. This asset is 2D and the design fits my game Lastly, when the player dies, an explosion would spawn. I would wait half a second and respawn the player at the location the player started at the beginning of the game This is it for part 2. Part 3 of my first android game journey can be found here
Recent blogs See all blogs