Back to project page diploma-assignment.
The source code is released under:
MIT License
If you think the Android project diploma-assignment listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.me.main; /* www.jav a2s . c om*/ import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.utils.Base64Coder; import com.badlogic.gdx.utils.Json; import com.badlogic.gdx.utils.JsonWriter.OutputType; import com.me.battlescreen.BattleScreen; import com.me.openingscreen.OpeningScreen; public class MyGame extends Game{ private OpeningScreen openingScreen; private BattleScreen battleScreen; private Player player; @Override public void create() { Texture.setEnforcePotImages(false); loadPlayer(); openingScreen = new OpeningScreen(this); this.setScreen(openingScreen); } private void loadPlayer() { Json json=new Json(); if(Gdx.files.local("profile/player.json").exists()){ String s=Gdx.files.local("profile/player.json").readString(); s=Base64Coder.decodeString(s); player= json.fromJson(Player.class, s); }else{ resetPlayer(); } } public void resetPlayer() { player=new Player("player"); savePlayer(); } public void savePlayer(){ Json json=new Json(); json.setOutputType(OutputType.json); FileHandle handle= Gdx.files.local("profile/player.json"); String s=json.toJson(player); s=Base64Coder.encodeString(s); handle.writeString(s, false); } public void battle() { battleScreen=new BattleScreen(this,player); this.setScreen(battleScreen); } public void destroyBattleScreen() { // TODO Auto-generated method stub battleScreen=null; } @Override public void dispose(){ Gdx.app.exit(); } public Player getPlayer() { return player; } public OpeningScreen getOpeningScreen() { return openingScreen; } }