How do I Draw and Recognize Shapes?

Get help using Construct 2

Post » Sat Feb 20, 2016 4:52 pm

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
B
9
S
2
Posts: 9
Reputation: 545

Post » Sat Feb 20, 2016 5:43 pm

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.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Sat Feb 20, 2016 7:10 pm

Search the forum for gesture recognition. There are a few examples and even a plugin.
search.php?st=0&sk=t&sd=d&sr=posts&keywords=gesture+recognition
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests