Game Development Community

How to bind keys with the level editor?

by Philip Mansfield · in Torque Game Builder · 05/16/2006 (12:33 pm) · 3 replies

I've run into a bit of an odd problem. I've got script in my games main.cs file that binds my keyboard commands:
function setupKeybinds()
{
   // define the controls for the Follow the Lights game
   if( isObject(moveMap) )
      moveMap.delete();

   new ActionMap(moveMap);
   moveMap.bind(keyboard, "r", "flashRed");
   moveMap.bind(keyboard, "g", "flashGreen");
   moveMap.bind(keyboard, "b", "flashBlue");
   moveMap.bind(keyboard, "y", "flashYellow");
   moveMap.bind(keyboard, "p", "playFollowLights");
}

Then in game.cs I push the action map:
function startGame(%level)
{
   // Set The GUI.
   Canvas.setContent(mainScreenGui);
   Canvas.setCursor(DefaultCursor);
   
   sceneWindow2D.loadLevel(%level);

   // initialise the High Score
   $highScore = 0;

   // start the demo mode
   moveMap.push();
   initDemoMode();
}

When I click the Play Level button, none of my binds actually work. If I push the actionmap from the console, I get no errors, but the keys still don't work. If I click Edit -> Preferences, I can see the function names at the top of the keybindings list that should be called, but they have no keys assigned to them.

I'm sure it's something daft that I'm doing, but I have no idea what it is. Any light that can be shone on the problem would be greatly appreciated :)

#1
05/16/2006 (5:53 pm)
I have the same problem, for some reason switching to the T2D project, then back to mine, they start working magically.. I think this may be a bug.
#2
05/16/2006 (11:54 pm)
*phew* I thought it was just me :)
#3
05/29/2006 (2:30 am)
This seems to be fixed in Beta 4.

I just fired up a bounty submission I was working on, and the keys mapped properly straight away.