Detecting if an online game

Does anyone happen to know how (if I’m in a java class), I can detect whether this is currently an “online game” (i.e. multiplayer, more than one computer, live)?

Try GameModule.getGameModule().getServer().isConnected().

ty!

Okay, now a “related question”.

What’s the soundest way to detect if an actual game is currently loaded? In other words, that we are neither sitting in the Editor before ever selecting “New Game”, nor are we after “Close Game” (but before any new reload).

What the code would be for “boolean GameModule.isGameActive()”.

All for my “Chess Clocks” class…

You can track the game start/ends directly.

Implement GameComponent in your Chess Clock class and in the addTo() override, call

GameModule.getGameModule().getGameState().addGameComponent(this);

You will then need to implement setup(gameStarting) which is called each time a game starts or shuts down.

Ah! Okay I actually already have that. So I see that “gameStarting” being true certainly lets me know when a game begins.

But are you saying that setup will also be called (w/ gameStarting false) when “Close Game” is picked from the file menu?

And is it called when the module first initialized (but game not yet started), e.g. if I start the thing in the Editor but haven’t launched/loaded a game yet?

Brian

Yes and No.

Alternatively, you can check GameModule.getGameModule(),getGameState().isGameStarted()