"Open source Java Game Framework libgdx topic" -05-Module description and context

Source: Internet
Author: User
Tags libgdx

    1. Module description (Modules overview)
    • Input: Provides a unified input model and handler for all platforms.
Get Touch Example:
1  if (Gdx.input.isTouched ()) {2    SYSTEM.OUT.PRINTLN ("Input occurred at x=" +gdx.input.getx () + ", y=" +3 }
      • Graphics: Ability to draw pictures on the screen using OpenGL ES provided by hardware
Get OpenGL API 2.0 implementation, if the hardware does not support OpenGL ES 2.0 will return null
1 GL20 gl =Gdx.graphics.getGL20 (); 2 Gl.glclearcolor (1f, 0.0f, 0.0f, 1); 3 gl.glclear (gl20.gl_color_buffer_bit);

      • Files: File access on all platforms provides a convenient way to read and write.
To create an example of a texture from file $app_dir/assets/textures:
1 Texture mytexture =newtexture (Gdx.files.internal ("assets/texture/brick.png"));
      • Audio: Play and record sound on all platforms
Example of playing sounds:
1 Music Music =gdx.audio.newmusic (Gdx.files.getFileHandle ("Data/mymusicfile.mp3", filetype.internal)) ; 2 music.setvolume (0.5f); 3 Music.play (); 4 music.setlooping (true);
      • Networking: Provides a way to perform network operations.
      • Basic Game Frame
    1. Acquisition of the application environment (context)
      1. Get Application Type
 1  switch   (Gdx.app.getType ()) { 2  case  android://  Android specific Codebreak;  3  case  desktop://  desktop specific codebreak;  4  case  WebGl: //  HTML5 specific codebreak;  5  default : //  Other platforms specific code  6 } 
If it is an Android app, you can also get the version:
1 int androidversion =gdx.app.getversion ();
      1. Memory consumption situation
Here are two ways to get Java and local memory availability
1 long javaheap =Gdx.app.getJavaHeap (); 2 Long nativeheap =gdx.app.getnativeheap ();
The original is written by Bo Master Le Zhi Editor, the copyright belongs to the Bo owner. The original address http://www.dtblog.cn/1126.html reprint please specify the source!

"Open source Java Game Framework libgdx topic" -05-Module description and context

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.