public void Game_Finished(int level) { game_finished = true; this.level = level; if (simulation.game_won()) { prefs.putInteger("Level_26_Game", 2); if (prefs.getInteger("Level_10_Game", 0) == 2) { } else { prefs.putInteger("Level_10_Game", 1); } if (prefs.getInteger("Level_21_Game", 0) == 2) { } else { prefs.putInteger("Level_21_Game", 1); } if (prefs.getInteger("Level_27_Game", 0) == 2) { } else { prefs.putInteger("Level_27_Game", 1); } if (prefs.getInteger("Level_31_Game", 0) == 2) { } else { prefs.putInteger("Level_31_Game", 1); } prefs.flush(); } }
@Override public void preDraw(float delta) { super.preDraw(delta); if (!isInitialised) { Gdx.app.log(TAG, "Loading Prefs"); isInitialised = true; ArtTag.gameSettings = new GameSettings(); final Preferences prefs = Gdx.app.getPreferences("ArtTreacheryPrefs"); ArtTag.gameSettings.screenWidth = prefs.getInteger("screenWidth", 1280); ArtTag.gameSettings.screenHeight = prefs.getInteger("screenHeight", 1024); ArtTag.gameSettings.fullscreen = prefs.getBoolean("fullscreen", false); ArtTag.gameSettings.blur = prefs.getInteger("blur", 1); ArtTag.gameSettings.rays = prefs.getInteger("rays", 64); ArtTag.gameSettings.handleResAuto = prefs.getBoolean("handleResAuto", true); Gdx.app.log(TAG, "Saving Prefs"); prefs.putInteger("screenWidth", ArtTag.gameSettings.screenWidth); prefs.putInteger("screenHeight", ArtTag.gameSettings.screenHeight); prefs.putBoolean("fullscreen", ArtTag.gameSettings.fullscreen); prefs.putInteger("blur", ArtTag.gameSettings.blur); prefs.putInteger("rays", ArtTag.gameSettings.rays); prefs.putBoolean("handleResAuto", ArtTag.gameSettings.handleResAuto); prefs.flush(); if (Gdx.graphics.supportsDisplayModeChange() && ArtTag.gameSettings.handleResAuto == false) { Gdx.app.log(TAG, "Trying to set Displaymode"); Gdx.graphics.setDisplayMode( ArtTag.gameSettings.screenWidth, ArtTag.gameSettings.screenHeight, ArtTag.gameSettings.fullscreen); // Gdx.gl.glViewport(0, 0, ArtTag.gameSettings.screenWidth, // ArtTag.gameSettings.screenHeight); } } Assets.assetsManager.update(); if (!isStarted && MathUtils.isEqual(1f, Assets.assetsManager.getProgress())) { // done loading eh Assets.instance.onFinishLoading(); startGame(); isStarted = true; // final TextButton startButton = new TextButton("Start", Assets.instance.skin); // startButton.addListener(new InputListener() { // // @Override // public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { // startGame(); // return super.touchDown(event, x, y, pointer, button); // } // }); } }
public final void updateFontsProperties(String language) { Preferences fontPrefs = Gdx.app.getPreferences(propertyName); // store screen width for detecting screen fontSize change // on later startups, which will require font regeneration fontPrefs.putString("tag", versionTag); fontPrefs.putInteger("display-width", Gdx.graphics.getWidth()); fontPrefs.putInteger("display-height", Gdx.graphics.getHeight()); fontPrefs.putString("lang", language); fontPrefs.flush(); }
public void setScore(int score) { scoreString.setScore(score); if (score > topScore) { topScore = score; preferences.putInteger(TOP_SCORE_PREF, topScore); preferences.flush(); topScoreString.setScore(score); } }
public void setSolitaireBest(final String table, int score) { for (TableInfo ti : this.tables) { if (ti.getName().equals(table)) { ti.setHighScore(score); } } Preferences p = Gdx.app.getPreferences(PREFS_NAME); p.putInteger(table, score); p.flush(); }
public void save() { prefs.putBoolean("sound", sound); prefs.putBoolean("music", music); prefs.putFloat("volSound", volSound); prefs.putFloat("volMusic", volMusic); prefs.putInteger("charSkin", charSkin); prefs.putBoolean("showFpsCounter", showFpsCounter); prefs.putBoolean("useMonochromeShader", useMonochromeShader); // сохраняем в файл prefs.flush(); }
public void saveState() { System.out.println("SAVE"); hasFlushed = false; int currentHighScore = prefs.getInteger("highscore"); prefs.clear(); for (int i = 0; i < grid.getBlocks().size; i++) { prefs.putFloat("x" + i, grid.getBlocks().get(i).getX()); prefs.putFloat("y" + i, grid.getBlocks().get(i).getY()); prefs.putFloat("val" + i, grid.getBlocks().get(i).getValue()); } prefs.putInteger("score", grid.getScore()); if (highScore >= currentHighScore) { prefs.putInteger("highscore", highScore); } else { prefs.putInteger("highscore", currentHighScore); } prefs.flush(); hasFlushed = true; }
public static void load() { texture = new Texture(Gdx.files.internal("data/texture.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); bg = new TextureRegion(texture, 0, 0, 136, 43); bg.flip(false, true); grass = new TextureRegion(texture, 0, 43, 143, 11); grass.flip(false, true); birdDown = new TextureRegion(texture, 136, 0, 17, 12); birdDown.flip(false, true); bird = new TextureRegion(texture, 153, 0, 17, 12); bird.flip(false, true); birdUp = new TextureRegion(texture, 170, 0, 17, 12); birdUp.flip(false, true); TextureRegion[] birds = {birdDown, bird, birdUp}; birdAnimation = new Animation(0.06f, birds); birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG); skullUp = new TextureRegion(texture, 192, 0, 24, 14); skullDown = new TextureRegion(skullUp); skullDown.flip(false, true); bar = new TextureRegion(texture, 136, 16, 22, 3); bar.flip(false, true); prefs = Gdx.app.getPreferences("ZombieBird"); if (!prefs.contains("highScore")) { prefs.putInteger("highScore", 0); } font = new BitmapFont(Gdx.files.internal("data/text.fnt")); shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt")); dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav")); flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav")); coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav")); }
@Override public void update(float dt) { if (!paused) { handleInput(); if (!readyToFadeWhite) player.update(dt); // So player can be controlled upward from Sky else { // Lift player whiteOverlay += .3f * dt; player.getVelocity().add(0, -player.gravity / 2); player.getVelocity().scl(dt); player.getPosition().add(player.movement * dt, player.getVelocity().y); player.getVelocity().scl(1 / dt); float temp = player.normalize( -450, 200, (float) -Math.PI / 4f, (float) Math.PI / 4f, player.getVelocity().y); player.rotation = 25 * (float) Math.sin(temp); if (whiteOverlay > 1f) { dispose(); Preferences p = Gdx.app.getPreferences(OwlCityTribute.GAME_PREFS); p.putInteger("level", 5); if (p.getInteger("maxlevel") < 5) { p.putInteger("maxlevel", 5); } p.flush(); gsm.currentState = GameStateManager.SKY; this.gsm.setState(new Sky(this.gsm)); } } fallen = player.getPosition().y == -OwlCityTribute.HEIGHT * .1f; if (!loss && fallen) { loss = true; gsm.push(new UponLoss(gsm)); } note.update(dt); noteAnim.update(dt); noteRotation += 100f * dt; if (noteRotation > 360) noteRotation = 0; balloonFluctuation.update(dt); cam.position.x = player.getPosition().x + player.xOffset; float leftEdge = player.getPosition().x - (cam.viewportWidth / 2) + player.xOffset; // Check if note is hit if (!shrinking && Math.sqrt( Math.pow( (player.getPosition().x + player.getPlane().getWidth() * .75f) - note.getPosition().x, 2) + Math.pow( (player.getPosition().y + (player.getPlane().getHeight() * .75f) / 2) - (note.getPosition().y + noteAnim.getFrame().getRegionHeight() / 2), 2)) < 40) { // Open textbox textCount++; textBox.prepare( sceneText.get(textCount).get(0), (sceneText.get(textCount).size() == 1) ? "" : sceneText.get(textCount).get(1), .1f); boxInitialized = true; // Set bounds int w = (int) font.getBounds(sceneText.get(textCount).get(0)).width; // int h = (int)(font.getBounds(sceneText.get(textCount).get(0)).height*2.5); int h = (int) (font.getBounds(sceneText.get(textCount).get(0)).height * sceneText.get(textCount).size() * 1.5); textBox.setBounds( w, h, (int) (OwlCityTribute.WIDTH * .65) - w / 2, (int) (OwlCityTribute.HEIGHT * .875) - h / 2); waiting = true; shrinking = true; } else if (note.getPosition().x < leftEdge - noteAnim.getFrame().getRegionWidth() && !waiting && textCount < sceneText.size() - 1 && player.movement > player.maxMovement * .75) { note.getPosition().x = player.getPosition().x + cam.viewportWidth; note.setyOffset((int) (Math.random() * 100) + 200); } if (shrinking) { noteScale -= 2.5 * dt; if (noteScale < 0) { shrinking = false; noteScale = 1f; note.getPosition().x -= cam.viewportWidth; } } if (textBox.readyToUpdate) { if (!textBox.update(dt)) waiting = true; else { waiting = false; if (textCount < sceneText.size() - 1 && player.movement > player.maxMovement * .75) { note.getPosition().x = player.getPosition().x + cam.viewportWidth; note.setyOffset((int) (Math.random() * 100) + 200); } } } if (!fallen && boxInitialized && textCount == sceneText.size() - 1 && textBox.finished) { readyToFadeWhite = true; } // clouds for (int i = 0; i < clouds.size; i++) { clouds.get(i).update(dt); if (clouds.get(i).getPosition().x < leftEdge - cloud.getWidth()) { int index = (i == 0) ? clouds.size - 1 : i - 1; clouds.get(i).getPosition().x = (float) (clouds.get(index).getPosition().x + cam.viewportWidth * .8); clouds.get(i).yOffset = random.nextInt((int) (OwlCityTribute.HEIGHT * .1f)) + (int) (OwlCityTribute.HEIGHT * .75f); } } // if(readyToFadeBlack){ // whiteValue = (whiteValue > 0) ? whiteValue - .2f*dt : 0f; // if(whiteValue == 0f){ // if(player.getPosition().y == -OwlCityTribute.HEIGHT*.1f){ // dispose(); // this.gsm.setState(new Sky(this.gsm)); // } // } // } // else{ whiteValue = (whiteValue < 1f) ? whiteValue + .4f * dt : 1f; // } // Shimmer update for (int i = 0; i < NUM_SHIMMERS; i++) { shimmers.get(i).update(dt); } // Check brush for (int i = 0; i < brushmoving.size; i++) { brushmoving.get(i).MOVEMENT = -(player.movement / 5); brushmoving.get(i).update(dt); if (brushmoving.get(i).getPosition().x < leftEdge - brush.getWidth() * 1.5) { int index = (i == 0) ? brushmoving.size - 1 : i - 1; brushmoving.get(i).getPosition().x = brushmoving.get(index).getPosition().x + brush.getWidth(); break; } } cam.update(); } }
public static void load() { logoTexture = new Texture(Gdx.files.internal("data/logo.png")); logoTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); logo = new TextureRegion(logoTexture, 0, 0, 512, 114); texture = new Texture(Gdx.files.internal("data/texture.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); playButtonUp = new TextureRegion(texture, 0, 83, 29, 16); playButtonDown = new TextureRegion(texture, 29, 83, 29, 16); playButtonUp.flip(false, true); playButtonDown.flip(false, true); ready = new TextureRegion(texture, 59, 83, 34, 7); ready.flip(false, true); retry = new TextureRegion(texture, 59, 110, 33, 7); retry.flip(false, true); gameOver = new TextureRegion(texture, 59, 92, 46, 7); gameOver.flip(false, true); scoreboard = new TextureRegion(texture, 111, 83, 97, 37); scoreboard.flip(false, true); star = new TextureRegion(texture, 152, 70, 10, 10); noStar = new TextureRegion(texture, 165, 70, 10, 10); star.flip(false, true); noStar.flip(false, true); highScore = new TextureRegion(texture, 59, 101, 48, 7); highScore.flip(false, true); zbLogo = new TextureRegion(texture, 0, 55, 135, 24); zbLogo.flip(false, true); bg = new TextureRegion(texture, 0, 0, 136, 43); bg.flip(false, true); grass = new TextureRegion(texture, 0, 43, 143, 11); grass.flip(false, true); birdDown = new TextureRegion(texture, 136, 0, 17, 12); birdDown.flip(false, true); bird = new TextureRegion(texture, 153, 0, 17, 12); bird.flip(false, true); birdUp = new TextureRegion(texture, 170, 0, 17, 12); birdUp.flip(false, true); // creates an array of TextureRegions TextureRegion[] birds = {birdDown, bird, birdUp}; // Creates a new Animation in which each frame is 0.06 seconds long, using the above array. birdAnimation = new Animation(0.06f, birds); // Sets play mode to be ping pong, in which we will see a bounce. birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG); skullUp = new TextureRegion(texture, 192, 0, 24, 14); // Create by flipping existing skullUp skullDown = new TextureRegion(skullUp); skullDown.flip(false, true); bar = new TextureRegion(texture, 136, 16, 22, 3); bar.flip(false, true); dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav")); flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav")); coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav")); fall = Gdx.audio.newSound(Gdx.files.internal("data/fall.wav")); font = new BitmapFont(Gdx.files.internal("data/text.fnt")); font.getData().setScale(.25f, -.25f); whiteFont = new BitmapFont(Gdx.files.internal("data/whitetext.fnt")); whiteFont.getData().setScale(.1f, -.1f); shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt")); shadow.getData().setScale(.25f, -.25f); // Create (or retrieve existing) preferences file prefs = Gdx.app.getPreferences("Zombie Bird"); // Provide default high score of 0 if (!prefs.contains("highScore")) { prefs.putInteger("highScore", 0); } }
public static void load() { // TEXTURES has to be in Formtat: 2^x * 2^y loadNumbers(); loadBlocks(); loadPlayerTextures(); logoTexture = new Texture(Gdx.files.internal("data/logo.png")); logoTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); logo = new TextureRegion(logoTexture, 0, 0, 512, 114); texture = new Texture(Gdx.files.internal("data/texture.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); FileHandle test = Gdx.files.internal("data/touchBackground.png"); System.out.println(test.exists()); touchKnob = new Texture(test); touchKnob.setFilter(TextureFilter.Linear, TextureFilter.Nearest); playButtonUp = new TextureRegion(texture, 0, 83, 29, 16); playButtonUp.flip(false, true); playButtonDown = new TextureRegion(texture, 29, 83, 29, 16); playButtonDown.flip(false, true); playerFace = new Texture(Gdx.files.internal("data/playerLogo.png")); playerLogo = new TextureRegion(playerFace, 0, 0, playerFace.getWidth(), playerFace.getHeight()); playerLogo.flip(false, true); ready = new TextureRegion(texture, 59, 83, 34, 7); ready.flip(false, true); retry = new TextureRegion(texture, 59, 110, 33, 7); retry.flip(false, true); gameOver = new TextureRegion(texture, 59, 92, 46, 7); gameOver.flip(false, true); scoreboard = new TextureRegion(texture, 111, 83, 97, 37); scoreboard.flip(false, true); star = new TextureRegion(texture, 152, 70, 10, 10); noStar = new TextureRegion(texture, 165, 70, 10, 10); star.flip(false, true); noStar.flip(false, true); highScore = new TextureRegion(texture, 59, 101, 48, 7); highScore.flip(false, true); zbLogo = new TextureRegion(texture, 0, 55, 135, 24); zbLogo.flip(false, true); bg = new TextureRegion(texture, 0, 0, 136, 43); bg.flip(false, true); block = new TextureRegion(texture, 0, 100, 34, 25); block.flip(false, true); grass = new TextureRegion(texture, 0, 43, 143, 11); grass.flip(false, false); birdDown = new TextureRegion(texture, 136, 0, 17, 12); birdDown.flip(false, true); bird = new TextureRegion(texture, 153, 0, 17, 12); bird.flip(false, true); birdUp = new TextureRegion(texture, 170, 0, 17, 12); birdUp.flip(false, true); TextureRegion[] birds = {birdDown, bird, birdUp}; birdAnimation = new Animation(0.06f, birds); birdAnimation.setPlayMode(Animation.LOOP_PINGPONG); skullUp = new TextureRegion(texture, 192, 0, 24, 14); // Create by flipping existing skullUp skullDown = new TextureRegion(skullUp); skullDown.flip(false, true); bar = new TextureRegion(texture, 136, 16, 22, 3); bar.flip(false, true); // dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav")); // flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav")); // coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav")); // fall = Gdx.audio.newSound(Gdx.files.internal("data/fall.wav")); font = new BitmapFont(Gdx.files.internal("data/text.fnt")); font.setScale(.25f, -.25f); whiteFont = new BitmapFont(Gdx.files.internal("data/whitetext.fnt")); whiteFont.setScale(.1f, -.1f); shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt")); shadow.setScale(.25f, -.25f); // Create (or retrieve existing) preferences file prefs = Gdx.app.getPreferences("ZombieBird"); if (!prefs.contains("highScore")) { prefs.putInteger("highScore", 0); } }
public static void setLuckQuantity(int amt) { check(); prefs.putInteger(Consts.PREF_LUCK_QUANTITY, amt); save(); }
public static void setScore(int score) { check(); prefs.putInteger(Consts.PREF_SCORE, score); save(); }
public static void load(NanoCat nano) { pref = Gdx.app.getPreferences("NanoGameState"); if (!pref.getBoolean("hdState")) { if (nano.getTime() < 15 && nano.getTime() >= 5) { bgTexture = new Texture(Gdx.files.internal("data/bg_1_s.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_1_s.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else if (nano.getTime() < 20 && nano.getTime() >= 15) { bgTexture = new Texture(Gdx.files.internal("data/bg_2_s.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_2_s.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else if (nano.getTime() >= 20) { bgTexture = new Texture(Gdx.files.internal("data/bg_3_s.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3_s.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else { bgTexture = new Texture(Gdx.files.internal("data/bg_3_s.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3_s.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } } else if (pref.getBoolean("hdState")) { if (nano.getTime() < 15 && nano.getTime() >= 5) { bgTexture = new Texture(Gdx.files.internal("data/bg_1.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_1.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else if (nano.getTime() < 20 && nano.getTime() >= 15) { bgTexture = new Texture(Gdx.files.internal("data/bg_2.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_2.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else if (nano.getTime() >= 20) { bgTexture = new Texture(Gdx.files.internal("data/bg_3.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else { bgTexture = new Texture(Gdx.files.internal("data/bg_3.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } } bgBack = new TextureRegion(bgBackTexture, 0, 0, 4096, 580); // Particle Stuff smoke = new Texture(Gdx.files.internal("data/smoke_particle.png")); smokeSprite = new Sprite(smoke); smokeEmitter = new ParticleEmitter(); smokeParticle = new ParticleEffect(); smokeParticle.load(Gdx.files.internal("data/particlesmoke"), Gdx.files.internal("data")); smokeParticle.findEmitter("smoke").getScale().setHigh(50f); starEmitter = new ParticleEmitter(); starParticle = new ParticleEffect(); starParticle.load(Gdx.files.internal("data/particles"), Gdx.files.internal("data")); starParticle.findEmitter("star").getScale().setHigh(5f); starParticle.findEmitter("star2").getScale().setHigh(5f); // smokeParticle.getScale().setHigh(5f); // End Particle Stuff texture = new Texture(Gdx.files.internal("data/nano_region.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); nanoRun = new TextureAtlas(Gdx.files.internal("data/nanorun.atlas")); platform = new TextureAtlas(Gdx.files.internal("data/platform.atlas")); catRun1 = nanoRun.findRegion("nanorun0001"); catRun2 = nanoRun.findRegion("nanorun0005"); catRun3 = nanoRun.findRegion("nanorun0009"); catRun4 = nanoRun.findRegion("nanorun0013"); catRun5 = nanoRun.findRegion("nanorun0017"); catRun6 = nanoRun.findRegion("nanorun0021"); catRun7 = nanoRun.findRegion("nanorun0025"); catRun8 = nanoRun.findRegion("nanorun0029"); catRun9 = nanoRun.findRegion("nanorun0033"); catRun10 = nanoRun.findRegion("nanorun0037"); catRun11 = nanoRun.findRegion("nanorun0041"); catRun12 = nanoRun.findRegion("nanorun0045"); catRun13 = nanoRun.findRegion("nanorun0049"); catRun14 = nanoRun.findRegion("nanorun0053"); catRun15 = nanoRun.findRegion("nanorun0057"); catCollide1 = nanoRun.findRegion("nanocollide0080"); catCollide2 = nanoRun.findRegion("nanocollide0084"); catCollide3 = nanoRun.findRegion("nanocollide0088"); catCollide4 = nanoRun.findRegion("nanocollide0092"); catCollide5 = nanoRun.findRegion("nanocollide0096"); catCollide6 = nanoRun.findRegion("nanocollide0100"); catCollide7 = nanoRun.findRegion("nanocollide0104"); catCollide8 = nanoRun.findRegion("nanocollide0108"); case0 = platform.findRegion("case0"); case1 = platform.findRegion("case1"); case2 = platform.findRegion("case2"); case3 = platform.findRegion("case3"); case4 = platform.findRegion("case4"); case5 = platform.findRegion("case5"); case6 = platform.findRegion("case6"); caseDefault = platform.findRegion("default"); TextureRegion[] catRun = { catRun1, catRun2, catRun3, catRun4, catRun5, catRun6, catRun7, catRun8, catRun9, catRun10, catRun11, catRun12, catRun13, catRun14, catRun15 }; catRunAnim = new Animation(.015f, catRun); catRunAnim.setPlayMode(Animation.PlayMode.LOOP); TextureRegion[] catJump = { catRun1, catRun2, catRun3, catRun4, catRun5, catRun6, catRun7, catRun8, catRun9, catRun9, catRun9, catRun9, catRun9, catRun9, catRun9, catRun9 }; catJumpAnim = new Animation(.04f, catJump); catJumpAnim.setPlayMode(Animation.PlayMode.LOOP); TextureRegion[] catCollide = { catCollide1, catCollide2, catCollide3, catCollide4, catCollide5, catCollide6, catCollide7, catCollide8 }; catCollideAnim = new Animation(.02f, catCollide); catCollideAnim.setPlayMode(Animation.PlayMode.NORMAL); fontFilter = new Texture(Gdx.files.internal("data/roboto_lt.png")); fontFilter.setFilter(TextureFilter.Linear, TextureFilter.Linear); robotoLt = new BitmapFont( Gdx.files.internal("data/roboto_lt.fnt"), new TextureRegion(fontFilter), false); robotoLt.setScale(.5f, .5f); fontFilter2 = new Texture(Gdx.files.internal("data/roboto_blk.png")); fontFilter2.setFilter(TextureFilter.Linear, TextureFilter.Linear); robotoBlk = new BitmapFont( Gdx.files.internal("data/roboto_blk.fnt"), new TextureRegion(fontFilter2), false); robotoBlk.setScale(.5f, .5f); panel = new Texture(Gdx.files.internal("data/panelcolor.png")); panel.setFilter(TextureFilter.Linear, TextureFilter.Linear); panelSprite = new Sprite(panel, 500, 300); fbShare = new Texture(Gdx.files.internal("data/fbshare.png")); fbShare.setFilter(TextureFilter.Linear, TextureFilter.Linear); fbShareSprite = new Sprite(fbShare, 199, 57); menuBack = new Texture(Gdx.files.internal("data/menu_back.png")); menuBack.setFilter(TextureFilter.Linear, TextureFilter.Linear); menuBackSprite = new Sprite(menuBack, 320, 50); collision = Gdx.audio.newSound(Gdx.files.internal("data/audio/collide.wav")); milestone = Gdx.audio.newSound(Gdx.files.internal("data/audio/milestone.wav")); milestone50 = Gdx.audio.newSound(Gdx.files.internal("data/audio/milestone50.wav")); jump = Gdx.audio.newSound(Gdx.files.internal("data/audio/nanojump.wav")); jumpSound = Gdx.audio.newSound(Gdx.files.internal("data/audio/jump_sound.wav")); dblJump = Gdx.audio.newSound(Gdx.files.internal("data/audio/nanojump2.wav")); hit = Gdx.audio.newSound(Gdx.files.internal("data/audio/hit.wav")); select = Gdx.audio.newSound(Gdx.files.internal("data/audio/select.wav")); run = Gdx.audio.newSound(Gdx.files.internal("data/audio/run.wav")); highScore = Gdx.audio.newSound(Gdx.files.internal("data/audio/highscore.wav")); // Scoring score = Gdx.app.getPreferences("NanoCat"); if (!score.contains("distance")) { score.putFloat("distance", 0); } if (!score.contains("highScore")) { score.putFloat("highScore", 0); } if (!score.contains("totalFall")) { score.putInteger("totalFall", 0); } }
public static void setTotalFall() { fallTemp = score.getInteger("totalFall"); fallTemp++; score.putInteger("totalFall", fallTemp); }
// Receives an integer and maps it to the String highScore in prefs public static void setHighScore(int val) { prefs.putInteger("highScore", val); prefs.flush(); }
/** Tallennetaan nykyinen kieli. * */ public void save(Preferences preferences) { preferences.putInteger("Locale", currentLocaleIndex); }