Report as inappropriate.
I got the idea from Celestics free scrolling world. I am posting it just as a starting point for beginners so that they get the idea of how to make their own scrolling games. If you just want to use this code for your games, here are some directions on how to use it.
Place your main actor that the rest of the world will be scrolling around in the man class and everything that will move when he scrolls in the other class. You can leave stuff like health bars or counters somewhere else and they will not be affected.
In order to limit the range that your actor can travel through (i.e. so that he will not go off of the image) call the can(direction) method. The numbers that represent which directions are defined in the Man class. Currently the range is set to -400 to 0 and from -600 to 0. To modify them go to the can class in the Man's code and modify the greater than brackets. Remember that everything in this world is flipped from usual java.
In order to set the starting position of the character, change the x, y variables in the scroller class to negatives of the position you want him to start in.
In order to set the image you want to use as your background, change the scroller's testScroll variable, and set the scroller's image to that.
There is a tutorial on this under Scrolling Man\doc\Tutorial.rtf in the download. The result is uploaded here http://www.greenfoot.org/scenarios/5704.
8137 views / 16 in the last 7 days
4 votes | 0 in the last 7 days
This scenario is a member of: Greenfoot courses, Scrolling games
Want to leave a comment? You must first log in.
2012/7/15
2012/7/15
2012/7/15
2012/7/17
2012/7/17
2012/8/4
2012/9/12
2012/9/12