I am quite new to Greenfoot and tried to do this game where you got to catch fruits with a basket.
I want the player to be able to control the basket with the mouse and therefore tried this:
but when I compile it gives me the following error:
"non-static method getX() cannot be referenced from a static context"
what am I doing wrong and how can I fix it?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; public class Basket extends Actor { private int x = 0 ; public void act() { x = MouseInfo.getX(); setLocation(x, 880 ); } } |