Im working on a school project now and i cant seem to change the world from world1 to world2, code im using is here. it is my bullet class
n a school project now and i cant seem to change the world from world1 to world2, code im using is
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class bullet here. * * @author (your name) * @version (a version number or a date) */ public class bullet extends Actor { private static final int damage = 16; private boolean stillalive = true; private int Scaryman2Eaten; /** A bullet looses one life each act, and will disappear when life = 0 */ private int life = 30; private int bulletspeed = 5; public boolean canSee(Class clss) { Actor actor = getOneObjectAtOffset(0, 0, clss); return actor != null; } public void eat(Class clss) { Actor actor = getOneObjectAtOffset(0, 0, clss); if(actor != null) { getWorld().removeObject(actor); } } public bullet() { Scaryman2Eaten = 0; } public bullet(int speed) { bulletspeed = speed; } /** * The bullet will damage it if it hits them. */ public void act() { lookForScaryman2(); lookForscaryman3(); if(life <= 0) { getWorld().removeObject(this); } else { life--; move(bulletspeed); checkScaryman2Hit(); if (stillalive) { checkscaryman3Hit(); } } if (Scaryman2Eaten == 3) { Greenfoot.setWorld(new Town2()); } } /** * Check whether we have hit an asteroid. */ private void checkScaryman2Hit() { Scaryman2 scaryman2 = (Scaryman2) getOneIntersectingObject(Scaryman2.class); if (scaryman2 != null){ getWorld().removeObject(this); scaryman2.hit(damage); stillalive = false; } } private void checkscaryman3Hit() { scaryman3 scaryman3 = (scaryman3) getOneIntersectingObject(scaryman3.class); if (scaryman3 != null){ getWorld().removeObject(this); scaryman3.hit(damage); stillalive = false; } } public bullet(Vector speed, int rotation) { setRotation(rotation); } public void lookForScaryman2() { if ( canSee(Scaryman2.class) ) { eat(Scaryman2.class); Scaryman2Eaten = Scaryman2Eaten + 1; } if (Scaryman2Eaten == 3) { Greenfoot.setWorld(new Town2()); } } public void lookForscaryman3() { if ( canSee(scaryman3.class) ) { eat(scaryman3.class); } } }