14.06.2011

states Management

posted by Karsten

public synchronized void restoreState(Bundle savedState) { synchronized (mSurfaceHolder) { setState(STATE_PAUSE); setScore(savedState.getLong("score")); mBallX = savedState.getFloat("mIconX"); mBallY = savedState.getFloat("mIconY"); mBallDX = savedState.getFloat("mIconDX"); mBallDY = savedState.getFloat("mIconDY"); Integer gameMode = savedState.getInt("gameMode"); if (gameMode == GameThread.STATE_LOSE | gameMode == GameThread.STATE_WIN) { setState(gameMode); } } } public Bundle saveState(Bundle map) { synchronized (mSurfaceHolder) { if (map != null) { map.putLong("score", score); map.putInt("gameMode", mMode); map.putFloat("mIconX", mBallX); map.putFloat("mIconY", mBallY); map.putFloat("mIconDX", mBallDX); map.putFloat("mIconDY", mBallDY); } } return map; }

Share

Place your comment

Please fill your data and comment below.
Name
Email
Website
Your comment