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
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 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); } } |