The game file to import and load for this session is 5961_10_03.stencyl
.
always
event: +Add Event | Basics | When Updating and rename it to Swipe Control
.Allow Gestures
.With just a few, minor modifications, we have converted our AcceloSoccer
test game to a SwipoSoccer
test game!
Because we do not need the accelerometer event, we disabled it. We could have deleted it entirely, but we might want to use it again at a later date.
With the unrequired event disabled, we then created a new Swipe Control
event which always reacts to the swipe gestures for each of the four detectable swipe directions. Windows developers also added a when created
event called Allow Gestures
, which contains the Enable gestures
block.
The
Enable gestures
block is not required according to the current Stencyl documentation. However, it was found that when developing on the Windows platform, the swipe events were not being detected on Android devices unless this block was implemented. This anomaly may be accounted for by the nature of the beta software that was being used during the production of this book, and may be resolved in upcoming updates to Stencyl.
Rather than controlling the soccer ball with gravity, which is controlled by the accelerometer feedback, we are now controlling the ball by swiping the screen in the required direction.
These are the only instruction blocks required to react and respond to touchscreen gestures!
Note that, in addition to the swipe …
instruction blocks that we have used in our test game, there is also a when the device is swiped …
event, which provides the same results but offers a different way to structure the events in our behaviors. The when the device is swiped …
event can be found by selecting + Add Event | Input | Swipe.
18.118.24.106