0 Favourites

How do I Draw and Recognize Shapes?

  • Hi all,

    Just a quick question. I have a prototype set up where you draw shapes on a touchscreen to cast spells in an endless runner. At this point, I have it set up so you can swipe in up, down, left, right to cast spells. Is there some way in C2 to recognize shapes drawn rather than just directional swipes?

    Thanks,

    cementtruckgames

  • You'll have to do some pretty advanced coding for that, but it is possible in my mind. I've thought of a similar system but have never actually created it.

    Rough idea -

    Create an array representing the width and height of your layout: more cells = higher resolution.

    As you swipe, record where your swipe passed through by toggling values in the array.

    Compare the array data with your accepted patterns to do actions <- This is the hard part.

    You'll have to have a certain leeway for your comparisons - after all, everyone draws a different shaped/sized circle. Also they might start in different places, or even put their circle in different places on the screen.

    To fudge it a bit I would actually check for a more specific pattern in the array, but have the user input cover more cells, and as long as the pattern is found anywhere in the array the action would fire.

    A second method would involve recording the maximum values your swipe coordinates reach and when they reach them - basically record corners/vertices in your drawing, and compare the locations of those with each other to match patterns. This is how swype-style text input on smartphone keyboards work.

    Either way is a pretty large task to undertake.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Search the forum for gesture recognition. There are a few examples and even a plugin.

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