1

Game maker Studio has the option to create new GML functions using the tools that android has, it is something very interesting for me as a programmer. I was wondering how to implement the gyroscope sensor. It uses "Android.permission ..." I'm not quite sure which ones are necessary for adding the Gyroscope, also it has a Java file where they get the data, Yoyo games have an example:

package ${YYAndroidPackageName};

import android.util.Log;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.String;

import ${YYAndroidPackageName}.R;
import com.yoyogames.runner.RunnerJNILib;


public class GenericTest
{

private static final int EVENT_OTHER_SOCIAL = 70;

  public void ReturnAsync(double arg0, double arg1)
 {   
   int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
   RunnerJNILib.DsMapAddString( dsMapIndex, "type", "finished" );
   RunnerJNILib.DsMapAddDouble( dsMapIndex, "argument0", arg0);
   RunnerJNILib.DsMapAddDouble( dsMapIndex, "argument1", arg1);
   RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
   
  }

     public double AddTwoNumbers(double arg0, double arg1)
 {
         double value = arg0 + arg1;
         Log.i("yoyo", arg0 + "+" + arg1 + " = " + value);

         return value;
     }


     public String BuildAString(String arg0, String arg1)
 {
         String myString = arg0 + " " + arg1;
         Log.i("yoyo", myString);

         return myString;
     }


     public String HowManyObjects(double arg0, double arg1, String arg2)
 {
         double value = arg0 + arg1;
         Log.i("yoyo", arg0 + "+" + arg1 + " = " + value);

  String myString = String.valueOf(value) + " " + arg2;
  Log.i("yoyo", myString);

         return myString;
     }

} // End of class

And then they create the functions in GML in order to be used on Game maker.

I'm not proficient in Android or Java, I would like to know if someone has a clue and knows how to do this? Thank you.

Yoyogame's post: http://help.yoyogames.com/hc/en-us/articles/216755248-Creating-A-Native-Extension-For-Android-GMS-v1-3-

1 Answers1

1

I think what you are looking for is

device_get_tilt_x()

and

device_get_tilt_y()

These functions automaticly acces your phones gyroscope. Links to documentation: https://docs.yoyogames.com/source/dadiospice/002_reference/mouse,%20keyboard%20and%20other%20controls/device%20input/device_get_tilt_x.html

LF00
  • 27,015
  • 29
  • 156
  • 295