@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);'
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.
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.
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.
@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.
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').
@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).
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?
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).
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.
@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.
@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.
@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.
@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.
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.
@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.
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!
@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..
2013/5/10
2013/5/10
2013/5/10
2013/5/10
2013/5/10
2013/5/10
2013/5/14
2013/5/14
2013/5/14
2013/5/14
2013/5/14
2013/5/14
2013/5/14
2013/5/14
2013/5/14
2013/5/14
2013/5/14
2013/5/31
2013/6/1
2013/6/3
2013/6/3
2013/6/3
2013/6/4
2013/7/26
2013/10/23
2013/10/23
2013/10/23
2013/10/23
2013/10/28
2014/7/15
2014/7/15
2014/7/15
2014/7/15
2014/7/15
2014/7/15
2014/7/15
2014/7/15
2014/7/16
2014/11/24
2014/11/24
2014/12/4
2015/1/29
2015/3/12
2015/3/12