有没有人有过使用涉及 java 文件和 .xml 清单的 java 扩展将游戏制作工作室移植到 android 的经验?版本- Game Maker: Studio,还要注意制作扩展涉及3种不同的代码,Java、XML和GML(基本上是html和visual basic的组合)
我有一个我正在为 Android 制作的考勤卡应用程序,你可以打卡、打卡、休息,并将该信息记录到应用程序工作目录中的文本文件中。我的问题是,如何在 Game Maker: Studio 中打开 notepad.exe(或等效程序)以向用户显示文本?
我在我的扩展程序中设置了我的名为 sheldo 的 java 文件,我将其命名为 supopntxtf,在它的属性页面中,我只选择了 android,在函数属性页面上,我将名称和外部名称都设置为 shell_do,返回类型设置为双精度,我已将参数 0 和参数 1 列为字符串。这是我放在 Sheldo.java 文件中的代码:
package ${YYAndroidPackageName};
import android.content.Intent;
import android.net.Uri;
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 sheldo extends Activity {
public void shell_do(String arg0, String arg1) {
if (arg0 == "open") {
Intent intent = new Intent(Intent.ACTION_EDIT);
Uri uri = Uri.parse(arg1);
intent.setDataAndType(uri, "text/plain");
startActivity(intent);
}
}
}
并将xml代码添加到android清单(右键单击我的扩展名并转到android选项卡)这是我输入的代码:
<activity
android:label="@string/app_name"
android:name="${YYAndroidPackageName}" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
以及我添加到它的权限:
android.permission.INTERNET
android.permission.BIND_CARRIER_SERVICE
android.permission.BIND_APP_WIDGET
android.permission.READ_EXTERNAL_STORAGE
android.permission.WRITE_EXTERNAL_STORAGE
好的,现在在游戏中(现在我们回到 GML 代码语言)我有一个名为指针的对象,在它的创建事件中我已经声明了这些相关变量:
result1="open";result2="No records";result3="No records";
在对象指针的警报事件中,我有这个代码来激活我的扩展:
result1="open";
result2=string_insert(string(global.fname[global.empnum]),string(" "),0);
result2=string_insert(string(result2),string(global.finfo[0]),0);
result2=string_insert(string(result2),string(" Week "),0);
result2=string_insert(string(result2),string(global.fiscalw),0);
result2=string_insert(string(result2),string(" "),0);
result2=string_insert(string(result2),string(global.yrs),0);
result2=string_insert(string(result2),string(".txt"),0);// result2 to this point builds the file name.txt
result3=string_insert("file:///",working_directory,0;
result3=string_insert(result3,string("+"),0);
result2=string_insert(string(result3),string(result2),0);// this puts the file path together
shell_do(result1,result2); // this calls the extension
Explanation of the variables that I used to name the file with their values being all strings:
global.fname[global.empnum] - employee name depending on the employee number
global.finfo[0] - the company name
global.fiscalw - the week
global.fiscalyr - the year
我编译了我的游戏(因为手册告诉我扩展程序不会工作,除非游戏完成编译),没有问题,但是当我尝试使用扩展程序时没有任何反应,但是通过运行日志回顾我得到这个错误每次我尝试使用扩展程序时都会发送消息:
尝试在 Sheldo 上调用方法 shell_do 时抛出异常
我在你的管子上观看了一些有用的视频,以了解有关 java 与 xml 结合的更多信息: https ://www.youtube.com/watch?v=AGzaFOpVuqs&index=13&list=PLRz47KuVF6Uos2m6ZQ5J7v9xNA-LN8m7L
https://www.youtube.com/watch?v=tv2iClQ3G3s&list=PLRz47KuVF6Uos2m6ZQ5J7v9xNA-LN8m7L&index=14 并下载了Android Studio并让它很容易工作,但我想在游戏制造商:工作室完成这个项目,因为我付出了很多花钱买它,也不想重写整个应用程序,因为它是完全不同的语言哈哈,但我想我一定在某个地方做错了什么,有什么想法吗?