I am making a cookie clicker game in greenfoot and I am trying to check when theCookie is clicked in the world so I can add to the counter. Maybe I can't do it this way but I've been using act() in my world class and trying to check if it's clicked with Greenfoot.mouseClicked(theCookie). If you need any more info than I've given just tell me
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class Clicker extends World { /** * Constructor for objects of class Clicker. * */ private int cookieCounter = 100; private int cookiesPerSecond = 0; private int clickValue = 1; Cookie theCookie = new Cookie(); ShopFrame theShopFrame = new ShopFrame(); Grandma theGrandma = new Grandma(); public Clicker() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(1000, 800, 1); addObject(theCookie, 280, 480); addObject(theShopFrame, 820, 400); addObject(theGrandma, 827, 400); } public void act() { if(Greenfoot.mouseClicked(theCookie)) { cookieCounter += clickValue; } showText("" + cookieCounter, 100, 100); } }