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

2020/5/20

Is there a way to get something to happen if there are no enemies on the world?

1
2
MYSTICPHOENIXXX MYSTICPHOENIXXX

2020/5/20

#
MYSTICPHOENIXXX wrote...
danpost wrote...
MYSTICPHOENIXXX wrote...
Can you please give an example visually?
Well, I think you are coding this in the wrong place to begin with. This action sounds like a major game procedure which should be a World subclass behavior. Remove all concerning killed enemies from Angels class and then in your World subclass, use an act method there:
public void act()
{
    if (getObjects(Enemies.class).size() == 0) { }
    // or
    if (getObjects(Enemies.class).isEmpty()) {}
}
I just put that in but for some reason it's silent.
The sound*
danpost danpost

2020/5/20

#
MYSTICPHOENIXXX wrote...
The sound*
You have to fill in the code in the "{ }" brackets.
MYSTICPHOENIXXX MYSTICPHOENIXXX

2020/5/20

#
danpost wrote...
MYSTICPHOENIXXX wrote...
The sound*
You have to fill in the code in the "{ }" brackets.
I did put the sound code in it but when I kill all 3 enemies, it's silent.
danpost danpost

2020/5/20

#
MYSTICPHOENIXXX wrote...
I did put the sound code in it but when I kill all 3 enemies, it's silent.
Show code.
MYSTICPHOENIXXX MYSTICPHOENIXXX

2020/5/20

#
  public void act ()
    {
        if (getObjects(Enemies.class).size() == 0) 
        {
            Greenfoot.playSound("yipee.wav");
        }
    }
danpost danpost

2020/5/20

#
And that code is in your active World subclass -- yes?
danpost danpost

2020/5/20

#
Do you have other classes that extend thee Enemies class? If so, list them.
MYSTICPHOENIXXX MYSTICPHOENIXXX

2020/5/20

#
danpost wrote...
And that code is in your active World subclass -- yes?
yes
danpost danpost

2020/5/20

#
danpost wrote...
Do you have other classes that extend the Enemies class? If so, list them.
MYSTICPHOENIXXX MYSTICPHOENIXXX

2020/5/20

#
danpost wrote...
danpost wrote...
Do you have other classes that extend the Enemies class? If so, list them.
danpost wrote...
danpost wrote...
Do you have other classes that extend the Enemies class? If so, list them.
no
danpost danpost

2020/5/20

#
Show code where shot enemies are removed from world and indicate where that code is located.
You need to login to post a reply.
1
2