Create a Simple IOS Game
I recently started a project to Empower people to lead successful lives and careers through Technical Skills. I want to give back to the community by teaching Technical Skills. This walkthrough is about creating a simple IOS game. The fact that you can create a simple IOS game in 30 minutes and a snippet of code is amazing. It is inspiring to see that you can create a program that runs on your phone in a short amount of time.
Part 1: Initial Setup + Background Image +Music
- Create a new project with Xcode. Select the Game Template with SpriteKit.
- Import the assets (Background Image Files + Music File).
- Initialize the SKSpriteNode for the Background Image.
- Initialize the SKAudioNode for the Background Music.
Import Assets
- Import App Icon into Assets Folder.
- Import Background Image as an image set into the Assets Folder.
- Import Background Music file into main Project folder. Make sure to include the Music file in the resource bundle.
Background Image
Set the Bounds on the Game Scene
Initialize the SKSpriteNode for the Background Image
Make sure to add a zPosition so that the background image will show up under the rest of the Game Nodes
Background Music
Part 2: Game Characters + Movement
- Add Image Assets for Game Characters
- Add Game Characters to Scene
- Add Player Character Movement
- Add Random Movement for Game Character
Import Assets
- Import Butterfly Image for player as an image set into the Assets Folder
- Import Butterfly Image for the game character as an image set into the Assets Folder
Add Game Characters to Scene
Add Player Character Movement
Add Game Character Random Movement
Part 3: Game Scoring System
- Add Labels for Game Score and Time
- Add Game Logic to Calculate and Display Score
- Update Time Label with Elapsed Time
Add Labels for Game Score and Time
Add Game Logic to Calculate and Display Score
Use the Distance Formula to check if the Game Characters are close enough to each other. Update Score if the Characters are in the set radius.
Update Time Label with Elapsed Time