Game Development Reference
In-Depth Information
strokeWidth(15)
lineCapMode(ROUND)
pushMatrix()
translate(WIDTH/2, HEIGHT/2)
grav = vec2(Gravity.x * 300, Gravity.y * 300)
line(0,0,grav.x, grav.y)
down = vec2(1,0)
orient = down:angleBetween(grav)
pushMatrix()
resetMatrix()
translate(WIDTH/2, HEIGHT/2)
translate(grav.x, grav.y)
rotate(math.deg(orient))
line(0,0,-25,-20)
line(0,0,-25,20)
popMatrix()
popMatrix()
end
The preceding code is from the Codea sample project; it measures the tilt of the device. As shown in
Figure 12-5 , the code draws an arrow that demonstrates the tilt of the device.
Search WWH ::




Custom Search