This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

SPower presents ...


Scrolling world

An implementation of a way to scroll through a world too big to fit on screen.

The important classes are ScrollWorld and ScrollActor, so you would do well to read the documentation of those two classes. If you've got further questions, you may leave a comment here (though please, don't post full code here: do that in a discussion).

As a demo, I made a bug that walks around in the world. It is controlled with your mouse and the up/down keys. Feel free to use the demo code in the Bug class, as all of the movement code is in there.

You're free to use this in your own games, but if you do so, I would appreciate giving credit as to where you got the scrolling code from.

25817 views / 1973 in the last 7 days

17 votes | 1 in the last 7 days

Tags: mouse demo with-source scrolling

This scenario is a member of: Reusable actors & support classes, Scrolling games

open in greenfoot

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

A new version of this scenario was uploaded on Thu Oct 31 20:11:27 UTC 2013 Bug fixes in the ScrollActor class
A new version of this scenario was uploaded on Thu Oct 31 20:15:25 UTC 2013 Fixed another bug in ScrollActor
A new version of this scenario was uploaded on Fri Nov 01 16:26:32 UTC 2013 Fixed a bug where removing a ScrollActor would case an exception


Thanks again :) .


I used this in a small class assignment. ScrollWorld and ScrollActor simplified a lot of stuff. Many thanks! You can find it here:


I am using your Scenario in one of my School Projects and it is helping me a lot. However, I got an issue, where I add an Object to the World and for some reason the globalX and globalY variables become 0 instead of giving the real values. This only happens when the CameraFollower is not moving. Any Suggestions?


@max_thure, please start a discussion thread on this. Include what code you have for your world and point out which part refers to the object you are adding and having the problem with. The moving or not moving of the 'mainActor' should not have any bearing on how other objects are added into the world.


Just did so. Still needs to get approved. For anyone that may have an idea: I gave it the topic "Problems with the Scrolling World"


Been trying to use this concept of a scrolling screen in a little project of mine, however I am having trouble getting started, I want the camera to move exactly as the main character does but I'm finding it difficult to get my head around the "addCameraFollower" operation as I would assume this would be the operation to make it follow the main character. Any help on how to structure the operation would be greatly appreciated, as I have a main character as "Wombat" as a sub class of ScrollActor but have no idea what to put in the place of "ScrollActor" or "cameraFollower" in this operation (For reference here is the documentation of the operation itself - addCameraFollower(ScrollActor cameraFollower, int x, int y))


Isn't your wombat exactly what the ladybug is in this project? The 'addCameraFollower' method is not the method which "moves the screen", it adds the actor which will be followed. Open the 'DemoWorld' and check how it was done.

See all comments

Want to leave a comment? You must first log in.

Who likes this?

priscan791 Oldmoe kidi99 askgriff CarlosOlea amin miles7191 Blkhwk93 Jrm1715 -nic- Game/maniac groengeel Cocky USBest CrazyGamer1122 Chantal davemib123