Part 2 - The Event Sheet
At this point the player can move around on the screen, but there is no way for the player to "win". We need to add logic to make that possible, and we do all that in the "Event Sheet". Go to the top of the screen and click on the even sheet tab.
The event sheet consists mostly of "Events". Each event consists of two parts:
1. One or more "conditions"
2. One or more "actions"
Every 60th of a second, the event sheet is run through in order. For each event, all of the conditions are checked. If they are all true, then that event's actions are taken.
There is one event that gets called only once when the page is first loaded. This event is "System" - "On page layout". This is where we will do all of our initial setup. In addition, we want to define the correct answer as a "Global Variable". So do the following:
1. Right-click on the event sheet to add a global variable called "correctanswer". Set its value to "prophase metaphase anaphase telophase ". Notice the space after telophase!!!
2. Right-click on the event sheet to add the "System" - "On Start of Layout" event. Once you have done this you should add three actions under this event. Your event sheet should look like this so far:
This does three things. First, it sets the "answer" text to blank. Second, it stops the "checkbutton" from automatically skipping to the last frame. Third, it sets the "correctanswer" text to blank so the player doesn't think they are correct even when they haven't done anything.
Adding Touchscreen Controls
Because this game needs to run on mobile devices, we need to add non-keyboard controls. For the purposes of this walkthrough we will add tilt-based controls. If you play a lot of games on mobile devices, you probably know that tilt-based controls can be difficult to use, but I have included them here to show them off. For a better version of this game you might want to add onscreen buttons to make the player move left, right, and jump.
Add the following to your event sheet:
Okay, that takes care of left and right, but what about jumping? For this, go back to the Layout tab and add an invisible sprite to the scorelayer. Make it take up the entire bottom half of the small rectangle so that when the player taps anywhere on the lower part of the screen the smiley face will jump. Once you have done this, add another event to your event sheet:
If you haven't done so already, export your project to your public dropbox folder, right click on the "index.html" file to copy the public link, and then email the link to your mobile device. Open up the link on your phone or tablet, and you should be able to play the game with the tilt/tap controls! For a complete explanation of how to use Dropbox with Construct 2, see this tutorial by Ashley.
What Happens When Player Collides With a Word
When the player collides with a word, we want that word to be added to the answer. Also, we want to gray out the word so it is no longer selectable. Add these events:
What Happens When the User Taps the "Check" or "Reset" Button
Now we're cooking. The very last thing we need to implement is the logic for when the player taps the "check" or the "reset" button. Add these events and subevents to the event sheet:
Note that you will need to do a LOT of right-clicking in the right spots to get all of the sub-events added. In the following event there is an "Else" statement and an "Inverted" condition:
To get the "Else", right-click on the event directly above, and "Add Else". To "invert" a condition, right click on the condition and "Invert" it.
At this point, the entire game should be playable. Congratulations!
In the following version I cleaned everything up, added better graphics, and included a "sky" background layer with clouds and haze to make it all look pretty. If you want to add more questions, all you have to do is create a new layout and event sheet with a different set of answers. Once you finish one, simply go to the next layout. Feel free to modify to your heart's content. Enjoy!
A prettier version of the project
The complete .capx - feel free to modify this!