This site requires JavaScript, please enable it in your browser!
Greenfoot back
qwasyx
qwasyx wrote ...

2012/11/9

How can I stop a method without finishing the game?

qwasyx qwasyx

2012/11/9

#
Hey guys. First of all sorry for my bad English. My problem: i want to cancel a method without stopping the whole game. private void nachladen() { if(anzahlSchuesse == 0) { Label label = new Label ("Reload"); getWorld().addObject (label, getX(), getY()); if (reloadDelayCount >0) { reloadDelayCount --; } if( reloadDelayCount <0) { anzahlSchuesse = anzahlSchuesse+30; } Before the delaycount realy starts I can still shoot and my number of bullets is negative. So I want to stop shooting therewith i can wait until the delaycount is = 0 again and my number of bullets get filled again. How can I do this? Please help me
SPower SPower

2012/11/10

#
Add this at the place you wanna be able to cancel:
if (reloadDelayCount <= 0) {
    return;
}
this will 'cancel' the method when reloadDelayCount is smaller or equal to 0
qwasyx qwasyx

2012/11/10

#
thank you!
SPower SPower

2012/11/10

#
You're welcome!
You need to login to post a reply.