08.11.2012 Views

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ty_real,2,ty_real,ty_real);<br />

global.ddd =<br />

external_define('MyDLL.DLL','DoubleString',dll_cdecl,<br />

ty_string,1,ty_string);<br />

}<br />

Now whenever you need to call the functions, you use the following function:<br />

external_call(id,arg1,arg2,...) Calls the external function <strong>with</strong> the<br />

given id, and the given arguments. You need to provide the correct number of<br />

arguments of the correct type (real or string). The function returns the result<br />

of the external function.<br />

So, for example, you would write:<br />

{<br />

}<br />

aaa = external_call(global.mmm,x,y);<br />

sss = external_call(global.ddd,'Hello');<br />

If you don't need to use the DLL anymore you had better free it.<br />

external_free(dll) Frees the DLL <strong>with</strong> the given name. This is in<br />

particular necessary if the game should remove the DLL. As long as the DLL is<br />

not freed it cannot be removed. Best do this e.g. in an end of game event.<br />

You might wonder how to make a function in a DLL that does something in the game. For<br />

example, you might want to create a DLL that adds instances of objects to your game. The<br />

easiest way is to let your DLL function return a string that contains a piece of GML code. This<br />

string that contains the piece of GML can be executed using the GML function<br />

execute_string(str,arg0,arg1,...) Execute the piece of code in the<br />

string str <strong>with</strong> the indicated arguments.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!