Languages

Menu
Sites
Language
How to move an object via Gyro as it's made in GWD?

How to move an object via Gyro as it's made in GWD?

I'm struggling to handle window.addEventListener('devicemotion') , but I can't get it how to apply this data for object moving. Gear S3 Tizen 2.3.2

 

window.addEventListener('devicemotion', function(e) {

ax = e.accelerationIncludingGravity.x;
ay = -e.accelerationIncludingGravity.y;
az = -e.accelerationIncludingGravity.z;
rotx = e.rotationRate.alpha;
roty = e.rotationRate.beta;
rotz = e.rotationRate.gamma;

object_gyro.style.left = ??? + "px";
object_gyro.style.right = ??? + "px";
object_gyro.style.top = ??? + "px";
object_gyro.style.bottom = ??? + "px";
});

#object-gyro{
z-index:1;
width: 100px;
height: 100px;
background-color: black;
position: absolute;
margin: auto;
left: 0;
right:0;
bottom:0;
top:0;
}
Edited by: Anonymous on 03 May, 2019

Responses

1 Replies
Yasin Ali

Hi,

You may follow this tip tutorial for implementation details

https://developer.tizen.org/ko/community/tip-tech/keeping-high-portability-your-tizen-web-applications?langredirect=1

 Hope it will work.

If you find my post is helpful for you, please mark it as the Best Answer to promote this post to others.