Please help my school project
i want make game that counting how much bug in world than press number button to
declare the number
but i have a trouble about count how much bug.class in the world, bug.class is spawn when i press button.class .
and than can you make a code for the number button? please i am new here
sorry for my bad langguag.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import greenfoot.*; import java.util.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class button here. * * @author (your name) * @version (a version number or a date) */ public class button extends Actor { int i = Greenfoot.getRandomNumber( 9 ); /** * Act - do whatever the button wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { start(); } public void start() { if (Greenfoot.mouseClicked( this )) { MouseInfo mouse = Greenfoot.getMouseInfo(); for ( int x= 0 ; x <i ; x++) { getWorld().addObject( new bug(), 76 , 90 ); Greenfoot.delay( 5 ); }} } } |