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

Comments for Scrolling SuperWorld

Return to Scrolling SuperWorld

A new version of this scenario was uploaded on Fri Apr 26 05:09:39 UTC 2013 Added some helper methods.
A new version of this scenario was uploaded on Fri Apr 26 11:38:46 UTC 2013 Added comments/documentation for the newly added methods.
Hey danpost, could you explain the UnviX and UnviY methods? I'm not exactly sure what they are supposed to do.
danpostdanpost

2013/5/10

@FlyingRabidUnicornPig, you enter a window coordinate in the parameter and it returns the universal coordinate. The top-left corner of the window in window coordinates is always (0, 0), no matter what scrolling has taken place; however, in universal coordinates, (0, 0) is always the top-left corner of the scrolling area. So, for example, if you wanted to know how far the background can scroll to the left in order to get to the left edge of the universe (or the left-most scrolling limit), you can use 'int remainingScrollToLeft = getWorld().getUnivX(0);'
Thank you!
What if I wanted to get the full width?
And I'm also getting a null pointer exception when trying to use getUnivX.
danpostdanpost

2013/5/10

Start a discussion and show your code.
A new version of this scenario was uploaded on Fri May 10 03:12:33 UTC 2013 'getUnivX' and 'getUnivY' can now be used without a background image being set.
A new version of this scenario was uploaded on Sat May 11 19:51:03 UTC 2013 Added methods to return the height and width of the scrolling area.
Entity1037Entity1037

2013/5/14

How do you make an exception for scrolling like for health meters?
danpostdanpost

2013/5/14

Same way I added the Counter object into the world in this scenario.
Entity1037Entity1037

2013/5/14

Oh duh, I feel stupid now. Thanks.
Entity1037Entity1037

2013/5/14

But wait, how do you do this from an actor? I'm sorry for all of the questions, but I'm only in Computer Science 1 and I don't know as much as I'd like to.
danpostdanpost

2013/5/14

Just prefix it with 'getWorld().'.
Entity1037Entity1037

2013/5/14

I do, but it doesn't let me use a boolean parameter at the end. I think it's calling the built in "addObject" method, and not the one you made.
danpostdanpost

2013/5/14

Ok. Prefix with '((SWorld)getWorld).'.
danpostdanpost

2013/5/14

That was supposed to be '((SWorld)getWorld()).'.
Entity1037Entity1037

2013/5/14

Ok nevermind, you just do ((SWorld)getWorld()).addObject(new Health1(),30,health,false);
Entity1037Entity1037

2013/5/14

I figured it out before I saw your comment. Thank you anyway.
Entity1037Entity1037

2013/5/14

I figured it out before I saw your comment. Thank you anyway.
Homicdle_mothHomicdle_moth

2013/5/31

Why does the wombat slide around? is there a way to prevent that from happening?
danpostdanpost

2013/6/1

@Homicdle_moth, the movement could have been coded hundreds of ways; it is just the way I chose to do the movement for it in this case.
RonMexicoRonMexico

2013/6/3

First of all, great scenario - implementing it has been a lot of help with my platforming game. I've got a bit of a problem with creating platforms for my world. I figured the easiest way to add platforms to my world would be by instantiating a 3000x400 world where I'd be able to add a bunch of platform objects all over the workspace, saving the world when I've placed them where I want them. After that, I change the parameters for the world object by instantiating the scrolling world with 400x400 dimensions. Everything runs fine; all platforms that I've added to the world are placed successfully via the prepare() method of the SWorld subclass, but the problem I'm facing is trying to get all of my platforms to be prepared from the far left of the world boundary as opposed to the centre. I've noticed that you've provided a means to spawn the player at the far left of the world and that works fine. I'm just wondering how I'd be able to do the same thing with platforms. I hope this makes sense. Many thanks in advance.
danpostdanpost

2013/6/3

@RonMexico, you could set the main actors location to anywhere and execute 'super.act();' to view that area. Then add the actors you want there and 'Save the World'. Then change the prepare call and method call to 'prepareA' (next 'prepareB', etc.) and after the prepareA call reset the actors location somewhere, repeating the process.
danpostdanpost

2013/6/3

The middle line in the last post should read 'Then change the prepare call and prepare method name to 'prepareA' ...'. (replacing 'method call' with 'method name').
RonMexicoRonMexico

2013/6/4

@danpost - Thank you very much for your help. It turns out calling super.act() solved my problems. :)
SparkySparky

2013/7/26

lol,im your 101st follower
A new version of this scenario was uploaded on Sun Oct 13 21:54:01 UTC 2013 Eliminated a lag producer.
BaenefinBaenefin

2013/10/23

I am trying to implement this into my source. I get an error on line 239. "Incompatible types"
danpostdanpost

2013/10/23

@Baenefin, I do not think that is possible. Either you gave the wrong line number, the error was not in the SWorld class or you edited the class (which I specifically requested not be changed in any way).
BaenefinBaenefin

2013/10/23

Ok the lines may differ, but i Copy your code and have not altered it. That's why I was surprised. It is in private void scrollObjects(). The for loop. for(Object obj : genActors) gives me the Incompatible types. Could that be that there is something wrong with my subclass of SWorld?
danpostdanpost

2013/10/23

It is very possible that the problem resides in your subclass of SWorld. Start a discussion thread and post your code.
A new version of this scenario was uploaded on Mon Oct 28 14:28:38 UTC 2013 Simplified some code and made it easier to use (scrolling objects are now added using scroll area coordinates instead of world coordinates).
danpostdanpost

2013/10/28

Need feedback on latest change. Good/bad? Request that anyone who has used this previously, try this version and reply.
I have addressed you in one of your other posts. I asked you to post the code for the scrolling superworld. Could you please do the same for this one as well? And also could you post it in reply to my comment so that I get a notification? Thank you and sorry for any inconveniences.
danpostdanpost

2014/7/15

@greenfootuserthegreat, both this and the other scrolling scenario are open source. You can click on the big green 'Open in Greenfoot' button, with the green foot over the left side of it, to open or download the scenario. It is located just above and to the right of the scenario window.
@danpost, I have tried that multiple times. But my computer does not support external Greenfoot projects. I'm sorry.
danpostdanpost

2014/7/15

@greenfootuserthegreat, after clicking the 'Open in Greenfoot' button, select the 'Save' option. This will put a copy in your downloads folder. From there you can cut/paste it to your scenarios folder and then open it with the greenfoot application (which will create an unzipped folder of the scenario from which you can get the class codes).
@danpost, the thing is that when I click on the "Open in Greenfoot," it downloads and says that there is no application to open it in. I have been trying many different ways to see if I can make it work, but it is not working.
By the way, your projects are brilliant.
danpostdanpost

2014/7/15

@greenfootuserthegreat, do you not have greenfoot installed on your system? if so, you should have a 'greenfoot/scenarios' folder. Cut/paste the downloaded 'gfar' file into that scenarios folder. Open your greenfoot application. From the menubar, select 'Scenarios/Open...'. Choose the 'gfar' file. That opens it.
@danpost, that's what I do, but it does not accept Greenfoot as an application. Thanks for your time though.
danpostdanpost

2014/7/16

@greenfootuserthegreat, the 'gfar' file is basically a zipped folder. You can unzip it with any standard tool and then view the 'java' files with any text editor.
DillybarDillybar

2014/11/24

Let me start off by saying that I love this code, thank you very much for it. However, I am having some issues with the main actor. When the world loads, I have a main actor and it functions perfectly. However, when I remove the main actor and add a new one (defining it as main actor) it is put back on the starting screen instead of where the old main actor was. I was hoping you would be able to help, thanks.
danpostdanpost

2014/11/24

@Dillybar, please start a discussion thread on this issue, I will be able to respond and post code there more easily. However, it will probably be a couple of hours or so as I am pressed for time atm.
Trex9513Trex9513

2014/12/4

this afro
getreidesgetreides

2015/1/29

Hello Danpost, this is really great stuff, I'm going to use it for a project I've been working on for the last months (see a version of the project in a very early stage on http://www.greenfoot.org/scenarios/12057). Keep up the great work!
EduandErnstEduandErnst

2015/3/12

@danpost is there a known bug with .png files as a scrolling background? Or am I doing something wrong? When I place .png file as background and move the pic gets blended all over but when I replace it with the exact same pic as .jpg it works perfectly..
danpostdanpost

2015/3/12

@EduandErnst, I am not quite sure what you mean. Maybe you can start a discussion thread and link an image of what you trying to describe.