简体   繁体   中英

Android - Can I use LibGdx for game screen only?

I have developed a game in android but now I want to make the gameplay or game screen in LibGdx as I am familiar with it. So, can I make game screen in LibGdx and use splash, login, setting screen etc. which are made in android ? If Yes, Then how can I do so?

Let me answer your question again. You don't have to use core or desktop folders. You can code everything for Android folder with Ads, Play Services, etc. if you wish.

Let me describe how you do it.

  1. Create a class that extends AndroidApplication this is your MainActivity class where everything starts.You add a game view and ad view to this class game view class extends Game class on create() method of AndroidApplication class.

     protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); // create view that contains game View viewGame = initializeForView(new MyGame(this), config); // create ads setUpAds(); layoutMain = new RelativeLayout(this); // add game view layoutMain.addView(viewGame, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); setContentView(layoutMain); 

    }

  2. You set a class that extends ScreenAdapter insde create() method of your MyGame class. and send instance of MyGame class to screen classes as parameter to change screen using Game instance and everything inside classes like Splash, Game, Setting or anything else is coded in Java(Android) and you can easily change screens using game.setScreen((new MainMenuScreen(game))); That's all the logic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM