Saving an interface instance into a Bundle
Posted
by
user22241
on Game Development
See other posts from Game Development
or by user22241
Published on 2013-06-25T18:42:16Z
Indexed on
2013/06/25
22:30 UTC
Read the original article
Hit count: 299
All
I've have an interface that allows me to switch between different scenes in my Android game. When the home key is pressed, I am saving all of my states (score, sprite positions etc) into a Bundle. When re-launching, I am restoring all my states and all is OK - however, I can't figure out how to save my 'Scene', thus when I return, it always starts at the default screen which is the 'Main Menu'.
How would I go about saving my 'Scene' (into a Bundle)?
Code
import android.view.MotionEvent;
public interface Scene{
void render();
void updateLogic();
boolean onTouchEvent(MotionEvent event);
}
I assume the interface is the relevant piece of code which is why I've posted that snippet.
I set my scene like so: ('options' is an object of my Options class which extends MainMenu (Another custom class) which, in turn implements the interface 'Scene')
SceneManager.getInstance().setCurrentScene(options); //Current scene is optionscreen
© Game Development or respective owner