change control

Shishkov

  • Posts: 169
Hello everybody.

I want to dublicate control. Now I have left, right,up, down arrow keys, but I, also, want to have WSAD keys. How can it be implemeted?

And how can change control during the game using code?

Photon

  • Posts: 2691
Perhaps you could store the current control being used for the game in a text game attribute. For instance, you could start by having the name of the up-key control in it, and then change it to the W-key control's name as needed.

The slightly trickier part would be then using that text and converting it to a control object. It's probably not that difficult to do, but I am not sure of what exactly you would need to do off the top of my head.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

Tuo

  • *
  • Posts: 2469
Umm... you could just use "or" conditions. That's what I do. For example "if [down is down] or [S is down]". You can change controls by have a game attribute that you then check to see which version is desired (for example, if Mode = 1, use WASD, otherwise if Mode = 2, use Arrows); that's what I did for my game anyways.
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

Shishkov

  • Posts: 169
How can I add these additional buttons to other buttons in settings? Simply add, for example, S to down arrow key or W to up arrow key?
I tried it once, but it did not work. Only first chosen key worked rather than second one 

« Last Edit: March 30, 2013, 10:29:11 am by Shishkov »

gruffman

  • *
  • Posts: 564
Ok, so normally as default in your Game Settings tab you will have a listing for

Name : down
Key : down

ok, next go to the bottom and click

"click here to add a new control"

here is my suggestion for your entry;

Name : AlsoDown
Key : s

INPORTANT, you need to now close any open tabs you have or they will not `see` your changes. This is usually the case with any changes made in the game settings tab.

Ok, now go to the palette as usual in the scene (i'm guessing this is where you want to check for key presses)

create a "when updating" event;

make this;
If (control is down) or (control is down)

and turn it into this

If (Down is released) or (Alsodown is released)
put_code_here_to_move_player_down

Hope this helps!
Now available for all Android Devices - Happy Face Concentration
My Games To Date
Find A Face / Hero Of Oda / Snakes And Ladders
Hungry Monkey available at fgl.com for Sponsorship
My site - Gruffgames.com

SadiQ

  • Posts: 1795
In the controls page ADD new controls, not keys on the existing controls. There's probably a bug with using more keys under the existing controls. Then as Tuo sugested use the OR block to use the arrows or the controls you want.

Edit. hehe Gruffman beat me to it :P
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.