How do I let user customize controls?

Get help using Construct 2

Post » Sat Aug 30, 2014 9:31 pm

I'm working on adding custom controls to my game...beacuse I hate when developers lock you into their button layout. :x

Anyway, it occurs to me that this must have been discussed before, included in a tutorial, etc...but my searching isn't getting anywhere.

In particular, I'm having a bit of trouble coming up with an elegant solution to custom map mouse buttons. With the keyboard I can just store keycodes in global variables like "keycode_foo", then "On keycode (keycode_foo) pressed".

However, there is no "On (keycode_foo) mouse button clicked" action, and all I'm coming up with is awkward, convoluted event trees.

Cheers, T
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Sat Aug 30, 2014 9:43 pm

Not sure if this will help you, but it might..
It's meant to turn Keyboardinput into the numbers on the NumPad..
so to check if a key is pressed and the mousebutton is pressed at the same time would be rather easy (But I might have totally misunderstood your question)
You do not have the required permissions to view the files attached to this post.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Aug 30, 2014 10:50 pm

Sorry, but that's not quite what I'm after. Trying to come up with a good way to alias any mouse button to any control.

With the keyboard, I can store keycodes in global variables (or an array) and then have "On keycode (keycode_foo) pressed" events. When these are true, I set a global var to 1. So

On keycode Keycode_Attack pressed:
Set ControlDown_Attack to true

However, there is no equivalent "On mouse button (mousecode_foo) pressed" action. Instead I have to do:

On left/middle/right click
Set ???

With the keycode solution, I know what the user is trying to do by the name of the keycode var, and I know they are pressing the right key by evaluating it's value. But...how do I handle that for the mouse? All I can tell is when the the different mouse buttons are down...I have to figure out what said buttons are supposed to do with other logic.

I can think of a couple ways to do it, with functions or groups, but my approaches seem overly complicated. I can't help but think "Ockham's razor...you are missing something."
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Sat Aug 30, 2014 11:04 pm

couldn't you just add a variable mousebutton or something and make actions based on that variable..
there's only three mousebuttons, so creating an event to change the mousebuttonvariable based on user preferences shouldn't be hard..
It seems to me to be that easy, but I might be overlooking something?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Aug 31, 2014 12:19 am

Call back referenes. Personally I like to use a dictionary. There is a tutorial. but it's all about knowing the keywords to use.... but you won't know them until you found the tutorial in the first place :D

The gist is

step. 0
[---Group Assign Function(active)----]
OnAnyKeyPress
->Dictionary.Add( "Press" & keyboard.lastkey, FunctionToAssignSelection.FunctionAbility)
-> Deactivate Group Assign Function

step. 2
on any key pressed
-> Function.Call( Dictionary.Get( "Press" & keyboard.lastkey), whatever holds paramaters )

step 3. on saving of setp
WebStorage.Set( "controller setup", Dictionary.ToJson )


step 4. on loading setup
Dictionary.FromJson( WebStorage.Get("controller setup") )


and that's the basics. do the same for mouse, joysticks so on etc.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,028

Post » Sun Aug 31, 2014 9:43 pm

@LittleStain

Essentially, but I want a system with a little more flexability...jayderyu makes a good suggestion.

@jayderyu

Never thought of that...much better than triggering a bunch of functions or groups by name. Will also make it easier to load control setups in/out from text files, etc. Thanks!
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Fri Sep 05, 2014 3:18 pm

Can someone go more in depth about what @jayderyu posted please?

It would be really good if the player in my game was able to change their buttons and I want to learn how to do it but I am unsure about how to do it exactly what jayderyu posted.
B
10
S
4
Posts: 56
Reputation: 919

Post » Fri Sep 05, 2014 3:32 pm

Bodhran wrote:Can someone go more in depth about what @jayderyu posted please?

Actually that is already in-depth, and a good answer. Take time to browse through manual based on what he said, I guess you should be good.

It always better if you ask specific question though. ;)
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Fri Sep 05, 2014 4:28 pm

i have makes project what you are need (I think). My Friend asking same problem. I work midnight, but i have done and get result!

this is my project: http://c2tuts.tk/project/ChangeControll/

and this is download link: https://drive.google.com/uc?export=down ... GJDeERjWnM

There are using my country language (Indonesia, Melayu). So, if you dont understand just click "jump" or "move right" then press your keyboard key you want. Sorry for my english.

I hope this help!

Regards,
-Regga354
Creating games makes your imagination realized
B
14
S
4
G
1
Posts: 55
Reputation: 1,130

Post » Fri Sep 05, 2014 5:05 pm

@Regga354 So far it works perfectly. Thanks so much. This is really cool.
B
10
S
4
Posts: 56
Reputation: 919

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev, dop2000 and 33 guests