Using swipes
If you use a mobile device, such as a phone or tablet, it's a safe bet to use swipe controls in a game or an app; popular games such as Fruit Ninja have been designed entirely around this type of a touchscreen input. Swipe controls are intuitive for certain onscreen actions (such as slicing a fruit), so the game just feels right; it's satisfying. Let's take a moment to cook up some satisfying controls.
Getting ready
We'll create a simple demo to showcase the swipe movement. To do this, you'll need a simple room and two objects. The first object should be called obj_target
and requires a sprite; I chose a simple green box. The second should be called obj_control_swipe
and requires no sprite. Based on the name, I'm sure you can guess what this second object does.
How to do it…
In
obj_target
, add a Create event to a code block containing the following code:x = room_width/2; y = room_height/2;
Add a Step event to the code block where you'll enter this code:
if (x < 0) or (x > room_width...