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

Comments for Scrolling SuperWorld

Return to Scrolling SuperWorld

danpostdanpost

2012/11/26

Last reminder, if anyone has downloaded this before the last update -- Please, re-download it to correct a snafu. (that is, if you do not have 'removeObject' methods in the SWorld class).
A new version of this scenario was uploaded on Mon Nov 26 18:30:25 UTC 2012 An easy to use super-class for a scrolling world; fully documented. Found and fixed a bug.
A new version of this scenario was uploaded on Sat Dec 01 19:44:11 UTC 2012 A super-class for a scrolling world; fully documented and very easy to use. Normalized the code.
epicm512epicm512

2012/12/2

why does the wombat thing turn red
danpostdanpost

2012/12/2

@epicm512, I have no clue as to what you are concerned with. As far as I know, nothing is turning red.
epicm512epicm512

2012/12/2

the wombat slightly turns red after a little bit
danpostdanpost

2012/12/2

I believe that may be a bit of an optical illusion due the the background not being a consistant color/brightness or maybe, but less likely, the movement of the wombat causes a slight change in its color (or maybe a combination of both). I assure you, however, that the wombat is not changing colors at all.
Game/maniacGame/maniac

2012/12/2

its probably just the background colour messing with your head
Game/maniacGame/maniac

2012/12/2

a bit like an optical illusion does
epicm512epicm512

2012/12/2

ok but it is kinda odd
Game/maniacGame/maniac

2012/12/2

Just noticed danpost said the same thing 3 minutes before me
MatheMagicianMatheMagician

2012/12/17

@danpost and game/maniac, I also noticed the slight tinting red when the wombat turned and remembered a discussion about it here: http://www.greenfoot.org/topics/find/3143#post_3143.
A new version of this scenario was uploaded on Sat Dec 29 21:16:15 UTC 2012 A super-class for a scrolling scenario. Now works with cells greater than pixel-sized (dims rounded up to next odds).
comandodude101comandodude101

2012/12/31

were can I find the scroll code?
Game/maniacGame/maniac

2012/12/31

@MatheMagician now I understand so it is just a bug in JDK 7 for windows xp, nothing to do with optical illusion, that's probably why I didn't notice the tint.
TheStopTheStop

2013/1/7

How do you get the window to follow the character as it moves about?
danpostdanpost

2013/1/7

@TheStop, please open the scenario in Greenfoot and look at the methods the 'act' method calls in the 'SWorld' world class.
DytanothDytanoth

2013/1/11

When I copy the Actors to my project, and add the SWorld & MyWorld Code it won't work, but when I copy the MyWorld from this Scenario to My Scenario it does work.. why won't it work ? super(50, 45, 16,50,60); setMainActor(new Wombat(), 23, 23); mainActor.setLocation(23, 23); GreenfootImage bg = new GreenfootImage("watertexture.jpg"); setScrollingBackground(bg); My world scrolls vertically. But the code above doesn't work in my world, but in the other world it does.. :/
danpostdanpost

2013/1/11

@Dytanoth, maybe I will add another method called 'fillScrollingBackground(GreenfootImage image, int wide, int high) and have it create the full-sized background image required from the 'smaller' image (to allow a 60x60, or whatever size, image to repeat and fill the background of the whole scrolling area).
danpostdanpost

2013/1/11

@Dytanoth, in the meantime, you may have to do that yourself and use the finished image as the scrolling background.
DytanothDytanoth

2013/1/11

I'm not sure I complete understand what you are saying. I've put my scenario http://www.greenfoot.org/scenarios/7217. The world that is active is your world, it's called MyWorl3d. My world is named MyWorld. What do you mean by finished image, and what do i have to do myself :S If you can use some granny language, or even look at my scenario i'd be very gratefull
danpostdanpost

2013/1/11

@Dytanoth, my world did not have an act method in it. By you putting one in your world, it overrides the one in the 'SWorld' super-class. You just need to add the statement 'super.act();' in the 'act' method of your 'MyWorld' world class.
DytanothDytanoth

2013/1/13

Some of my actors, have a specific act on a location. How can I make sure my y-value, becomes a y+scroll value?
danpostdanpost

2013/1/13

@Dytanoth, you should be able to code their movement as normal using move(int) or setLocation(int, int). If using the 'setLocation(int, int)' method during game play, base the int values on the current x and y value of the actor; that is 'setLocation(getX()+xOffset, getY()+yOffset);'. Using absolute locations will not guarantee that the actor will end up in the world where you want because the scrolling world makes
danpostdanpost

2013/1/13

Sorry, did not mean to submit yet -- continuation follows: each location have various universal coordinates.
danpostdanpost

2013/1/13

I guess what I was trying to say was this: When using scrolling, no coordinates are absolute.
A new version of this scenario was uploaded on Sun Jan 13 10:46:23 UTC 2013 A support class for a scrolling world. Added a method for more versitility.
danpostdanpost

2013/1/13

@Dytanoth, I have incorporated the 'fillScrollingBackground' method into my scenario and uploaded it (with some minor comment changes). Hope this helps.
DytanothDytanoth

2013/1/13

That is really helpfull, thanks! You are fantastic!
your codes seem very complex. do you mind explaining it to me? the world, sworld and my world? Thank you. (I'm just a beginner btw, please go easy on me)
danpostdanpost

2013/3/5

I will start a Discussion thread called 'On Scrolling SuperWorld by danpost'. Please ask any specifics as to what you would like to know there. I will start will a general run-down.
where is that discussion thread? thank you again for being so helpful. :)
JetLennitJetLennit

2013/4/1

may i use this for something i want to make?
danpostdanpost

2013/4/1

Sure. After you 'like' it.
danpostdanpost

2013/4/1

@Velociraptor06, I was going to start one, but realized that the scenario was well documented with comments and all that it was not worth starting a new thread. If you have any specific questions about it that are not explained within the documentation, you can start the thread yourself and inform me that you have done so by leaving a comment here.
JetLennitJetLennit

2013/4/1

Thank you!
JetLennitJetLennit

2013/4/1

i'm confused...
danpostdanpost

2013/4/1

@JetLennit, start a discussion thread and explain why you are confused.
JetLennitJetLennit

2013/4/1

I suppose that i get it.... or at least i can use it =)
al_griffal_griff

2013/4/10

Is there a way to have the extra parts of the world populate to the right of your actor? At the moment, the space to scroll is split between the left and right.
danpostdanpost

2013/4/10

@al_griff, are you wanting your main actor to start at the left edge of the scroll world?
danpostdanpost

2013/4/10

My main actor is a Wombat object. To start him on the left edge of the scrollable world, the following can be used in the constructor for the subclass of SWorld: Wombat wombat = new Wombat(); // creates the main actor setMainActor(wombat, 250, 300); // sets as main actor and sets its range of movement GreenfootImage bg = new GreenfootImage("scene.jpg"); // create background image setScrollingBackground(bg); // set the scolling background image int leftOffset = -getUnivX(wombat.getX()); // get -offset from left edge of scroll world wombat.move(leftOffset); // move actor to left edge of scroll world act(); // adjust the scrolling background // add the rest of your objects
danpostdanpost

2013/4/10

@al_griff, the previous post has the code to do what I believe you wanted to do. The last line should probably read 'super.act()' (in case you add an act to your world -- if you do, make sure you call 'super.act()' in it also or the scrolling will not work).
al_griffal_griff

2013/4/12

Ok, thanks for that, I'll add that and see what happens.
JetLennitJetLennit

2013/4/22

Could you check this http://www.greenfoot.org/topics/3459?
al_griffal_griff

2013/4/23

I'm getting problems with the int leftOffset = -getUnivX(player.getX()); Greenfoot is saying that it cannot find the symbol.
danpostdanpost

2013/4/23

Are you placing this code in your sub-class of SWorld?
al_griffal_griff

2013/4/23

Yes.
danpostdanpost

2013/4/24

Maybe you should start a discussion, and explain what Greenfoot says it cannot find and give the code around where that highlighted statement is.
A new version of this scenario was uploaded on Fri Apr 26 05:04:38 UTC 2013 Added some helper methods.