Presentation is loading. Please wait.

Presentation is loading. Please wait.

方向及加速感測器 靜宜大學資管系 楊子青.

Similar presentations


Presentation on theme: "方向及加速感測器 靜宜大學資管系 楊子青."— Presentation transcript:

1 方向及加速感測器 靜宜大學資管系 楊子青

2 1. OrientationSensor (方向感測器)
兩個最常用的屬性 Angle (傾斜角度) indicates the direction in which the phone is tilted (in degrees). Magnitude (傾斜量) indicates the amount of tilt, ranging from 0 (no tilt) to 1 (maximum tilt) Multiplying the Magnitude by 100 tells the ladybug that it should move between 0 and 100 pixels in the specified Heading (direction) whenever its TimerInterval

3 專案:Sensor (傾斜手機,讓球滾動) 介面設計

4 程式碼 (需打包成apk檔,安裝至手機測試)

5 2. AccelerometerSensor (加速感測器)
又稱重力感測器(G-Sensor) 可以提供速度和位移的資訊 zAccel: Equal to -9.8 (地球重力加速度為9.8m∕sec2) XAccel>0 XAccel<0 45 90 135 180 225 270 315 yAccel<0 yAccel>0

6 經驗法則(以下為Java程式碼) if (Math.abs(x) + Math.abs(y) + Math.abs(z) > 32) { txv.setText("手機搖晃"); } if (Math.abs(x)<1 && Math.abs(y)<1 && z<-9) { txv.setText("朝下平放再轉回");

7 加入Label2及AccelerometerSensor1元件 撰寫以下程式碼 ( Sensor專案)


Download ppt "方向及加速感測器 靜宜大學資管系 楊子青."

Similar presentations


Ads by Google