v0.9.4: game now periodically clears texture cache when changing scenes

This commit is contained in:
Evan Debenham 2021-07-11 16:09:24 -04:00
parent 020d14011f
commit ac790b1ece
6 changed files with 49 additions and 15 deletions

View File

@ -81,6 +81,10 @@ public class AlchemyScene extends PixelScene {
private static final int BTN_SIZE = 28;
{
inGameScene = true;
}
@Override
public void create() {
super.create();

View File

@ -46,6 +46,10 @@ public class AmuletScene extends PixelScene {
private Image amulet;
{
inGameScene = true;
}
@Override
public void create() {
super.create();

View File

@ -172,6 +172,10 @@ public class GameScene extends PixelScene {
private ActionIndicator action;
private ResumeIndicator resume;
{
inGameScene = true;
}
@Override
public void create() {

View File

@ -90,6 +90,12 @@ public class InterlevelScene extends PixelScene {
private static Exception error = null;
private float waitingTime;
public static int lastRegion = -1;
{
inGameScene = true;
}
@Override
public void create() {
super.create();
@ -136,11 +142,19 @@ public class InterlevelScene extends PixelScene {
scrollSpeed = returnDepth > Dungeon.depth ? 15 : -15;
break;
}
if (loadingDepth <= 5) loadingAsset = Assets.Interfaces.LOADING_SEWERS;
else if (loadingDepth <= 10) loadingAsset = Assets.Interfaces.LOADING_PRISON;
else if (loadingDepth <= 15) loadingAsset = Assets.Interfaces.LOADING_CAVES;
else if (loadingDepth <= 20) loadingAsset = Assets.Interfaces.LOADING_CITY;
else if (loadingDepth <= 25) loadingAsset = Assets.Interfaces.LOADING_HALLS;
//flush the texture cache whenever moving between regions, helps reduce memory load
int region = (int)Math.ceil(loadingDepth / 5f);
if (region != lastRegion){
TextureCache.clear();
lastRegion = region;
}
if (lastRegion == 1) loadingAsset = Assets.Interfaces.LOADING_SEWERS;
else if (lastRegion == 2) loadingAsset = Assets.Interfaces.LOADING_PRISON;
else if (lastRegion == 3) loadingAsset = Assets.Interfaces.LOADING_CAVES;
else if (lastRegion == 4) loadingAsset = Assets.Interfaces.LOADING_CITY;
else if (lastRegion == 5) loadingAsset = Assets.Interfaces.LOADING_HALLS;
else loadingAsset = Assets.Interfaces.SHADOW;
//slow down transition when displaying an install prompt

View File

@ -27,6 +27,10 @@ import com.watabou.noosa.Game;
public class IntroScene extends PixelScene {
{
inGameScene = true;
}
@Override
public void create() {
super.create();

View File

@ -67,6 +67,8 @@ public class PixelScene extends Scene {
//stylized 3x5 bitmapped pixel font. Only latin characters supported.
public static BitmapText.Font pixelFont;
protected boolean inGameScene = false;
@Override
public void create() {
@ -74,6 +76,12 @@ public class PixelScene extends Scene {
GameScene.scene = null;
//flush the texture cache whenever moving from ingame to menu, helps reduce memory load
if (!inGameScene && InterlevelScene.lastRegion != -1){
InterlevelScene.lastRegion = -1;
TextureCache.clear();
}
float minWidth, minHeight;
if (landscape()) {
minWidth = MIN_WIDTH_L;
@ -100,16 +108,12 @@ public class PixelScene extends Scene {
uiCamera = Camera.createFullscreen( uiZoom );
Camera.add( uiCamera );
if (pixelFont == null) {
// 3x5 (6)
pixelFont = Font.colorMarked(
TextureCache.get( Assets.Fonts.PIXELFONT), 0x00000000, BitmapText.Font.LATIN_FULL );
pixelFont.baseLine = 6;
pixelFont.tracking = -1;
}
//set up the texture size which rendered text will use for any new glyphs.
int renderedTextPageSize;
if (defaultZoom <= 3){