Collisions can also be used to keep objects within the bounds of a room. In this video we make sure our paddle collides with side walls and stays in our level.
- [Voiceover] Let's stop our paddle from going outside…the bounds of the room.…Go ahead and open up the paddle in the objects folder,…and let's open the script in the create event.…Maximize the window, and I want to create a new…variable here, we'll call it paddleWidth.…We'll set it to the sprite_width, the width of our paddle.…We're setting this variable in case later we decide to…change our sprite to a smaller or larger paddle.…Which is something we might do if you want to adjust the…difficulty of the game.…Let's save the script.…And now we can add the collision event.…Add event, collision, and we're going to choose sideWall,…because we want the paddle to collide with the side walls.…
Let's add another execute code action.…Maximize the window.…And set a comment, keep paddle in room.…Pretty straightforward.…For this we'll need an if statement to check if the…exposition of our paddle is less than our paddle width.…If X is less than paddleWidth.…Because the script is in the collision event,…we know that the paddle is hitting a wall.…
- Creating a new GameMaker project
- Creating sprites
- Importing existing images
- Adding collisions
- Playing sounds
- Designing game levels
- Creating start and game over screens
- Exporting the game
Skill Level Beginner
iOS Game Development with Swift 3 and SpriteKitwith Todd Perkins2h 52m Intermediate
1. Getting Started
2. The Game Pieces
3. The Gameplay
4. The Game Cycle
5. Finishing a Project
- 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.