开发传感器游戏很好的插件的安装

希望大家多多使用,提高游戏开发效率!

首先:

下载SensorSimulator,SensorSimulator是一个开源免费的传感器小工具,通过该工具便可以在模拟器中调试传感器的应用,读可从http://code.google.com/p/openintents/wiki/SensorSimulator网站找到该工具的下载链接。

将下载好的SensorSimulator解压到C盘根目录。
向模拟器安装SensorSimulatorSettings.apk。首先在操作系统中依次选择"开始"|"运行"进入"运行"对话框,如图14-2所示。然后在"运行"对话框输入cmd进入cmd命令行,之后通过cd命令将当前目录导航到SensorSimulatorSettings.apk目录下,然后输入下列命令向模拟器安装该apk。需要注意的是,安装apk时,一定要保证模拟器正在运行才可以,如图14-3所示。


  • 1   adb install SensorSimulatorSettings.apk
图14-2  运行对话框
(点击查看大图)图14-3  安装apk到模拟器

创建一个名为Sample_14_1的Android项目。
搭建界面,用下列代码替代main.xml中的原有代码。



  • 1    <?xml
    version= "1.0"
    encoding= "utf-8" ?>
    <!-- 声明xml的版本及编码格式 -->

<LinearLayout
xmlns:android="http://schemas.
android.com/apk/res/android"

androidrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- 添加一个垂直的线性布局 -->
<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"/>
<!-- 添加一个TextView控件 -->
<TextView
android:id="@+id/myTextView1"
android:textSize="18px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/myTextView1"/>
<!-- 添加一个TextView控件 -->
<TextView
android:id="@+id/myTextView2"
android:textSize="18px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/myTextView2"/>
<!-- 添加一个TextView控件 -->
<TextView
android:id="@+id/myTextView3"
android:textSize="18px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/myTextView3"/>
<!-- 添加一个TextView控件 -->
</LinearLayout>
说明:首先定义一个垂直的线性布局,然后依次向线性布局中添加四个TextView,并分别为其指定ID、设置文字大小及对其方式等。
在Eclipse中为该项目添加JAR包,使其能够使用SensorSimulator工具的类和方法,添加方法如下。
在Eclipse的Package Explorer中找到该项目的文件夹,然后右键单击该文件夹并选择"roperties"选项,弹出如图14-4所示的窗口。
选择左面的"Java Build Path"选项,然后单击"Libraries"选项卡。
单击"Add External JARs"按钮来添加需要的JAR包。
在弹出的"JAR Selection"对话框中选择C:/sensorsimulator-1.0.0-beta1/lib目录下的sensorsimulator-lib.jar,并将其添加到该项目中。

 

(点击查看大图)图14-4  Properties窗口

 

其次:

运行bin目录下sensorsimulator.jar,再运行模拟器中刚刚安装好的SensorSimulatorSettings应用,配置IP为本机IP。如图:

  端口是用默认的就好。
  配置好IP后,点击Testing下的connect进行连接.
 最后:大功告成!到了这一步就可以运行我们自己写的关于重力感应的DEMO了。同时,通过对sensorsimulator.jar中窗口左侧的手机的控制就可以实现模拟重力感应的效果了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值