Android Question full screen sprite gaming animation

peacemaker

Expert
Licensed User
Hi, All

Who tried to make 2D-games :) please, suggest.
My fishing game uses the full screen sprites: rod with the line are made by the designer as single pictures, that require full screen :-(

And controlling the rod by swipes over the line - is hard task, as needs always reload the fullscreen sprites of rods - line cannot be separated for smaller pictures.
And it's rather slow and hunging process even on modern phones with 1GB RAM and fast processor.

Sprites are pre-loaded into Bitmap array at Activity start. But i guess much time is used for transparent drawing when i do
B4X:
pnl.SetBackgroundImage(Sprite(ix))
If to comment this loading line - all works fast, sure.

Question - if to preload these fullscreen sprites into panels and just makes one visible - will it be faster ?
Or the same speed issue, as panel must be shown and made transparent ?
 

peacemaker

Expert
Licensed User
Picture is limited, sure
B4X:
Sprite(i).InitializeSample(File.DirAssets, "rod0_" & NumberFormat(i,2,0) & ".png", pnl.Width, pnl.Height)
 
Upvote 0

sorex

Expert
Licensed User
I would split it up like in the image.

load the top left section frames as 1 image once and just copy the right one to the canvas.

the rest remains the same.

smaller app, less memory usage and it will run faster aswell I guess.
 

Attachments

  • fishingline.png
    fishingline.png
    53.4 KB · Views: 126
Upvote 0

sorex

Expert
Licensed User
what about this (see image)

red is static
green variable and copied to canvas
blue static but moved to the right horizontal place based on the animation

it will cut down image sizes a lot on small bends but requires some tweaking.

not much more options I'm affraid. (besides drawing arcs/beziercurves yourself)
 

Attachments

  • fishingline2.png
    fishingline2.png
    53.6 KB · Views: 125
Upvote 0

peacemaker

Expert
Licensed User
Thanks, such way was known from the beginning...
I mean - for these current conditions - no way to animate full screen pictures fast ?
And if to think about tablets, that actually for good looking need even more picture resolutions...

Making visible panels is not the same that transparent drawing (loading alfa-PNG into background), correct ?

UPD:
BTW, SeePU utility (from next topic) shows that the processor is not a problem at all ! A bit more loaded than idle during animation.
Low memory - yes, it's usual situation, even without gaming - also does not look the issue.

So WHY SLOW working? Line panel swiping ? Often requests to re-load sprites ?
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
it's the loading that causes slowdown.

it's better to load them once and copy it to the canvas.

but I don't know if you can load them at once, that's why I suggested the split up to reduce memory usage.
 
Upvote 0

peacemaker

Expert
Licensed User
SOLVED :)
Cash lib is good, but manual pre-loading into bitmaps - it's almost the same (but cash lib working looks faster).
Main issue is (WAS !) .... do not draw a picture, if it (the same) is already drawn :)

Normal working now.

Soon will be published, online multiplayer ice fishing simulator, but will be with EN interface now.
 
Upvote 0

wonder

Expert
Licensed User
I was experiencing terrible performance problems in my game until I switched to libGDX.
This might look like a line taken form an infomercial, but it really works great!

Give it a try for you next project! ;)
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
keep in mind that it adds another 3Mb overhead to your project and I doubt it will gain anything at all in this case.
 
Upvote 0

Informatix

Expert
Licensed User
keep in mind that it adds another 3Mb overhead to your project and I doubt it will gain anything at all in this case.
Look at the size of most games today. 3 MB is a very small share of the final weight (and the JAR file can go under 2 MB as explained in the LibGDX thread). Music, sounds and graphics take a lot more space, especially when you want to support resolutions from 800x480 to 2560x1600 (the current range on the market). Anyway, you don't have the choice depending on your project: only libGDX can provide the needed performance.
 
Upvote 0

wonder

Expert
Licensed User
For a small project, if the apk file size is a concern, it might not be worth it.
However, using GDX is always the safest way to achieve optimal performance.

My first app was a handgun simulator. It works fine and utilizes nothing more than ImageView's to animate the pistol, which is a composite of high-res full screen images. Although it works well on most devices, I often receive "java.lang.OutOfMemoryError" reports on my Google Play Dashboard.
This might be due to the image size of the sprites in my app. I might be wrong be if I've coded it today, I would use GDX.

Nowadays, downloading 3 megabytes is nothing but 1 extra second over wifi or 10 seconds over 3G.
In my humble opinion we should always aim for the best performance. :)
 
Upvote 0
Top