The applications framework

View: 1087    Dowload: 0   Comment: 0   Post by: daii   Category: Mobile applications   Fields: Game - Entertainment

17 point/5 review File has been tested

Modules

At its core, libgdx consists of six interfaces that provide means to interact with the operating system. Each back-end implements these interfaces.

  • Application: runs the application and informs an API client about application level events, such as window resizing. Provides logging facilities and querying methods, e.g., memory usage.
  • Files: exposes the underlying file system(s) of the platform. Provides an abstraction over different types of file locations on top of a custom file handle system (which does not inter-operate with Java's File class).
  • Input: informs the API client of user input such as mouse, keyboard, touch or accelerometer events. Both polling and event driven processing are supported.
  • Net*: provides means to access resources via HTTP/HTTPS in a cross-platform way, as well as create TCP server and client sockets.
  • Audio: provides means to playback sound effects and streaming music as well as directly accessing audio devices for PCM audio input/output.
  • Graphics: exposes OpenGL ES 2.0 (where available) and allows querying/setting video modes and similar things.

Starter Classes

The only platform specific code that needs to be written, are so called starter classes. For each platform that is targeted, a piece of code will instantiate a concrete implementation of the Application interface, provided by the back-end for the platform. For the desktop this might look something like this, using the Lwjgl back-end:

public class DesktopStarter {
   public static void main(String[] argv) {
      LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
      new LwjglApplication(new MyGame(), config);
   }
}

For Android, the corresponding starter class might look like this:

public class AndroidStarter extends AndroidApplication {
   public void onCreate(Bundle bundle) {
      super.onCreate(bundle);
      AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
      initialize(new MyGame(), config);
   }
}

These two classes usually live in separate projects, e.g., a desktop and an Android project. TheProject Setup, Running & Debugging page describes the layout of these projects for Eclipse.

The actual code of the application is located in a class that implements the ApplicationListenerinterface (MyGame in the above example). An instance of this class is passed to the respective initialization methods of each back-end's Application implementation (see above). The application will then call into the methods of the ApplicationListener at appropriate times (see The Life-Cycle).

See Starter Classes & Configuration for details on starter classes.

Accessing Modules

The modules described earlier can be accessed via static fields of the Gdx class. This is essentially a set of global variables that allows easy access to any module of libgdx. While generally viewed as very bad coding practice, we decided on using this mechanism to ease the pain usually associated with passing around references to things that are used often in all kinds of places within the code base.

To access, for example, the audio module one can simply write the following:

// creates a new AudioDevice to which 16-bit PCM samples can be written
AudioDevice audioDevice = Gdx.audio.newAudioDevice(44100, false);

Gdx.audio is a reference to the backend implementation that has been instantiated on application startup by the Application instance. Other modules are accessed in the same fashion, e.g., Gdx.appto get the Application, Gdx.files to access the Files implementation and so on.

The applications framework

The applications framework Posted on 09-11-2016  At its core, libgdx consists of six interfaces that provide means to interact with the operating system. Each back-end implements these interfaces. 3.4/10 1087

Comment:

To comment you must be logged in members.

Files with category

  • An Experience about Using Webview in Android Studio 3.0

    An Experience about Using Webview in Android Studio 3.0

    View: 10    Download: 0   Comment: 0

    Category: Android     Fields: Other

    I am blogging on ngocminhtran.com (using WordPress platform). Like most websites, I want to write an Android application to help viewers have a lot of great experiences with my blog.

  • Android - Simple Sending SMS

    Android - Simple Sending SMS

    View: 145    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    Learn on how to create a Simple Sending SMS using Android. This tutorial is only an example for sending an SMS, it does not contain the receiving message yet. Android is a mobile operating system developed by Google. It used in several gadget like...

  • Bomb Explode! (An Android App Strategy Game)

    Bomb Explode! (An Android App Strategy Game)

    View: 269    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This android app named Bomb Explode! is a capstone project that I made for a particular school. BOMB EXPLODE! is a Human Versus Computer strategy game. The objective is to eliminate the opponent by blowing up their BOMBS. Each player takes a turn by...

  • GIS App for Flood-Prone and Disease Affected Areas

    GIS App for Flood-Prone and Disease Affected Areas

    View: 294    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    GIS App for Flood-Prone and Disease Affected Areas is one of the capstone project that I have created in a particular school. Features of the application: - Geographic Map - GIS - Flood Prone Map - Urban Map - Search a particular area - Has SQLite...

  • NSO Demographic Application

    NSO Demographic Application

    View: 291    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This app is entitled NSO Demographic Application that was one of the capstone project/thesis project that I made for a particular school. This app features to provide a demographic survey of the National Statistics Office that will send to the...

  • HandEBook: An IT Portable Book Application

    HandEBook: An IT Portable Book Application

    View: 245    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This is an android mobile application entitled HandEBook: An IT Portable Book Application was one one of the capstone project that I have made in our clients at Cotabato. We used the Basic4Android software for the frontend and SQLite for the database...

  • Publishing The Game

    Publishing The Game

    View: 118    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    To build the game go to the file menu, then choose Build Setting. Drag all the scenes in the empty box and set the platform to android as shown below. After you're done click the Player Setting, then fill up the required information in order to build...

  • Simple Game in Android

    Simple Game in Android

    View: 158    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    The is simple game developed in eclipse compatible with all screen resolution using getwidth() and getheight() function -Highscore page added -Volume control page In this game the player collects the coins by jumping and makes score. More tips:...

 
File suggestion for you
File top downloads
Codetitle.net - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.net Develope by Vinagon .Ltd