With great honour, I'm pleased to announce my most recent weekend project: GMExtensions!
What is is?
GMExtensions allows you to integrate Java (and through NDK, C/++) into your Game Maker Studio: Android applications and games!
How does it work?
Adding additional functions to Game Maker is tricky to say the least. Most functions are contained within a compile shared object (libyoyo.so) which can't easily be edited. Luckily for us, some of them aren't! The functions I take advantage of is get_string, which I chose because of its ability to receive two string parameters and return a string. By slightly modifying its actions, I can bootstrap a class loader that allows you to receive and return values to Game Maker.
Can I see an example?
Sure! Scan this QR code or click the link on your phone to download a simple test app. Requires Android and Arm7 support (most modern phones).
How do I install it in Game Maker?
As of now, installing it requires a little bit of editing.
- Editing the runner
You will need to modify a file that Game Maker compiles to allow this to work.
First, open up Notepad (or Wordpad, or your favourite Java/text editor)
File > Open and type
%appdata%\GameMaker-Studio\Android\runner\src\com\yoyogames\runner\RunnerJNILib.javaNow, make the following changes:
Add the bottom of the imports:
//import GMExtensions import gmc.GMExtensions;Inside the class:
public static final String extKey = "GME_";Spoiler
Scroll down (or CTRL-F to InputString). Inside the method:
//Only interpret commands with a valid key if (_default.startsWith(extKey)) return GMExtensions.interpret(_message, _default);Spoiler
- Adding the classes
Now that you have edited the runner, you must add the classes.
Download GMExtensions and the test class, toastTest.
Open up start and enter:
%appdata%\GameMaker-Studio\Android\runner\src\Extract the file and place the folder in \src\. Verify it is correct by insuring \src\gmc\GMExtensions.java exists. Done!
- Interfacing from GMS
Now, GME can be called through the get_string command. However, I do not recommend this! Instead, download my example gmz and use the scripts inside! Use the file > create executable command to run.
Unfortunately, this system isn't bulletproof. Aside from the crashes that you will cause if you pass the wrong string, there are several minor problems.
The most major one is that it only works when you do a full compile of the apk. This means that to test it, you must compile the entire executable. There is nothing I can do about this. Hopefully this wont be the case when 1.3 extensions come out.
Additionally, I threw this all together without prior experience with the Reflect API. I also did not code a lot of failsafing so don't be surprised if it crashes. If you are experienced in Java and would like to improve the code, go ahead by all means. Oh, and please help create extensions. />/>
(All the download links in case you missed them in the text)
Note to Staff: