简体   繁体   English

如何在 Game maker studio 上实现 Android Gyroscope?

[英]How to implement Android Gyroscope on Game maker studio?

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. Game maker Studio 可以选择使用 android 拥有的工具创建新的 GML 函数,这对我作为程序员来说非常有趣。 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:它使用“Android.permission ...”我不太确定哪些是添加陀螺仪所必需的,它还有一个Java文件来获取数据,Yoyo游戏有一个例子:

 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.然后他们在 GML 中创建函数以便在 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?我不精通 Android 或 Java,我想知道是否有人有线索并知道如何执行此操作? Thank you.谢谢你。

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

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文档链接: https : //docs.yoyogames.com/source/dadiospice/002_reference/mouse,%20keyboard%20and%20other%20controls/device%20input/device_get_tilt_x.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM