forked from qt-creator/qt-creator
Doc: update Accelbubble example
The app could not recover from receiving a NaN value from the Accelerometer, so NaN values are ignored. Change-Id: Ia33d800f7fe080e07dcf327c26b3772e994793bf Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -79,6 +79,9 @@ ApplicationWindow {
|
|||||||
var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * 0.1)
|
var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * 0.1)
|
||||||
var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * 0.1)
|
var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * 0.1)
|
||||||
|
|
||||||
|
if (isNaN(newX) || isNaN(newY))
|
||||||
|
return;
|
||||||
|
|
||||||
if (newX < 0)
|
if (newX < 0)
|
||||||
newX = 0
|
newX = 0
|
||||||
|
|
||||||
|
@@ -196,6 +196,9 @@
|
|||||||
\skipto onReadingChanged
|
\skipto onReadingChanged
|
||||||
\printuntil }
|
\printuntil }
|
||||||
|
|
||||||
|
We want to ensure that the position of the bubble is always within
|
||||||
|
the bounds of the screen. If the Accelerometer returns not a number
|
||||||
|
(NaN), the value is ignored and the bubble position is not updated.
|
||||||
\li Add SmoothedAnimation behavior on the \a x and \a y properties of
|
\li Add SmoothedAnimation behavior on the \a x and \a y properties of
|
||||||
the bubble to make its movement look smoother.
|
the bubble to make its movement look smoother.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user