Use of the android game development framework libgdx (I)-Environment setup

Source: Internet
Author: User
Tags clear screen libgdx

The libgdx used in this article is version 0.92, which may be different from the latest version. The full text is for reference only.

Libgdx is a game library that supports 2D and 3D Game Development. It is compatible with most microcomputer platforms (Standard javase implementation and can run on Mac, Linux, windows, and other systems) it can be used with the Android platform (android1.5 or above, and android2.1 or above can be used at full power ).

Logo:

Address: http://code.google.com/p/libgdx/

First download the latest jar, I downloaded the libgdx-0.9.2.

Create an android project, File> New> Project> Android project. The sdk I selected is 1.6, and the minimum option is 1.5.

Create a new folder libs (the name is fixed and cannot be changed at will), copy the downloaded jar into, Android platform only need to copy GDX. jar and gdx-backend-android.jar.

Add references, and then copy the armeabi and armeabi-v7a folders to the libs folder.

Then write a small item to test whether the environment is correct.

The new class hellogameactivity inherits the androidapplication class.

Package COM. cnblogs. htynkn; import COM. badlogic. GDX. backends. android. androidapplication; import android. OS. bundle; public class hellogameactivity extends androidapplication {@ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); initialize (New firstgame (), false );}}

 

 
Initialize (New firstgame (), false );

It is the key to starting the game. firstgame is a class that implements applicationlistener.

CodeAs follows:

Package COM. cnblogs. htynkn; import COM. badlogic. GDX. applicationlistener; import COM. badlogic. GDX. GDX; import COM. badlogic. GDX. graphics. gl10; import COM. badlogic. GDX. graphics. g2d. spritebatch; public class firstgame implements applicationlistener {// spritebatch private spritebatch batch for plotting; @ override public void create () {batch = new spritebatch (); // instantiate} @ override public void dispose () {// todo auto-generated method stub} @ override public void pause () {// todo auto-generated method stub} @ override public void render () {GDX. GL. glclear (gl10.gl _ color_buffer_bit); // clear screen batch. begin (); batch. end () ;}@ override public void resize (INT width, int height) {// todo auto-generated method stub} @ override public void resume () {// todo auto-generated method stub }}

Because no actual content is written, the effect is a black box.

The next article is about image rendering.

Note:

If you carefully observe logcat, you will find an error:

E/libegl (382): Couldn't load <libhgl. So> Library (cannot load Library: load_library [984]: Library 'libgl. so' not found)

It doesn't matter. This is because the system fails to load the hardware OpenGL driver and returns to the software processing method, not a defect or error.

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.