SO I got the code off of onw of danposts games that involves bees and babys. I used the scrolling world code off of his game and it works fine but there is just onr thing. when ever objects are close to the edge of the world I want them to go off the screen but they get dragged along my the adge of the screen. I NEED HELP FAST!!!
The Code in the world class
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Level1 here. * * @author (your name) * @version (a version number or a date) */ public class Level1 extends World { GreenfootSound backgroundMusic = new GreenfootSound("hl2_song1.mp3"); public ImgScroll scroller; // scroll controller private Jerome jerome; // main actor /** * Constructor for objects of class Level1. * */ public Level1() { super(1500, 700, 1); backgroundMusic.playLoop(); backgroundMusic.setVolume(40); addObject(jerome= new Jerome(), 60, 60); prepare(); // settings Greenfoot.setSpeed(50); setPaintOrder(Jerome.class); // initialize fields scroller = new ImgScroll(this, new GreenfootImage("Level1.png"), 5000, 700); // prepare and add actors to world for (int j=0; j<scroller.getScrollHeight()-100; j+=300) for (int i=0; i<scroller.getScrollWidth()-200; i+=300); } public void act() { // run scroll engine (keeps boy in center when possible) scroller.scroll(getWidth()/2-jerome.getX(), getHeight()/2-jerome.getY()); } public void stopped() { backgroundMusic.pause(); } public void started() { backgroundMusic.playLoop(); backgroundMusic.setVolume(40); } /** * Prepare the world for the start of the program. * That is: create the initial objects and add them to the world. */ private void prepare() { Jerome jerome = new Jerome(); addObject(jerome,278,229); RipperSpawner ripperspawner = new RipperSpawner(); addObject(ripperspawner,431,112); removeObject(jerome); TeliZone telizone = new TeliZone(); addObject(telizone,4568,113); TeliText telitext = new TeliText(); addObject(telitext,4568,121); telitext.setLocation(4566,111); Barrel1 barrel1 = new Barrel1(); addObject(barrel1,997,72); Barrel1 barrel12 = new Barrel1(); addObject(barrel12,913,127); Barrel1 barrel13 = new Barrel1(); addObject(barrel13,1016,171); Barrel1 barrel14 = new Barrel1(); addObject(barrel14,981,130); barrel14.setLocation(939,201); } }