Development of plug-ins for sensor games

Source: Internet
Author: User

Hope you can use it more and improve game development efficiency!

First:

Download sensorsimulator. sensorsimulator is an open-source and free sensor tool that allows you to debug sensor applications in the simulator.

Decompress the downloaded sensorsimulator to the c root directory.
Install sensorsimulatorsettings.apk to the simulator. Select Start> run in the operating system to enter the run dialog box, as shown in figure 14-2. Then input the scripts in the "run" dialog box and navigate to the sensorsimulatorsettings.apk directory through the CD command. Then, enter the following command to install the APK to the simulator. Note that when installing the APK, make sure that the simulator is running, as shown in Figure 14-3.

  • 1 ADB install sensorsimulatorsettings.apk
Figure 14-2 run dialog box
(Click to view the larger picture) Figure 14-3 install APK to the simulator

Create an android project named sample_14_1.
Build the interface and use the following code to replace the original code in Main. xml.

    1<? XML
    Version = "1.0"
    Encoding = "UTF-8"?>
    <! -- Declare the XML version and encoding format -->

<Linearlayout
Xmlns: Android = "http: // schemas.
Android.com/apk/res/android"
Androidrientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
<! -- Add a vertical linear layout -->
<Textview
Android: Id = "@ + ID/Title"
Android: gravity = "center_horizontal"
Android: textsize = "20px"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/Title"/>
<! -- Add a textview control -->
<Textview
Android: Id = "@ + ID/mytextview1"
Android: textsize = "18px"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/mytextview1"/>
<! -- Add a textview control -->
<Textview
Android: Id = "@ + ID/mytextview2"
Android: textsize = "18px"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/mytextview2"/>
<! -- Add a textview control -->
<Textview
Android: Id = "@ + ID/mytextview3"
Android: textsize = "18px"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/mytextview3"/>
<! -- Add a textview control -->
</Linearlayout>
Note: first define a vertical linear layout, and then add four textviews to the linear layout in sequence, and specify the ID, set the text size, and set the mode of the textview.
In eclipse, add a jar package for the project so that it can use the classes and methods of the sensorsimulator tool. The method for adding a jar package is as follows.
Find the project folder in the package explorer of Eclipse, right-click the folder, and select the "roperties" option. The window shown in figure 14-4 is displayed.
Select the "Java build path" option on the left and click the "Libraries" tab.
Click "add external jars" to add the required jar package.
In the displayed "jar selection" dialog box, select the sensorsimulator-1.0.0-beta1 under the C:/sensorsimulator-lib.jar/lib directory and add it to the project.

 

(Click to view the larger image) Figure 14-4 Properties window

 

Second:

Run sensorsimulator. jar in the bin directory, run the sensorsimulatorsettings application that has just been installed in the simulator, and set the IP address to the local IP address.

Use the default port.
After configuring the IP address, click Connect under testing to connect.
Final: Success! In this step, we can run our own gravity sensing demo. At the same time, by controlling the cell phone on the left side of the window in sensorsimulator. jar, we can simulate gravity sensing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.