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

2018/5/4

MUSIC

Heet_Patel Heet_Patel

2018/5/4

#
So I have a basic understanding of BGM but there is one question in my mind. The question is: If, I have a few different worlds and when I click on another world will the music stop? For example, I have a world called Start. I insert the code for the BGM. Now this world has a button which once I click on it will take me to another world. Will this mean that the music will stop for the Start world and will the music for the new world start without any kind of input on my side.
danpost danpost

2018/5/4

#
Heet_Patel wrote...
If, I have a few different worlds and when I click on another world will the music stop?
Why don't you just try it to find out? You do not have to ask anything here you can test on your own.
I have a world called Start. I insert the code for the BGM. Now this world has a button which once I click on it will take me to another world. Will this mean that the music will stop for the Start world and will the music for the new world start without any kind of input on my side.
Same goes with this.
Heet_Patel Heet_Patel

2018/5/5

#
Yeah it doesn't work. Pls send me a code which will work. I need help with this man.
Heet_Patel Heet_Patel

2018/5/5

#
Also i have a spawner which is only supposed to spawn 5 fishes but it continues to spawn after the five fishes This is the code
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Nest here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class SharkSpawner extends chaar
{
    /**
     * Act - do whatever the Nest wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public SharkSpawner()
    {
        GreenfootImage image = getImage();
        image.scale(image.getWidth() - 400, image.getHeight() - 370);
        setImage(image);
    }
    private int spawnTimer = 20;
    public void act() 
    {
        if (spawnTimer > 0) spawnTimer--;
        if (spawnTimer == 0 && getWorld().getObjects(Fish.class).size() < 5)
        {
            getWorld().addObject(new Shark_2(), getX(), getY());
            spawnTimer = 100;
        }
    }
}
Heet_Patel Heet_Patel

2018/5/5

#
why does it not work
danpost danpost

2018/5/5

#
Heet_Patel wrote...
i have a spawner which is only supposed to spawn 5 fishes but it continues to spawn after the five fishes
Does the Shark_2 class extend the Fish class?
Heet_Patel Heet_Patel

2018/5/6

#
nope tnx
Heet_Patel Heet_Patel

2018/5/6

#
what do i do to make it work again
Heet_Patel Heet_Patel

2018/5/6

#
I have go it to work somehow. tnx for the help. Now is it possible to make a counter which adds a point every few seconds you survive. Sorry for asking so many questions
You need to login to post a reply.