We setup the Escape keyboard key to toggle pause in our game. GameMaker allows objects to listen for keyboard and mouse events.
- [Narrator] Now let's open up our pause object…and add a new event to activate it while in game.…Click Add Event,…and this time we'll use the Key Release Event.…And the key we want is under Others.…We'll use Escape to pause the game.…Add a new script,…maximize the window,…and give it a name of Toggle Pause.…We need two if checks here.…The first,…if (obj_ball…to reference our ball object,….ballLaunched == true)…This is to make sure the game is already started…before we try to pause.…
The next,…if (paused == false).…This makes sure we're not already paused.…In this case,…we'll pause by setting paused = true…in the case where we already are paused,…We'll use an else block.…Else…paused = false…and now we can save the script and give it a try.…Run the game.…And now,…try pressing escape before the game starts.…Notice the game doesn't pause as expected.…Now we can left-click to launch the ball,…and now press escape.…
And now we see the paused text…going back and forth across the screen as expected.…But the ball keeps moving.…We'll fix that now.…
- 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.