Summary of problems and solutions encountered when using the libgdx engine in android game development

Source: Internet
Author: User
Tags libgdx
The problem of changing the image to a white square after drawing tilemaprenderer

The problem is that tilemaprenderer has enabled a new batch, but the batch enabled in the previous scenario has not been closed, which leads to an error. Therefore, you only need to restart the batch of the scenario after creating the map:

If (_ tilemaprenderer! = NULL ){

_ Tilemaprenderer. Render (_ orthographiccamera );

// Restart the batch. Otherwise, the subsequent items will become white blocks.

Batch. End ();

Batch. Begin ();

}

 

Com. badlogic. GDX. utils. gdxruntimeexception: Error reading file Error

04-03 11:52:16. 214: E/androidruntime (13760): Fatal exception: glthread 28833
04-03 11:52:16. 214: E/androidruntime (13760): COM. badlogic. GDX. utils. gdxruntimeexception: Error reading file: font \ CN. fnt (internal)
04-03 11:52:16. 214: E/androidruntime (13760): At com. badlogic. GDX. backends. Android. androidfilehandle. Read (androidfilehandle. Java: 66)
04-03 11:52:16. 214: E/androidruntime (13760): At com. badlogic. GDX. Graphics. g2d. bitmapfont $ bitmapfontdata. <init> (bitmapfont. Java: 89)
04-03 11:52:16. 214: E/androidruntime (13760): At com. badlogic. GDX. Graphics. g2d. bitmapfont. <init> (bitmapfont. Java: 287)
04-03 11:52:16. 214: E/androidruntime (13760): At com. badlogic. GDX. Graphics. g2d. bitmapfont. <init> (bitmapfont. Java: 279)
04-03 11:52:16. 214: E/androidruntime (13760): At com. skyd. libgdxtest. Game. Create (game. Java: 44)
04-03 11:52:16. 214: E/androidruntime (13760): At com. badlogic. GDX. backends. Android. androidgraphics. onsurfacechanged (androidgraphics. Java: 275)
04-03 11:52:16. 214: E/androidruntime (13760): at Android. OpenGL. glsurfaceview $ glthread. guardedrun (glsurfaceview. Java: 1455)
04-03 11:52:16. 214: E/androidruntime (13760): at Android. OpenGL. glsurfaceview $ glthread. Run (glsurfaceview. Java: 1216)
04-03 11:52:16. 214: E/androidruntime (13760): caused by: Java. Io. filenotfoundexception: font \ CN. fnt
04-03 11:52:16. 214: E/androidruntime (13760): at Android. content. res. assetmanager. openasset (native method)
04-03 11:52:16. 214: E/androidruntime (13760): at Android. content. res. assetmanager. Open (assetmanager. Java: 315)
04-03 11:52:16. 214: E/androidruntime (13760): at Android. content. res. assetmanager. Open (assetmanager. Java: 289)
04-03 11:52:16. 214: E/androidruntime (13760): At com. badlogic. GDX. backends. Android. androidfilehandle. Read (androidfilehandle. Java: 64)
04-03 11:52:16. 214: E/androidruntime (13760):... 7 more

This error is caused by a path problem. The slash in "font \ CN. fnt" identifies a problem in Android and uses "/" to indicate a directory.

That is

Bitmapfont = new bitmapfont (GDX. Files. Internal ("Font/CN. fnt"), GDX. Files. Internal ("Font/cn.png"), false );

 

Misplacement of Action animation display

In libgdx, if multiple actors are drawn on one batch and each of them has an action animation, some of the actors pass the batch when drawing. if the setprojectionmatrix method changes the matrix, the animation may be disordered. Currently, I do not know the cause of this problem, but it can be solved through a work und.

That is, to create a new scenario and draw some special objects in the new scenario, there is no problem if you do not share the batch.

 

The orientation of the Y-axis motion of the particle animation generated using the particle editor particle-editor is reversed.

You can only do it in the editor, so you can get it right in the game.

 

The problem that a translucent color cannot be implemented when shaperender is called to draw a geometric image

Run the following command before drawing:

GDX. gl. glable (gl10.gl _ blend );

GDX. gl. glblendfunc (gl10.gl _ src_alpha, gl10.gl _ one_minus_src_alpha );

 

Image do not support anti-aliasing during image stretching

 

Make settings similar to the following for its texture:

 
Region. gettexture (). setfilter (texturefilter. Linear, texturefilter. Linear );
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.