Add the basic logic to the various elements on screen.
- [Male Speaker] Now we're gonna create the new function…called the checkCollision.…The checkCollision will check…if a certain element, in this case the ball,…hit another element, in this case the brick or the paddle.…Now we're gonna add the checkCollision function.…The checkCollision function works…with the ballElement and the brickElement.…In future sections we'll add it…as a more general hitElement…because we'll add it to the paddle as well.…
And as you can see, in order to see…if the ballElement and the brickElement actually collided,…we're gonna have various if statements.…Now, if one of these statements occurs,…then basically, there was no collision.…Otherwise, a collision had happened.…Now we can check every logic we have here,…and we're gonna discuss it…and we'll see why that specific statement…if it occurs, it means that the ball…hasn't collided with the brick.…
Now, the ballElement, the x and the y values…are exactly in the middle of the ball.…So in order to get the borders of the ball,…we need to add the BALL_RADIUS.…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Playing sounds in various browsers using SoundJS
- Tweening objects using TweenJS
- Creating graphic assets and basic animations
- Game stage creation and object positioning
- Adding the basic game logic
- Add the game physics
- Adding mouse and keyboard controls
- Debugging with breakpoints in Chrome
- Debugging on Android and iOS
- Character movement and input handling
Skill Level Advanced
iOS Game Development with Swift 3 and SpriteKitwith Todd Perkins2h 52m Intermediate
2. Game Outline
3. Game Logic
4. Planning Your Second Game
5. Testing and Debugging the Game
6. Character Movement and Input Handling
- 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.