I have a code to set my ProgressBar with value on the different class but it does not run. i need to set my progressbar with monsterHP then if the monsterHP below 0 it does reset the monster hp and increment the stage.
Heres the code:
public class MainActivity extends Activity {
MonsterStatus monsterStatus;
PlayerStatus playerStatus;
public Button myClick;
ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
myClick = (Button) findViewById(R.id.btnClick);
progressBar.setProgress(monsterStatus.getMonsterHP());
myClick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
monsterStatus.onClick(playerStatus.getClickDamage());
progressBar.setProgress(monsterStatus.getMonsterHP());
}
});
}
}
public class MonsterStatus {
private String monsterName;
private int monsterHP = 50;
public boolean isAlive;
private int currentStage = 1;
private int headID,bodyID,armsID,legsID;
public void setMonsterHP(){
if(currentStage > 10 && currentStage < 21){
monsterHP = 100;
}
}
public int getMonsterHP(){
return monsterHP;
}
public void onClick(int _clickPower){
monsterHP -= _clickPower;
if(monsterHP <= 0){
currentStage += 1;
setMonsterHP();
}
}
}
What should i do to get the different class variable?