Hi all,
I am trying to make the google chrome t rex game. However I cannot make it scroll.
Here is the code:
The error message is that it cannot find "Scroller".
Please help
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class MyWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Background extends World
{
public static final int WIDE = 1000;
public static final int HIGH = 600;
private Scroller scroller;
public Background()
{
super(WIDE,HIGH,1,false);
GreenfootImage image = newGreenfootImage("background.png");
scroller = new Scroller(this,image);
}
public void act()
{
scroll();
prepare();
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
Trex trex = new Trex();
addObject(trex,126,491);
trex.setLocation(126,482);
trex.setLocation(122,485);
}
private void scroll()
{
int speed = 2;
scroller.scroll(0,- speed);
}
}


