• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to not load removed object?  RSS feed

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my game there are players and an enemy. If the player shoots an enemy, that enemy dies. Easy. If I want to save that individual enemy's dead or alive state and load it, how would I go about doing that? For example:

In my XML level file, there are three different enemies, like so:
<entity x="400" y="400" type="enemy"/>
<entity x="600" y="200" type="enemy"/>
<entity x="700" y="900" type="enemy"/>
If the player shoots the enemy that originated at 400, 400, or any other coordinate and that enemy dies I want to save that to sharedPreferences either in an array of enemies or as a boolean, and when the game is loaded, I want the dead enemy to stay dead and not be loaded. I could easily make an enemy1, enemy2, enemy3... object and have individual booleans for them, but there has to be a way to save and load for multiple objects of the same entity, if that makes any sense. (The enemy at 400, 400 the enemy at 600, 200 etc...)

How would I go about doing this?
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!