jPCT-AE - a 3d engine for Android > Support

Pause, resume and restart

(1/3) > >>

AceGIS:
Hi Egon,

In your examples you have a function to copy a "master" activity if it does not exist and this is used to handle pause resume. I have extracted the renderer into a standalone class, therefore myActivityClass.this in your renderer does not work for me. Do you have another solution for handling pause and resume? Android activity and GLSurfaceView states are driving me crazy trying to work this out...

EgonOlsen:
That actually doesn't matter, the basic idea stays the same. Just split the renderer from the game (which my examples don't do for the sake of simplicity) and only save the game instance. In my RPG project, the Activity still contains the renderer as an internal class, but it has only one other instance variable, which is the root of the game's object tree. Only that one is saved and all that onDrameFrame does is to call game.draw().

However, i've still no idea if this kind of state management is a good way to do it. It's the way i do it and it works pretty well for me, but on the other hand, it looks somehow hacky and i bet that there are other solutions.

AceGIS:
Hi Egon,

I am still struggling with this. In my activity that contains the GLSurfaceView (and renderer) I have the snippet below;


--- Code: ---// Used to handle pause and resume...
static CameraViewActivity master = null;

if (getMaster() != null) { // I have created getter and setter
      copy(getMaster()); // copy method from helloworld example
}
--- End code ---

In my renderer class onSurfaceChanged I have the snippet below;

--- Code: ---if (CameraViewActivity.getMaster() == null)
// create textures, load models......

if (CameraViewActivity.getMaster() == null) {
Logger.log("Saving master Activity!");
CameraViewActivity.setMaster(CameraViewActivity.master);
}
--- End code ---

I just can't seem to work out what is going on here. DANG!! Any advice?

EgonOlsen:
I'm not sure what the actual problem is now... ???

AceGIS:
Sorry Egon,

Is the line "CameraViewActivity.setMaster(CameraViewActivity.master);" the correct way to do this. It compiles without error, but my app is still getting OOM. ??

Navigation

[0] Message Index

[#] Next page

Go to full version