Sprites stretch or blowup when replacing scene on Android


#1

I’m having a weird problem that only seems to be happening when I run my game on Android (iOS works fine).

When the game starts, it runs with a scene which contains multiple sprites. The scene looks perfect at this point. Then later I replace the scene with a new instance of the same scene class, but uses different sprites. The new scene appears, but some of the sprites are stretched taller or blown up while some assets look correct.

If I switch the order of the scenes the same thing happens, the scene the game is started with looks great, but the scene I replace it with later has sprites which are stretched and blown up.

Does anyone have an idea of what could cause this?


#2

Nevermind I figured out my problem. I was calling code to change the scene from java, which is not on the opengl thread. I fixed it by queuing the call on the GLView’s thread.

Runnable changeScene = new Runnable() {
public void run() {
nativeLoadScene();
}
};
mGLView.queueEvent(changeScene);