everytime i am pressing the restart button i am getting the problem that my music will be playing for the 2nd time over the first music, this is important i need
FIXING
please help the poor ernie who can no longer fix the game myself because i amErnie
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Generates the actual game.
*
* @author ()
* @version (v.1.0)
*/
public class PlayArea extends Maps
{
/**
* Constructor for objects of class PlayArea.
*
*/
public PlayArea()
{
// Plays music
backgroundMusic.playLoop();
//Inherits world size from Maps
preparePlayArea();
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Maps here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Maps extends World
{
Counter counter1;
Score score;
Counter health;
int [][]coOrd={{30,575,582,25,322,321},{30,32,584,583,26,581}};
int [][]Blerko={{576,580,34,27,29,580},{171,467,202,445,328,316}};
// Gets music to play
GreenfootSound backgroundMusic = new GreenfootSound("BattleBoi Music.mp3");
/**
* Constructor for objects of class Maps.
*
*/
public Maps()
{
// Create a new world with 600x600 cells with a cell size of 1x1 pixels.
super(600, 600, 1);
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
public void preparePlayArea()
{
Champion champion = new Champion();
addObject(champion,308,313);
score = new Score();
addObject(score,340,16);
score.setLocation(340,16);
health = new Counter();
health.sethealth(100);
addObject(health,242,16);
for(int i=0; i<6; i++)
{
addObject(new Klorb(), coOrd[0][i],coOrd[1][i]);
}
for(int i=0; i<6; i++)
{
addObject(new Blerko(), coOrd[0][i],coOrd[1][i]);
}
}
public void removeHealth()//this is used to remove health
{
health.add(-2);
}
public int getHealth1()//this allows classes get
{
int x = health.gethealth();
return x;
}
public void addScore()
{
score.add(2);
}
/**
* Prepare BossBattle for the start of the program.
* That is: create the initial objects and add them to the world.
*/
public void prepareBossBattle()
{
Champion champion = new Champion();
addObject(champion,108,534);
BossMan bossman = new BossMan();
addObject(bossman,471,148);
counter1 = new Counter();
addObject(counter1,303,19);
bossman.setLocation(472,147);
}
public void removeHealth2()//this is used to remove health
{
counter1.add(-2);
}
public int getHealth2()//this allows classes get
{
int x = counter1.gethealth();
return x;
}
}
