How do I create a virtual Dpad?

  • How do I create a virtual Dpad for something like a tablet?

    I know it has to to with the touch object but how do you set it up in code?

    the default Dpad only supported 8 directions right?

    how would I do something like this and still be able to do things like double tapping

  • https://www.scirra.com/tutorials/202/to ... put-method

    If you're trying to do something like a platformer, you can always set the sprite to something like:

    on sprite touched - simulate platform pressing whichever direction - I don't see why that wouldn't work.

  • well its a retro arcade space game

    however I need to limit the dpad to only take 2 adjacent inputs?

  • Ahh, so like: if these buttons are pressed ->disable other buttons sort of thing?

  • ya

    basicly 4 directions

    right, up, left ,down

    and it only lets you press 2 of the 4 direction that are next to eachother

    rightup upleft, leftdown, downright would be the limit of multiple buttons being pressed

  • I'm also relatively new to C2 so that may be a bit out of my depth. I'm going to try and make something (although, with my keyboard) and hopefully we'll get there together.

  • k thankyou

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Update:

    So I've managed to get a system working where:

    down/right and down/left neglect other inputs - however, I'm having issues making that work for other combinations. (So if there's someone more experienced that can see what I've done wrong here, please let me know!)

    I'm not really changing my method between combinations so I'm not sure why I'm running into this issue. I'm sort of stuck but maybe I'm on to something if a few inputs are working correctly?

    My method:

    I made a global variable called Touchable and set it to 3. (there is a text box I put in the layout to display this)

    I made the player a platform with default controls set to "no" (so we can get vector info)

    I set gravity to 0 (so the platform doesn't fall and can be pushed at different angles)

    When left/right/up/down are pressed subtract 1 from global variable.

    On any key released add 1 to global variable.

    Then I defined what inputs do (ie, which angle the platform moves toward, depending on whether global variable is 0 and what is pressed when it is 0. See my capx for numbers).

    Here's a link to my project folder. Choose "newproject" and not the other capx (which, somehow, was corrupted?)

    Also, it's not notated, sorry!

    https://www.dropbox.com/sh/o74rl6lz2du6 ... JTUCa?dl=0

  • can you save it to a single file?

    so I can take a look?

  • https://www.dropbox.com/s/ffru0h3v929bo ... .capx?dl=0

    EDIT: I think I've realized that this method just wont work for more than 1 or two keys. Once opposites are introduced, (up/down, left/right), they both end up travelling at 0 degrees. I'll spare the boring details about other things I tried doing using the global variable.

    I'm thinking that using key codes (for the inputs I'm using) would work best. I don't know how that would translate to a touch interface...

    My thinking would be to have duplicate sprites, one set that is pressable and one set that is not. When 2 are pressed the other two can be destroyed and spawn the unpressable ones. When less than two are pressed the unpressable ones can also be destroyed and spawn pressable ones.

  • hmm weird you example doesn't seem to work with the touch but

    I think I see where your going I will try to use this to implement into my game

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)