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

2023/4/28

Stop Either Method

Mzarifin58 Mzarifin58

2023/4/28

#
Hei, I want to stop my Either Method in my program. This my program: public void act (){ if ( Greenfoot.getRandomNumber(100)<1){ addObject(new enemy(), Greenfoot.getRandomNumber(499), 500); } countTime(); if ( time == 0){ // What should i put in here? } } I want "if the time == 0" the enemy is stopping spawn, and then what should i do?
Mzarifin58 Mzarifin58

2023/4/28

#
Please, what should i do?
Super_Hippo Super_Hippo

2023/4/28

#
Maybe like this?
public void act()
{
    countTime();
    if (time > 0)
    {
        if (Greenfoot.getRandomNumber(100)==0)
        {
            addObject(new enemy(), Greenfoot.getRandomNumber(499), 500);
        }
    }
}
Mzarifin58 Mzarifin58

2023/4/29

#
I have try your program in my program, buat it doesnt work
danpost danpost

2023/4/29

#
Mzarifin58 wrote...
I have try your program in my program, buat it doesnt work
Please show attempted code (entire class please).
You need to login to post a reply.