I'm creating a Guitar Hero for my school, and I am having trouble taking the private Variable of a setting actor by clicking on it. The line with a lot of dashes on it is causing me the most problems. Thanks -Hyperbaba
World Class
public class MyWorld extends greenfoot.World
{
/**
* Constructor for objects of class MyWorld.
*
*/
static int noteMissed, noteHit, noteStreak,acts, random, total, input;
static int speed = (int)(Math.random()*35 + 15);
static int ex;
private int increase = 50;
static boolean start = false;
boolean gameStart = true;
MouseInfo mouse = Greenfoot.getMouseInfo();
int[] setting = {100,75,50};
// String[] songs = {"Song.mp3"};
GreenfootSound backGroundMusic = new GreenfootSound("Song.mp3");
public MyWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1200, 800, 1);
Prepare();
}
public void Prepare(){
for(int x = 1; x <= 3; x ++){
Setting set = new Setting(x);
addObject(set,200+(400*(x-1)) ,400);
}
}
public void Prepare2(){
for(int x = 1; x <= 5; x++){
Button button = new Button(x);
addObject(button,386+107*(x-1), 707);
}
int noteMissed = 0;
int noteHit = 0;
int noteStreak = 0;
int acts = 0;
int random = 0;
}
public void act(){
------------------------------------------------ ex = setting[( ((Setting)(mouse.getActor())) .returnNum())-1];
if(Setting.returnStart()){
//ex = setting[( ((Setting)(mouse.getActor())) .returnNum())-1];
if(gameStart == true){
Prepare2();
start = true;
setBackground("fret.jpg");
// backGroundMusic.playLoop();
//ex = setting[( ((Setting)(mouse.getActor())) .returnNum())-1];
gameStart = false;
}
if(acts % speed == 0){
random = (int)(Math.random()*5)+1;
Note notee = new Note(random);
addObject(notee,526+36*(random-1),345);
total++;
speed = (int)(Math.random()*ex + 5);
}
showText("Note Streak:" + noteStreak, 1100, 100);
showText("Notes Hit:" + noteHit + "/" + total, 100, 100);
showText("Notes Missed:" + noteMissed, 100, 200);
if(noteStreak >= increase){
ex -= 2;
increase += 10;
}
acts++;
}
}
public static void setMiss(){
noteMissed ++;
}
public static void setHit(){
noteHit ++;
noteStreak ++;
}
public static void reset(){
noteStreak = 0;
}
public void startMusic(){
backGroundMusic.playLoop();
}
public static boolean Starting(){
return start;
}
public int returnEX(){
return ex;
}
}
--------------------------------------------
//Setting class
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Setting here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Setting extends Actor
{
/**
* Act - do whatever the Setting wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int num;
static int num2;
MyWorld myWorld = (MyWorld) getWorld();
static boolean start= false;
public Setting(int x){
num = x;
num2 = x;
setImage("diff" + x + ".jpg");
}
public void act()
{
if(Greenfoot.mouseClicked(this)){
// myWorld.setEX(returnNum());
start = true;
}
if(myWorld.Starting()){
getWorld().removeObject(this);
}
}
static public int returnNum(){
return num2;
}
static boolean returnStart(){
return start;
}
}
