Time for action – experimenting with the accelerometer
The game file to import and load for this session is 5961_10_01.stencyl
.
Before we attempt to use the accelerometer in a practical test game, let's carry out an experiment to learn how Stencyl accesses the accelerometer information on a mobile device.
Note
The mobile device must have a built-in accelerometer in order for the following instructions to work.
Attach the mobile device to the development computer using the supplied USB cable.
Continue to use the blank game created in either of the sections, Time for action – testing on an Android device, or Time for action – testing on an iOS device. Alternatively, import the specified download file for this session.
Open Test Scene and select the Events button at the upper-center of the screen.
Select + Add Event | Basics | When Drawing.
In the new when drawing event, add the instruction blocks shown as follows, noting that the … of accelerometer block can be found in the instruction block palette...