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.
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.
@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).
@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.
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.. :/
@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).
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
@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.
@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
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.
@Dytanoth, I have incorporated the 'fillScrollingBackground' method into my scenario and uploaded it (with some minor comment changes). Hope this helps.
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)
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.
@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.
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.
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
@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).
2012/11/26
2012/12/2
2012/12/2
2012/12/2
2012/12/2
2012/12/2
2012/12/2
2012/12/2
2012/12/2
2012/12/17
2012/12/31
2012/12/31
2013/1/7
2013/1/7
2013/1/11
2013/1/11
2013/1/11
2013/1/11
2013/1/11
2013/1/13
2013/1/13
2013/1/13
2013/1/13
2013/1/13
2013/1/13
2013/3/5
2013/3/5
2013/3/6
2013/4/1
2013/4/1
2013/4/1
2013/4/1
2013/4/1
2013/4/1
2013/4/1
2013/4/10
2013/4/10
2013/4/10
2013/4/10
2013/4/12
2013/4/22
2013/4/23
2013/4/23
2013/4/23
2013/4/24