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

2017/12/3

how to scroll?

kevoncmlc2000 kevoncmlc2000

2017/12/3

#
i'm working on a mario game code which has a big background which is really long, about 1000*100 with 6*6 pixels. i've got pretty much everything down, except i don't know how to program the scrolling mechanism where mario gets to a certain x and the background scrolls to the right. it cannot scroll left, like super mario bros. i tried to use danpost's scrolling code but that failed too. can someone help me out?
danpost danpost

2017/12/3

#
kevoncmlc2000 wrote...
i tried to use danpost's scrolling code but that failed
Which scrolling code of mine failed?
kevoncmlc2000 kevoncmlc2000

2017/12/3

#
im not saying its a complete failure im just saying for my particular code it didn't work. it was the arrow key scrolling code and the scroller class never compiled
danpost danpost

2017/12/3

#
kevoncmlc2000 wrote...
im not saying its a complete failure im just saying for my particular code it didn't work. it was the arrow key scrolling code and the scroller class never compiled
If you are referring to the Scroller class that my tutorial and Scroller class demo work with, then it should compile. That is to say, the class should not be modified and should compile as given.
kevoncmlc2000 kevoncmlc2000

2017/12/3

#
so here's the url for the game i was talking about, maybe someone can go in there and manipulate the code to get the world to scroll? thx http://www.greenfoot.org/scenarios/20444
danpost danpost

2017/12/3

#
In the first line of your act method in the Background class, you are setting the value of '-5' to 'imageCount'; but, what you want to do is decrease its value by '5'.
kevoncmlc2000 kevoncmlc2000

2017/12/4

#
yeah that scrolls the background but i want to basically scroll the entire world including all the actors
danpost danpost

2017/12/4

#
kevoncmlc2000 wrote...
yeah that scrolls the background but i want to basically scroll the entire world including all the actors
Then you need to iterate through all actors in the world and shift the position of each one (except for text displays).
kevoncmlc2000 kevoncmlc2000

2017/12/4

#
ill try it. thanks
danpost danpost

2017/12/4

#
kevoncmlc2000 wrote...
ill try it. thanks
Keep in mind that actors leaving the viewable world which are no longer needed should be removed from the world to prevent possible lag.
You need to login to post a reply.