• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

HTML5 Do Tilt functions works on HTML5/InstantGames

makas

Member
As the title says I have a game on android and tilt functions works pretty well but, I can't make them work on html5, did html5/instant games works with tilt functions ?
 

makas

Member
I check it out is there any way to implement this on gamemaker? those functions looks like they are native to html5, but how do I bring those to gamemaker? sorry if this a very noobie question
 

chmod777

Member
You'll need an extension.
Code:
var g_tiltInit = false;
var g_tiltAlpha = 0;
var g_tiltBeta = 0;
var g_tiltGamma = 0;

function tilt_init() { // call this once on gamestart
   if(g_tiltInit) return;
   window.addEventListener("deviceorientation", function(event) {
       g_tiltAlpha = e.alpha;
       g_tiltBeta = e.beta;
       g_tiltGamma = e.gamma;
   });
   g_tiltInit = true;
}

function tilt_x() {
   return g_tiltBeta;
}

function tilt_y() {
   return g_tiltGamma;
}

function tilt_z() {
   return g_tiltAlpha;
}
Something like that... However, the values will not match those returned by the native device_get_tilt_* functions on Android and would need some additional stuff. But this should be possible.
 
Top