What I'm trying to do is have a button in the world that when clicked adds 5 to the int Credits
Code for the button
Then, I want the int to be printed by another class, Balance
Code for balance
However, the error is cannot find symbol, variable Credits.
What I want to do is have the Credits accessible by all classes.
PS Im bad at greenfoot
import greenfoot.*;
import java.awt.Color;
public class Button extends Actor
{
public void act()
{
int credits = 0;
if (Greenfoot.mouseClicked (this))
{
credits = credits + 5;
}
}
}
import greenfoot.*;
public class Balance extends Actor
{
public void act()
{
String strx = Credits + "";
GreenfootImage textImage = new GreenfootImage ( strx ,40, Color.WHITE, Color.BLUE);
setImage(textImage);
}
}
