Memory management in game development? - android

I'm new to android and i started to develop a game, I thought about memory management when loading images and using them for animations, I want to know how to manage it properly so it wont damage the game's smoothness, How could i proceed with this?. And while I'm asking about game development is it a good idea to start with a new framework for all the calculations,physics and graphics?

If you want to start gaming development on Android, I recommend you use a game framework built on top of OpenGL-es
Look into LibGdx, it s a great starting point, so you don't reinvent the wheel and get productive right away:
http://libgdx.badlogicgames.com/

When it comes to memory management in Android, the thing to keep in mind is that Java has automatic garbage collection. So, as long as you don't maintain a reference to images and animations after they're no longer needed, they will get garbage collected and removed from memory as needed.
The Android Developer docs contain much information related to memory management and performance: http://developer.android.com/training/best-performance.html
Another thing to keep in mind is that the complexity of your layouts has a dramatic effect on app performance. Try to keep your layouts as flat as reasonably possible. This is explained here: http://developer.android.com/training/improving-layouts/optimizing-layout.html

If you are new you definitely shouldnt start off by making your own framework bro, its just way too ambitious.
Go for OpenGL or a library like that as the other answer said for a game with 3D graphics, or even no graphics framework if its a very simple game that doesnt need that. It really depends on the kind of game you have in mind.
Check this for memory management tips: https://www.youtube.com/watch?v=McAvq5SkeTk
What will matter the most though is optimizing the animations for smoothness, check this for tips on this and general guidelines for what you want: http://developer.android.com/guide/topics/graphics/overview.html

Personally, I enjoyed using Unity3D to develop mobile games. It will handle those types of memory issues for you.

Related

Unity how to improve your 3dDgame preformance for mobile devices?

I have build a pinball game in unity 3d for android and for some low mobile devices it is running slowly. I was thinking about hiring a unity expert to lighten up the code so it would run better on all devices.
But I wonder if this is possible. Can you make a game preform better by changing the code? I have to add this was my first unity project and it's very messy.
Thanks for helping
Absolutely, there are plenty of ways that changes to code could yield significant increases in performance, depending on how you're currently doing things.
One of them is object pooling when dealing with frequent creation/destruction of objects, another is caching component references when they are used often every frame. And if you're still using OnGui for your interface, probably avoid it in favour of the new (as of 4.6) GUI system. But you haven't included your code in your question, so I can't give a definite solution for optimizing your code.
Chances are though, not all of your code is problematic, just key scripts. My suggestion is to take a look at the Unity Profiler to determine which areas in your code are slowing down your game the most, then take steps to try reducing the execution time. You should also take into consideration non-code problems (eg. With lighting, geometry, materials, textures). Take a look at the guide Unity provides for ideas on how to address those
If you're still having problems, then you can bring that specific code to StackOverflow and see if it can be further improved. Hope this helps! Let me know if you have any questions.

Replacing Movie Clips with Sprites

Hey everyone so I'm relatively new to AS3, I had a question. I'm developing a Mobile Application for Android devices and all my objects that are on the stage and that are added to the stage are Movie Clips. After awhile I begin to notice a drop in FPS. I know that this is due to me not using the devices GPU. Also I have read a lot about 3rd party programs that make use of the GPU and enhance the performance immensely such as the Starling framework. I've tried to implement that into my game and create the sprite sheets etc... But I just get error after error and i understand I'm not as advanced in AS3 to truly grasp how to use it. So I was wondering if replacing the movie clips with sprites would enhance the performance? Or is that even possible. I know that Sprites are capable of working like move clips via able to add tweens etc... But will this enhance the performance of the game? Or am i pretty much screwed unless I learn how to use the starling framework?
Any help would be appreciated thanks everyone.
Just how many MovieClips do you think are bogging you down? What are those errors? I would not put your faith in a framework to save you from poor programming. Better to do good programming first. Sprites vs. MovieClips are probably not the answer. Post some code and specifics, please.

canvas or OpenGL ES?

I am embarking on a project (game) and I have a question about the implementation, will be developed specifically for Android and want to know which is better (easier, faster to develop and portable). canvas or OpenGL ES
Unless you already have a good working knowledge of OpenGL, then using a Canvas will be easier and faster. In terms of portability it really isn't as clear cut.
That said you should probably consider using one the pre-existing game engines, if you really only about Android then you should check out http://www.andengine.org/ its a great engine with a strong community and lots of great little example games.
Actually I'm not really sure where I read this,but when it's about developing game if you have any knowledge of OpenGL, you better use that,because the system is separating more space for your application so it can run without lagging or crash.So you can't get an Memory Full error. (Please correct me if I'm wrong.)

How to start game programming without a graphic artist?

Having a hard time phrasing the question, my situation actually is on the release phase of the game development cycle.
I have this game that falls under the casual category with little to no-complex-logic involved at all, running on a 2D side scrolling (semi) single character. In short it really is simple, so I am already done with the code and just need to replace sprites with my own to avoid any copyright issues once I decide to release it on the market (truth is I used sprites from various forums of another side scrolling MMORPG).
So my actual problem is, being an independent developer, with no talent in graphic arts and little budget to outsource a graphic artist, How would I (a plain programmer) create a modern looking graphical game?
Note:
The game is non-profit, I made it just to learn what the android platform has to offer.
But seeing it can actually be fun for others to play with, I'd like to release it.
I wanted to make this a community wiki as I see other game programming beginners would also face the same question. Although I am not that sure if that reason alone qualifies. But it seems with my reputation now, I'd leave that to the admin / mods decisions.
Keep the resources seperate and replace them before releasing with free versions or your own art.
There is no cheap source of high quality (graphics) unless you find someone willing to work for you cheap or for free.
Be very careful with copying sprites from other games. Some publishers have (and keep) very strict policies.
Another forum/site that might give you more information is http://www.Gamedev.net
Especially interesting might be the resources found here
I don't know how it is on Android but whenever I've tried games for fun, I've always relied on free sprite sheets which are all over the net. I've also clipped off a few from old DOS games which I run via. dosbox.
My favorite tactic is to put ugly placeholder graphics inside the game, and brag with it to my fellow pixel-movers. Next, someone from the pool will be disgusted with my lack of taste and ability to do good graphics, and put himself into the game.
If it doesn't work, you can always go headhunting, having your game ready and with just graphics to replace.
I stayed on the same problem, like you did.
Me as programmer also wanted to start coding a little android game, because i never did before.
And my garphic/artist skill is like 3-year-old-child...
So i tried to think of a designconcept with very easy geometrical Forms, if you are not so skilled.
And with the open source Software gimp you can do alot.
I dont know which engine you use, but i decided for unity3d, cause you are very flexible and you also can cross compile your project. I dont had experience with c#, but its very easy if you came from other oop languages, like java, so maybe have look for it. :)
Maybe also look what i made of it, it were just some circles and lines!
https://play.google.com/store/apps/details?id=de.duckdev.anbr
greets

Tips for lightweight Android Applications

I am starting to develop Android applications and I would like to know if there are any tips for creating lightweight applications. This is my first attempt to write applications on a mobile platform but I hope that my experience in programming will help.
I have in mind the "Better, Faster, Lighter Java" book, but will this be "the" answer to my question? Are there any tips specific for the Android Platform that will allow me to build lightweight applications?
A good place to start would be the Designing for Performance and Designing for Responsiveness documents in the Android Developer Documentation.
Realize that you are coding for a platform with limited memory, so try not to allocate memory unless you absolutely have to. The last thing you want is for the garbage collector to kick in and start eating CPU cycles. Also, quite often "performance" is synonymous with "user experience" so if you have to do anything CPU intensive, do it in the background and out of the UI thread.
Here is some additional information that you might find useful:
Turbo Charge Your UI
Coding for Battery Life

Categories

Resources