I'm making a game where I have a button in a World. If I click this button I want it to set the variable "img" in another world to 2. This is the code of the button:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class S2 extends buttons { public void act() { if(Greenfoot.mouseClicked(this)) { if(//? { // sets the variable img of World "welt" to 2 } getWorld().removeObject(this); Greenfoot.setWorld(new Game()); } } }