[EDIT: New source file (v0005), added comments to source]
While I wait for Construct's animation system to be upgraded to the point I can resume working on my test level, I figure I'll step ahead and go through the process of creating a menu screen.
<img src="http://www.strouperman.com/Special/SFG/titlescreen.jpg">
Most of the times I see MMF and Construct apps, the title screen requires a click of the mouse. While this is fine, it doesn't lend itself well to more traditional games that required arrow and button key navigation. So let's make one.
The thing we have to get through our heads is that when we make a selection system, we're often times not working with the objects themselves. We work with variables, and the variables control everything. To set ourselves up for this, we need a local object to carry the variable that will control the menu. In this case, I chose the sprite that contains the game's logo. We'll set up a private variable in it called "Selector" with a default value of 1.
Now we have to determine which functions our variables can't or shouldn't control. The only thing I can really think of is the little chime sound that comes when you press up or down. So, we'll load that function onto the controls themselves.
To make our controls, we have to give them limits. We don't want our variable to go outside of the number of items in our menu. In my menu, there are five choices. This into account, and with our sound events, the events needed are as follows:
///
Mouse&Keyboard: On "Move Down" pressed.
Logo: Value 'Selector' is less than 5.
Logo: Add 1 to 'Selector'.
DirectSound: Autoplay wav file.;
Mouse&Keyboard: On "Move Up" pressed.
Logo: Value 'Selector' is greater than 1.
Logo: Subtract 1 from 'Selector'.
DirectSound: Autoplay wav file.;
///
Next we need some way of indicating which item is currently selected. Though I'm sure you can be more creative, I'm going to use Construct's useful FILTER feature to tint my menu selection red.
Much like in my last journal, I'm going to opt for a brute force method. The smartest way of going about handling multiple objects at a time is with either containers or families, but seeing as how I don't really trust those features yet (forgive me, Ashley!) and especially since families cause problems with Vista as of this writing, they hold no benefits opposed to just adding a few more lines of code than normal.
I should note, of course, that using families would make adding items to the menu easier in the future. Oh well.
///
Logo: Value of 'Selector' is equal to 1.
Trigger once while true.
MenuItem1: Set filter to Red.
MenuItem2: Set filter to White (none).
MenuItem3: Set filter to White (none).
MenuItem4: Set filter to White (none).
MenuItem5: Set filter to White (none).;
Logo: Value of 'Selector' is equal to 2.
Trigger once while true.
MenuItem1: Set filter to White (none).
MenuItem2: Set filter to Red.
MenuItem3: Set filter to White (none).
MenuItem4: Set filter to White (none).
MenuItem5: Set filter to White (none).;
[ect, ect until finished]
///
Finally, we need one event per menu item having to do with whatever key(s) will activate the choice. If there is any title screen music playing, we should also stop it at this point.
///
Mouse&Keyboard: On key "Enter" pressed.
Logo: Value 'Selector' is equal to 1.
DirectSound: Pause music.
DirectSound: Play wav file.
System: Go to layout #.;
[ect, ect per choice]
///
As always I encourage you to reply with your own strategies on this topic. Especially reply if I made a glaring mistake in my own implementation.
Here are some source files for you to peruse.
The sound pack is optional. It is there to provide a complete experience if desired.
CAP FILE:
http://www.strouperman.com/Special/SFG/ ... _v0005.cap
SOUND AND MUSIC PACK:
http://www.strouperman.com/Special/SFG/SoundPack.zip