I'm building a game a pokemon like rpg game in iOS using Swift. I'm currently in the process of making graphics and is in the dilemma of either just using a health bar blank and dynamically changing the length of a health bar or should I instead use intervals (100percent.png, 90percent.png) to represent damage? Which way is more appropriate to conserve memory and is more efficient?


Generally, I wouldn't think the efficiency of drawing your health bar would be a bottleneck in your game. If it is, you should figure out why by profiling your code and seeing where the slowdown is.

Having said that, you could just make it a rectangle that you fill in and then it takes no texture memory. It may not look as cool, but if you're concerned about the amount of memory you're using, it's very efficient. It also allows you to make the health any value between the minimum and maximum, so you aren't constrained to just 10% intervals.

If you still want to use textures, you could also look into compressed textures. I'm not sure whether or not iOS supports them and if so which types of compression, but if you're concerned about size, that may be a reasonable option.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.