Hello all,
I am in what I would like to call the final stages of developing my first application for the android market, the game is a casual evolution type game, using the accelerometer for controls. as you move around and eat edibles, and avoid predators, you grow. the growth is displayed as a series of different sprites that are both progressively larger and more detailed… The issue I am having is swapping the user sprites in and out of memory in such a way that the user will not notice the lag…
My current idea of how to do this is to use an asynctask to dispose of the older unecessary sprite and load in the new one while the user is making there way to the next growth stage, which will take them at least 30 seconds… But I am having some issues implementing this… I have pasted in the code of my most recent attempts. I continue to get a log of “java.lang.RuntimeException: Only one Looper may be created per thread”
Thank you for your help
@Override
public boolean loadStuff(int size) {
Looper.prepare();
SampleTask st = new SampleTask();
st.game = this;
st.size = size;
st.execute(size);
return false;
}
private class SampleTask extends AsyncTask{
public Game game;
public int size;
@Override
protected Object doInBackground(Object... arg0) {
long start = System.currentTimeMillis();
//switch on size to determine which images to use
//when the user grows dispose of the old image and load in the next one in the background
Graphics g = game.getGraphics();
switch(size){
case 1:
Assets.jellyFish0.dispose();
Assets.jellyFish0 = g.newPixmap("stage4.png", PixmapFormat.ARGB4444,.45f);
break;
}
return true;
}
}