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.openingscreen; //w w w . ja va 2 s . c om import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Touchable; import com.me.battlescreen.MyButton; import com.me.battlescreen.MyLabel; public class PlayerMenu extends AbstractMenu{ MyButton toBattleScreen; MyButton toUpgradeScreen; MyButton toStatisticsScreen; MyButton toFirstMenu; MyLabel gold; MyLabel level; BitmapFont font; public PlayerMenu(OpeningScreen s, Stage st) { super(s, st); // TODO Auto-generated constructor stub font=new BitmapFont(Gdx.files.internal("data/myFont.fnt"),Gdx.files.internal("data/myFont.png"),false); font.setUseIntegerPositions(false); font.setScale(s.getHeight()*0.10f/font.getLineHeight()); gold=new MyLabel(screen,"123456",font,new int[]{0,screen.getHeight()}); gold.setTouchable(Touchable.disabled); updateGold(); level=new MyLabel(screen,"Level:"+screen.game.getPlayer().getLevel(),font,new int[]{(int)(screen.getWidth()*0.7f),screen.getHeight()}); level.setTouchable(Touchable.disabled); stage.addActor(gold); stage.addActor(level); createButtons(); addListeners(); } @Override protected void createButtons() { Texture t=new Texture(Gdx.files.internal("data/menus/battle.png")); toBattleScreen=new MyButton(t); createButton(toBattleScreen,7,t,1); t=new Texture(Gdx.files.internal("data/menus/upgrade.png")); toUpgradeScreen=new MyButton(t); createButton(toUpgradeScreen,5,t,1); t=new Texture(Gdx.files.internal("data/menus/statistics.png")); toStatisticsScreen=new MyButton(t); createButton(toStatisticsScreen,3,t,1); t=new Texture(Gdx.files.internal("data/menus/return.png")); toFirstMenu=new MyButton(t); createButton(toFirstMenu,1,t,1); } @Override protected void addListeners() { addToBattleListener(); addToUpgradeListener(); addToStatisticsListener(); addToFirstMenuListener(); } private void addToBattleListener() { // TODO Auto-generated method stub toBattleScreen.addListener(new InputListener(){ public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { toBattleScreen.setPressed(true); return true; } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { toBattleScreen.setPressed(false); screen.game.battle(); } }); } private void addToUpgradeListener() { // TODO Auto-generated method stub toUpgradeScreen.addListener(new InputListener(){ public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { toUpgradeScreen.setPressed(true); return true; } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { toUpgradeScreen.setPressed(false); screen.setMenu(new UpgradeMenu(screen,stage)); } }); } private void addToStatisticsListener() { // TODO Auto-generated method stub toStatisticsScreen.addListener(new InputListener(){ public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { toStatisticsScreen.setPressed(true); return true; } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { toStatisticsScreen.setPressed(false); screen.setMenu(new StatisticsMenu(screen,stage)); } }); } private void addToFirstMenuListener() { // TODO Auto-generated method stub toFirstMenu.addListener(new InputListener(){ public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { toFirstMenu.setPressed(true); return true; } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { toFirstMenu.setPressed(false); screen.setMenu(new FirstMenu(screen,stage)); } }); } public void updateGold() { // TODO Auto-generated method stub long temp=screen.game.getPlayer().getGold(); if(temp==0) temp=1; int count=0; while(temp>0){ temp/=10; count++; } String s=""; for(int i=0;i<8-count;i++){ s=s+" "; } gold.setText("Gold:"+s+screen.game.getPlayer().getGold()); } }