aspose file tools*
The moose likes Game Development and the fly likes LibGDX Android question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "LibGDX Android question" Watch "LibGDX Android question" New topic
Author

LibGDX Android question

Christopher McKay
Ranch Hand

Joined: Oct 19, 2013
Posts: 50

I have been using the LibGDX java game library and have created an application for both desktop (windows) and android devices. The only problem is that I would like to add buttons to the android version for movement (since android devices don't have external keyboards) but that would also affect the desktop version (which I do not want any buttons on). Help would be appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42291
    
  64
Why would changes to the Android version affect the desktop version? Surely there are many differences between both versions that are handled somehow by the build process; why couldn't it handle this difference as well?


Ping & DNS - my free Android networking tools app
Christopher McKay
Ranch Hand

Joined: Oct 19, 2013
Posts: 50

Ulf Dittmer wrote:Why would changes to the Android version affect the desktop version? Surely there are many differences between both versions that are handled somehow by the build process; why couldn't it handle this difference as well?

The reason the desktop version affects the Android version is that all the code is written in a source project and is then ported to android and desktop automatically by LibGDX. So my workspace looks like:

Game
Game-desktop
Game-android

I don't actually write in the Game-desktop or Game-android projects.
Christopher McKay
Ranch Hand

Joined: Oct 19, 2013
Posts: 50

Problem still hasn't been resolved. Any further help would be appreciated!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42291
    
  64
I know nothing about LibGDX, but it seems that any code generator that can create code for several platforms should have a mechanism for hooking up stuff for one particular platform. (At least, I don't think I'd want to use one that didn't have that capability.)
Christopher McKay
Ranch Hand

Joined: Oct 19, 2013
Posts: 50

Ulf Dittmer wrote:I know nothing about LibGDX, but it seems that any code generator that can create code for several platforms should have a mechanism for hooking up stuff for one particular platform. (At least, I don't think I'd want to use one that didn't have that capability.)

Ok, I'll look into it and post up what I find.
Keith Earl
Greenhorn

Joined: Mar 25, 2014
Posts: 11

Christopher McKay wrote:
Ulf Dittmer wrote:I know nothing about LibGDX, but it seems that any code generator that can create code for several platforms should have a mechanism for hooking up stuff for one particular platform. (At least, I don't think I'd want to use one that didn't have that capability.)

Ok, I'll look into it and post up what I find.


I know this thread is a bit dated and since I haven't seen any replies to it I figure I'd put my $0.02 in. I'm by no means any expert in java and in fact am just starting off learning it myself. Well I was dabbling with libgdx while studying java se (which java se should be learned first) and I remember running across something about Modules used and what you're asking about was with the Application Module which deals with Gdx.app. With that you can query the platform type and write platform-specific code where it's necessary to know the platform type. And example is

switch (Gdx.app.getType()) {
case Desktop:
// Code for Desktop application
break;
case Android:
// Code for Android application
break;
case WebGL:
// Code for WebGL application
break;
default:
// Unhandled (new?) platform application
break;
}


Again, I'm just starting off with java, but maybe you could add code where needed in order to change things JUST for android (for example) while leaving the desktop coding just the way it is?
Christopher McKay
Ranch Hand

Joined: Oct 19, 2013
Posts: 50

Keith Earl wrote:
Christopher McKay wrote:
Ulf Dittmer wrote:I know nothing about LibGDX, but it seems that any code generator that can create code for several platforms should have a mechanism for hooking up stuff for one particular platform. (At least, I don't think I'd want to use one that didn't have that capability.)

Ok, I'll look into it and post up what I find.


I know this thread is a bit dated and since I haven't seen any replies to it I figure I'd put my $0.02 in. I'm by no means any expert in java and in fact am just starting off learning it myself. Well I was dabbling with libgdx while studying java se (which java se should be learned first) and I remember running across something about Modules used and what you're asking about was with the Application Module which deals with Gdx.app. With that you can query the platform type and write platform-specific code where it's necessary to know the platform type. And example is

switch (Gdx.app.getType()) {
case Desktop:
// Code for Desktop application
break;
case Android:
// Code for Android application
break;
case WebGL:
// Code for WebGL application
break;
default:
// Unhandled (new?) platform application
break;
}


Again, I'm just starting off with java, but maybe you could add code where needed in order to change things JUST for android (for example) while leaving the desktop coding just the way it is?


Thanks Keith Earl, I didn't realize you could do this. My problem has been solved by you!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: LibGDX Android question