Delta Engine
»
Support
»
Input
»
Managing Input and command
Joined: 12/19/2011(UTC) Posts: 529
Thanks: 10 times Was thanked: 16 time(s) in 15 post(s)
|
Hello again, I'm back with another question :)
I'm currently working on something for my project and it's using the InputCommands class. I also want that thing to be configurable regarding keys. Now I have a little question: In my current class structure, I have one private member per key (later I will also probably use GamePadButtons and Touch if somehow possible and good implementable). Each key can be reset thorugh its appropriate public property which calls then InputCommand.Remove to remove the old command and then I want to add a new command with InputCommand.Add. Since Remove takes only a Command as param (and nothing else), I also have to store a command for each button. And this is my problem: Is it good to store it like I described or should I use a better way? What I want is to be sure that the old command is correctly deregistered before I register the new command so I more or less have to store the command (the Key could probably get removed since it makes no sense to store it, setting a new key can also be done with a method)
I hope you can understand my problem and maybe give me some tipps if there's something which could be done better. For now I let my class like it is now but I think I will remove the Key references tomorrow and build a method instead to set the key so I more or less only have to store the Command for deleting and registering. |
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
Currently your best bet is to store the commands you create and then remove them when you are done. A good place for creation is the constructor and then remove them again in the Dispose method once you want to move to a different part of your application.
In the future this will be simplified via the Scene class, whenever you leave a scene all input commands will be destroyed automatically for you, which makes it a bit easier to make a transition from menu to level or from one game mode to another. We will provide tutorials on working with commands, ui and scenes shortly.
|
|
|
|
Joined: 12/19/2011(UTC) Posts: 529
Thanks: 10 times Was thanked: 16 time(s) in 15 post(s)
|
Good answer, Benjamin, helpful as always^^ You confirmed my assumption, I have to store the Commands so I can manipulate them. I'd like to use scenes for better handling but the problem is that the component I'm working on is a bit more special so it would not fit into a scene. I also need to change the command whenever the associated key changes so it listens for that key instead of listening for the old key. To achieve that I will create the commands and whenever the key changes, I will remove the old command and register the new command.
Again thanks for your answer, you helped me although I only could use a small portion of your answer :) |
|
|
|
|
Delta Engine
»
Support
»
Input
»
Managing Input and command
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.