Android drawing method is slow

Greetings to all! I am trying to convert from C # XNA 4.0 to Java, Android dev to Java. Firstly, I must say that Microsoft really did a great job developing games for its mobile platform. It is a pity that about twenty people around the world really own one of the Win Mob 7 phones. * ...
XNA development is very easy to understand and everything is done for you. But I wanted to get my apps for people, not just Bill's friends or those who have these few WM phones ...

And then the pranks came ... I can’t even do ONE! Raster image with satisfactory speed. I read this book:

(www.apress.com/9781430230427) Starting Android Games by Mario Zechner

Therefore, I thought that it would not be so bad - actually draw. But, ... I tried different drawing styles ... one from the book (representing the Screen class for RenderView), then the method from this tutorial http://www.edu4java.com/androidgame/androidgame3.html , and then the easiest http : //mikeyhogarth.wordpress.com/2010/10/09/how-to-develop-pong-for-android/ pong with primitives.

I cannot understand why even drawing primitives and moving 3 primitive objects can be so slow.

I tried to move 1! bitmap (from the edu4java tutorial) and it couldn’t be constantly moving . Even if I applied the sleep () method to suspend Thread and renedering at 10 (or 20 (or 30)) FPS, it was still terrible. I tried it in the emulator (much worse than in Microsoft), as well as in the real device (Wildfire S)

Good, good, Wildfire S is not the fastest Android ever, but has drawn ONE! A bitmap cannot be such a hardcore.

And I know that I have to have a new Thread for drawing, I have to do it through SurfaceView, draw on Canvas, etc.

I could not find anything around the firewalls that helped me. I hope this may be the easiest answer, and I would look like the most beautiful noob in the history of the Internet, but I will endure it ...

Is there anyone who knows what to do better?

(I do not use OpenGL EP, since I am only interested in simple 2D games (for now))

Thanks even for reading.

Erhan

+4
source share
1 answer

This can help in performance. If you are building at a high level API, you should be able to enable hardware acceleration in your manifest. Its easy to use and should make things smoother. The trick is to turn it on when you need it and turn it off when nothing happens. http://android-developers.blogspot.com/2011/03/android-30-hardware-acceleration.html

+3
source

Source: https://habr.com/ru/post/1389657/


All Articles