I am having trouble with implementing danposts Scrolling SuperWorld. I already created the SWorld and pasted everything into it. Now (if I understand right) I only have to adjust the code of the subclass of SWorld, which is RaceWorld in my case. Scrolling works already, but only horizontally.
What I basically want is a "zoom window" around my actor following it (vertically and horizontally). My RaceWorld image is 1000x750. My Actor image is 46x24. RaceTrack and StartLine should scroll as the world does so they stick to it. This is my subclass of SWorld:
Any help is highly appreciated ^^
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public class RaceWorld extends SWorld { public RaceWorld() { super ( 750 , 750 , 1 , 1000 ); // scroll world constructor call; last parameter is scroll width addObject( new RaceTrack(), 375 , 375 ); addObject( new StartLine(), 372 , 126 ); setMainActor( new Car(), 250 , 300 ); mainActor.setLocation( 450 , 125 ); GreenfootImage bg = new GreenfootImage( "World.png" ); setScrollingBackground(bg); } } |