I am getting this error, yet NOTHING in my code is static!!! HELLPPP!
Here is the code from the two classes that are interacting:
And the other.....
PLEASE HELP MEE!!!!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Piece here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Piece extends Actor
{
public String player;
public int color;
public boolean isp1turn2;
public int dumX;
public int dumY;
public Piece(int color){
if(color == 1){
setImage("blue-draught.png");
player = "Blue";
color = color;
}
if(color == 2)
{
player = "Red";
color = color;
}
isp1turn2 = true;
}
/**
* Act - do whatever the Piece wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
try{
makeKing();
}
catch(NullPointerException e){
}
takeTurn();
}
public void makeKing()
{
if(player.equals("Red") && getY()<=0){
getWorld().addObject(new King(color), getX(), getY());
getWorld().removeObject(this);
}
}
public void takeTurn()
{
if(isp1turn2 == true){ // is p1's turn:
if(Greenfoot.mouseClicked(this)){
getWorld().addObject(new Dummy(), getX()-1, getY()-1);
getWorld().addObject(new Dummy(), getX()+1, getY()-1);
setLocation(dumX, dumY);
}
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Dummy here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Dummy extends Actor
{
public int xX;
public int yY;
public boolean isClicked;
/**
* Act - do whatever the Dummy wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
xX = getX();
yY = getY();
if(Greenfoot.mouseClicked(this)){
isClicked = true;
}
if(isClicked == true){
Piece.dumX = xX; //<== ERROR COMES HERE
Piece.dumY = yY(); //<== ERROR COMES HERE
isClicked = false;
}
}
}

