Hello Guest

Author Topic: How to add Keys?  (Read 1359 times)

0 Members and 1 Guest are viewing this topic.

cracylord

  • Member
  • Posts: 3
    • View Profile
How to add Keys?
« on: May 09, 2015, 09:57:18 AM »
Hey guys,
i'm doing this: http://ericmbernier.tumblr.com/post/74890485795/otter2d-top-down-adventure-tutorial-part-1-an tutorial, but at part three i get an error with those lines:

in Program.cs
Code: [Select]
Global.PlayerSession.Controller.Start.AddKey(Key.Return);

and TitleScene.cs
Code: [Select]
if (Global.PlayerSession.Controller.Start.Pressed)

the Error:

Error 1 'Otter.Controller' does not contain a definition for 'Start' and no extension method 'Start' accepting a first argument of type 'Otter.Controller' could be found (are you missing a using directive or an assembly reference?)

what am i doing wrong? Is this Method outdated?
thanks for your reply.

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: How to add Keys?
« Reply #1 on: May 09, 2015, 03:40:21 PM »
Yeah, the controller class has been changed since that tutorial was written. 

Code: [Select]
var game = new Game();

var playerSession = game.AddSession("Player");
playerSession.Controller.AddButton("Start");
playerSession.Controller.Button("Start").AddKey(Key.Return);

Instead of having a controller be locked down to specific buttons and axes like Start, A, B, X, Y, LeftStick, RightStick, etc, I made it so you can just add whatever buttons and axes you want at the start of the game.

So you first have to add a button to the controller, and then you can get access that button and add keys to it.