The hero can run now, but there is no effect when the hero hits the coins and obstacles. Implement the logic when the hero hits them.
- [Narrator] Hi there.…Welcome back to the video.…In the last video, we created the Coin Game Object Class…and put an instance on stage.…In this video, we check the collision…between the Hero and the Coin's collection.…We define a new method, eatCoin,…to remove the Coin from the World Class and the array.…Let's open the game-es6 script encode editor.…We define an array to store all Coins reference.…We have one Coin instance in the world class.…
We push that into the array.…The tick function in the world class,…besides the enemy checking logic,…we detect the Coin's collision.…If the return value isn't false,…we get the reference of the collided Coins.…What we do here is to remove the Coin from the world…and the Coin's array.…It is a large block of code that we want to dedicate…to a function for this Coin-removing logic.…Let's name the function eatCoin.…
We call it and pass the Coin reference to it.…Then, we define this eatCoin function.…The eatCoin method loops all the Coin instances…in the array and finds the index.…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Planning your first game
- Setting up your file structure
- Setting up HTML and JS
- Drawing basic shapes with EaselJS
- Implementing your first game object
- Creating the core game logic
- Adding graphics to your game
- Planning your second game
- Handling obstacle and hero collisions
- Making the hero run and jump
- Adding graphics and animations
- Polishing your final game
Skill Level Beginner
Q: Should the exercise files be run from a server or locally?
A: Please run the exercise files from a server as directed. The files will not work properly if run locally.
iOS Game Development with Swift 3 and SpriteKitwith Todd Perkins2h 52m Intermediate
1. Planning the Count Game
2. Creating the Core Game Logic
3. Polishing the Count Game
4. Planning the Rush Game
5. Moving the Character
6. Collision Detection
7. Building Levels
8. Polishing the Rush Game
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.