Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline internetfreak  
#1 Posted : Monday, June 10, 2013 11:08:10 PM(UTC)
internetfreak

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.
Mein Blog: www.internetfreak.net

- Inoffizieller DeltaEngine-Supporter und Tutorialschreiber -

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline Benjamin  
#2 Posted : Monday, June 10, 2013 11:24:32 PM(UTC)
Benjamin

Medals: Admin

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.
Offline internetfreak  
#3 Posted : Tuesday, June 11, 2013 8:19:38 AM(UTC)
internetfreak

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 :)
Mein Blog: www.internetfreak.net

- Inoffizieller DeltaEngine-Supporter und Tutorialschreiber -
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
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.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.139 seconds.