Open main menu

Difference between revisions of "AGIWiki/controller"

330 bytes added ,  09:44, 25 April 2013
m
Line 23: Line 23:
== Example ==
== Example ==
<syntax type="C++">
<syntax type="C++">
//build a simple menu structure
//build a simple menu structure
set.menu("File");
set.menu("Info");
set.menu.item("Save Game      <F5>", c2);
set.menu.item("About  ", c0);
set.menu.item("Restore Game  <F7>", c3);
set.menu.item("Help    ", c1);
set.menu("File");
set.menu.item("Save Game      <F5>", c2);
set.menu.item("Restore Game  <F7>", c3);
set.menu.item("-------------------", c20);
set.menu.item("Restart Game  <F9>", c4);
set.menu.item("-------------------", c20);
set.menu.item("Quit        <Alt Z>", c5);
//disable the separators
disable.item(c20);


//submit menu to agi
//submit menu to agi
submit.menu()
submit.menu()


//create keyboard shortcuts
//create keyboard shortcuts
set.key(0, 63, c2); // 'F5'
set.key(0, 63, c2); // 'F5'
set.key(0, 65, c3); // 'F7'
set.key(0, 65, c3); // 'F7'
set.key(0, 67, c4); // 'F9'
set.key(26, 0, c5); // 'Alt-Z'


//test for menu or keyboard selections
//test for menu or keyboard selections
if (controller(c2) {
if (controller(c2) {
  //save game
  //save game
  save.game();
  save.game();
}
}
if (controller(c3) {
if (controller(c3) {
  //restore game
  //restore game
  restore.game()
  restore.game()
}
}
...
</syntax>
</syntax>


885

edits