構文 | sensor.setdevOrient(Pow) |
説明 | 傾斜センサの起動と終了を設定します。 |
引数 | Pow: 0:終了, 1:起動 センサを起動させないと値が取得できません。 |
戻り値 | なし |
------------------------------------------
-- 傾斜センサの起動と終了を設定するサンプル setdevOrient_sample.lua
------------------------------------------
function main()
local w,h = canvas.getviewSize()
local xx, yy = 0, 50
canvas.drawCls(color(255,255,255))
canvas.drawText("傾斜センサの起動と終了を設定するサンプル", 0, 0, 24, color(0,0,0))
canvas.drawText("画面の右下の四角枠内のタッチで終了します。", 0, 30, 24, color( 0, 0, 0))
canvas.drawRect( w-100, h-100, w-2, h-2, color( 0, 0, 0))
sensor.setdevOrient(1)
while not ((xx >= w-100 and xx <= w-2) and (yy >= h-100 and yy <= h-2)) do
xx, yy,mode = touch(0)
d, p, r = sensor.getOrient()
canvas.drawText("方位(北の方向)をDegreeで取得 = " .. d .. " ", 0, 80, 24, color(0,0,0), color(255,255,255))
canvas.drawText("画面長編方向の傾斜成分を取得 = " .. p .. " ", 0, 110, 24, color(0,0,0), color(255,255,255))
canvas.drawText("画面短辺方向の傾斜成分を取得 = " .. r .. " ", 0, 140, 24, color(0,0,0), color(255,255,255))
end
sensor.setdevOrient(0)
end
main()