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

2011/11/6

Sidescrolling concept

darkmist255 darkmist255

2011/11/6

#
Hey, just a quick question. What is the concept behind how to make something sidescrolling. Should I have a long image that it scrolls through left to right, or a series of images? And how would I go about doing this.
giordanno92 giordanno92

2011/11/6

#
You can make a side scrolling by using a very large image (direct solution for the problem) For this solution you can use 2 GreenfootImages, one for the image directory and other for the changing background, example: img2.drawImage(img1, -230, 0); this is a solution I found and use on my projects. Keep in mind that the image can't be too big or you'll get an error (Java heap space), and by big I mean the size in bytes. Or you can make using tiles, which is pieces of images that compose the scene. I find this solution a bit harder, since it demands more code but saves a lot of bytes on the final jar. There are scenarios in the gallery that show moving background. - giordanno92
Duta Duta

2011/11/12

#
Related to this, to stop actors getting stuck at the edges of the world, change the world constructor to "super(600, 600, 1, false)" (replacing "super(600, 600, 1)" - this assumes a 600x600 world, which is the default size)
Duta Duta

2011/11/13

#
As I noticed a few posts about side-scrolling on the forum, I've made this quick scenario which should hopefully help: http://www.greenfoot.org/scenarios/3767
darkmist255 darkmist255

2011/11/13

#
In "super(600, 600, 1, false)" what does "false" mean? Does it mean that we just "see" 600x600? Nevermind just read your comment in the source.
DoomN1nja DoomN1nja

2012/11/17

#
It means that actors can go 'out' of the world, basically so you can't see them, as opposed to them getting stuck at the edge
You need to login to post a reply.