Java + GLBasic Global Variables

Previous topic - Next topic

Poetronic

Hi everyone,

is it possible by any chance to communicate directly between the SDLActivity.java and global variables in GLBasic? I would like to be able to change the Android Back Button's behavior based on the state of a global variable in the GLBasic app, or even better be able to change the variable inside the SLDActivity.java. Possible or not?

Thank you!
ILI-Blocks, my first game ever - please check it out! http://www.glbasic.com/forum/index.php?topic=8654.0

spacefractal

#1
no.

But howover you can do a javacall to change example a variable in a java array trought a java call. one to set that, and another one to get that. here was that im was doing to do, but did not update to the ANDROIDEXTRAS:

In Public static String glb_JAVACALL(String url):
Code (glbasic) Select

// --== IS MENU SHOWHING? ==--
if (tokens[0].equals("setMenuShow"))
{ doMenuShow=false;
if (tokens[1].equals("1") || tokens[1].equals("true") doMenuShow=true;
}


In the top, just under public class SDLActivity extends Activity or >>>>>>>> START OF ANDROID EXTRAS <<<<<<<< :

Code (glbasic) Select

private boolean doMenuShow = false;


Then in doKeydown() event, you could do something like this:

Code (glbasic) Select

if (keyCode == KeyEvent.KEYCODE_BACK)
{ if (event.isAltPressed()) { return false; } // prevent quit if circle is pressed on Xperia Play
if (doMenuShow==false) { return false; } // prevent back button to work
}


This is just giving you ideas.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Poetronic

Hi,

I copied the code from fivesprites and inserted the rest at the specified locations, but now I am getting a fatal error:

Code (glbasic) Select
gpc_temp0.o:gpc_temp0.cpp:(.text+0x7e06): undefined reference to `_android_JAVACALL'

Seems like the function is ignored by the compiler?
ILI-Blocks, my first game ever - please check it out! http://www.glbasic.com/forum/index.php?topic=8654.0

Poetronic

#3
Ok, don't bother, working now.   :)

EDIT: Haha, ok - I got it all working, but the point is that on my 2.2.2 Phone the return false on Keypress Back Button doesn't make any difference at all.
ILI-Blocks, my first game ever - please check it out! http://www.glbasic.com/forum/index.php?topic=8654.0

spacefractal

It's might been a bug on the phone with wrong implement. but if it's does on the v4 device, you should write the part of the code.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/