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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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()); } } } |