I just wrote some code in a class called "Player" that creates a bottom sensor to detect things below the Player. However, when I try to run the project, I get this error in the Terminal Window:
The first parts of my code for the Player is:
The code for the BottomSensor is:
Thank you guys!
java.lang.StackOverflowError at java.util.HashMap.putVal(HashMap.java:634) at java.util.HashMap.put(HashMap.java:611) at greenfoot.core.ImageCache.addCachedImage(ImageCache.java:75) at greenfoot.util.GreenfootUtil.addCachedImage(GreenfootUtil.java:788) at greenfoot.GreenfootImage.<init>(GreenfootImage.java:116) at Player.<init>(Player.java:14) at BottomSensor.<init>(BottomSensor.java:9) at Player.<init>(Player.java:24)
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* The person that the user controls
*
* @author Wasupmacuz
* @version 0.0.0
*/
public class Player extends Actor
{
private static int walking;
private static int walkDirection;
public static boolean isWalking=false;
GreenfootImage stand=new GreenfootImage("playerStand.png");
GreenfootImage walk1=new GreenfootImage("playerWalk1.png");
GreenfootImage walk2=new GreenfootImage("playerWalk2.png");
private static String leftOrRight="left";
/**
* Makes necessary things at the start of everything
*/
public Player()
{
BottomSensor bottom=new BottomSensor();
getWorld().addObject(bottom,getX(),getY()-26);
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class BottomSensor here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class BottomSensor extends Player
{
/**
* Act - do whatever the BottomSensor wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}

