v0.9.4: game now periodically clears texture cache when changing scenes
This commit is contained in:
parent
020d14011f
commit
ac790b1ece
|
@ -81,6 +81,10 @@ public class AlchemyScene extends PixelScene {
|
||||||
|
|
||||||
private static final int BTN_SIZE = 28;
|
private static final int BTN_SIZE = 28;
|
||||||
|
|
||||||
|
{
|
||||||
|
inGameScene = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
super.create();
|
super.create();
|
||||||
|
|
|
@ -46,6 +46,10 @@ public class AmuletScene extends PixelScene {
|
||||||
|
|
||||||
private Image amulet;
|
private Image amulet;
|
||||||
|
|
||||||
|
{
|
||||||
|
inGameScene = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
super.create();
|
super.create();
|
||||||
|
|
|
@ -172,6 +172,10 @@ public class GameScene extends PixelScene {
|
||||||
private ActionIndicator action;
|
private ActionIndicator action;
|
||||||
private ResumeIndicator resume;
|
private ResumeIndicator resume;
|
||||||
|
|
||||||
|
{
|
||||||
|
inGameScene = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,12 @@ public class InterlevelScene extends PixelScene {
|
||||||
private static Exception error = null;
|
private static Exception error = null;
|
||||||
private float waitingTime;
|
private float waitingTime;
|
||||||
|
|
||||||
|
public static int lastRegion = -1;
|
||||||
|
|
||||||
|
{
|
||||||
|
inGameScene = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
super.create();
|
super.create();
|
||||||
|
@ -136,11 +142,19 @@ public class InterlevelScene extends PixelScene {
|
||||||
scrollSpeed = returnDepth > Dungeon.depth ? 15 : -15;
|
scrollSpeed = returnDepth > Dungeon.depth ? 15 : -15;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (loadingDepth <= 5) loadingAsset = Assets.Interfaces.LOADING_SEWERS;
|
|
||||||
else if (loadingDepth <= 10) loadingAsset = Assets.Interfaces.LOADING_PRISON;
|
//flush the texture cache whenever moving between regions, helps reduce memory load
|
||||||
else if (loadingDepth <= 15) loadingAsset = Assets.Interfaces.LOADING_CAVES;
|
int region = (int)Math.ceil(loadingDepth / 5f);
|
||||||
else if (loadingDepth <= 20) loadingAsset = Assets.Interfaces.LOADING_CITY;
|
if (region != lastRegion){
|
||||||
else if (loadingDepth <= 25) loadingAsset = Assets.Interfaces.LOADING_HALLS;
|
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;
|
else loadingAsset = Assets.Interfaces.SHADOW;
|
||||||
|
|
||||||
//slow down transition when displaying an install prompt
|
//slow down transition when displaying an install prompt
|
||||||
|
|
|
@ -27,6 +27,10 @@ import com.watabou.noosa.Game;
|
||||||
|
|
||||||
public class IntroScene extends PixelScene {
|
public class IntroScene extends PixelScene {
|
||||||
|
|
||||||
|
{
|
||||||
|
inGameScene = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
super.create();
|
super.create();
|
||||||
|
|
|
@ -67,6 +67,8 @@ public class PixelScene extends Scene {
|
||||||
//stylized 3x5 bitmapped pixel font. Only latin characters supported.
|
//stylized 3x5 bitmapped pixel font. Only latin characters supported.
|
||||||
public static BitmapText.Font pixelFont;
|
public static BitmapText.Font pixelFont;
|
||||||
|
|
||||||
|
protected boolean inGameScene = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
|
|
||||||
|
@ -74,6 +76,12 @@ public class PixelScene extends Scene {
|
||||||
|
|
||||||
GameScene.scene = null;
|
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;
|
float minWidth, minHeight;
|
||||||
if (landscape()) {
|
if (landscape()) {
|
||||||
minWidth = MIN_WIDTH_L;
|
minWidth = MIN_WIDTH_L;
|
||||||
|
@ -100,16 +108,12 @@ public class PixelScene extends Scene {
|
||||||
uiCamera = Camera.createFullscreen( uiZoom );
|
uiCamera = Camera.createFullscreen( uiZoom );
|
||||||
Camera.add( uiCamera );
|
Camera.add( uiCamera );
|
||||||
|
|
||||||
if (pixelFont == null) {
|
|
||||||
|
|
||||||
// 3x5 (6)
|
// 3x5 (6)
|
||||||
pixelFont = Font.colorMarked(
|
pixelFont = Font.colorMarked(
|
||||||
TextureCache.get( Assets.Fonts.PIXELFONT), 0x00000000, BitmapText.Font.LATIN_FULL );
|
TextureCache.get( Assets.Fonts.PIXELFONT), 0x00000000, BitmapText.Font.LATIN_FULL );
|
||||||
pixelFont.baseLine = 6;
|
pixelFont.baseLine = 6;
|
||||||
pixelFont.tracking = -1;
|
pixelFont.tracking = -1;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//set up the texture size which rendered text will use for any new glyphs.
|
//set up the texture size which rendered text will use for any new glyphs.
|
||||||
int renderedTextPageSize;
|
int renderedTextPageSize;
|
||||||
if (defaultZoom <= 3){
|
if (defaultZoom <= 3){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user