
/**
* CLASS: NonStopScroller
*
* DESCRIPTION: creates an unlimited continuously scrolling world
*/
import greenfoot.*;
public class NonStopScroller extends World
{
// class constants
public static final int WIDE = 800; // world width (viewport)
public static final int HIGH = 600; // world height (viewport)
// instance reference field for Scroller object
private Scroller scroller;
// creates the world that will scroll
public NonStopScroller()
{
super(WIDE, HIGH, 1, false); // create an unbounded world
GreenfootImage image = new GreenfootImage("bg.png")); // the background image
scroller = new Scroller(this, image); // create the Scroller object
}
public void act()
{
scroll();
}
// performs continuous upward scrolling
private void scroll()
{
int speed = 2;
scroller.scroll(0, -speed);
}
}