Hey, I'm currently developing a game, and I need to know the best way to reference its sprites for drawing. Right now I have a pretty simple runnable thread that starts after the application starts, so it doesn't hang, and loads up every drawable to a variable. Like so;
new Thread(new Runnable() { public void run() { Resources res = mContext.getResources(); BackgroundImage = res.getDrawable (R.drawable.clouds2); mBackgroundRays = res.getDrawable (R.drawable.lightrays); mBackgroundLoaded = true; mMenuBunz = res.getDrawable(R.drawable.menu); mMenuLoaded = true; mGameLayout = res.getDrawable (R.drawable.game); mFoods[0] = res.getDrawable(R.drawable.bunbot); mFoods[1] = res.getDrawable(R.drawable.patty); mFoods[2] = res.getDrawable(R.drawable.pattybad); mFoods[3] = res.getDrawable(R.drawable.gold); mFoods[4] = res.getDrawable(R.drawable.bacon); mFoods[5] = res.getDrawable(R.drawable.baconbad); mFoods[6] = res.getDrawable(R.drawable.cheese); mFoods[7] = res.getDrawable(R.drawable.cheesebad); mFoods[8] = res.getDrawable(R.drawable.onions); mFoods[9] = res.getDrawable(R.drawable.onionsbad); mFoods[10] = res.getDrawable(R.drawable.tomatoes); mFoods[11] = res.getDrawable(R.drawable.tomatoesbad); mFoods[12] = res.getDrawable(R.drawable.lettuce); mFoods[13] = res.getDrawable(R.drawable.lettucebad); mFoods[14] = res.getDrawable(R.drawable.buntop); mFoods[15] = res.getDrawable(R.drawable.life); mFallingFood[0] = new Food(); mFallingFood[1] = new Food(); mFallingFood[2] = new Food(); mFallingFood[3] = new Food(); mFallingFood[4] = new Food(); mFallingFoods = FOOD_MAX_FALLING; mGameLoaded = true; mMenuScores = res.getDrawable(R.drawable.highscore); mScoresLoaded = true; mMenuHelp = res.getDrawable(R.drawable.help); mHelpLoaded = true; mResLoaded = true; } }).start(); That's about 700kb worth of images loaded, but its loading times on the phone are random. Sometime the images take 5 seconds to load and at other times they can take up to 20 seconds. Can someone please tell me how to properly load up my sprites? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---