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

Comments for Scrolling world

Return to Scrolling world

danpostdanpost

2012/9/15

@jhadad, start a new discussion on this and explain exactly what you are trying to do (what you [i]want[/i] to happen), as well as what is currently happening. Also, supply the code in question. The more specific and detailed you are the better to reach a working solution quickly.
A new version of this scenario was uploaded on Sat Sep 29 15:17:13 UTC 2012 Added the isCameraFollower method in ScrollActor: you can now know you're added as a camera follower or not.
A new version of this scenario was uploaded on Sat Sep 29 15:20:13 UTC 2012 Changed the documentation a little bit.
gusbus123gusbus123

2012/10/10

you should make it so the bug can get to the edge of the world, not stop in the middle of it. Makes a bit more sense. other than that its great :)
gusbus123gusbus123

2012/10/10

i might do somthing like this with different atributes, if i do then just saying i havnt looked at your code.
SPowerSPower

2012/10/10

You know, about the bug not reaching the end: it's just a demo. I'm not going to make a really big demo, just a little one to show you how the basics work. And anyway, I'm not going to improve the demo here on my birthday, maybe this sunday or next week (if I do it anyway)
-nic--nic-

2012/10/16

nice demo very smooth
SPowerSPower

2012/10/16

Thanks! I hope you can use it if you want!
-nic--nic-

2012/10/16

thinking of making a racing scroler
SPowerSPower

2012/10/16

Ok, if you need help, I'll help you (as always :) )
-nic--nic-

2012/10/16

thanks
A new version of this scenario was uploaded on Wed Oct 17 14:21:28 UTC 2012 -Improvements in ScrollWorld: cell sizes bigger than 1 will now also work fine! -Removed initializeBackground -Added the method setNewBackground which replaces setBackround -Changed the name of moveCameraTo to setCameraLocation -Small speed improvements -Some little documentation changes
Game/maniacGame/maniac

2012/10/17

I've messed around with it and its pretty good
Game/maniacGame/maniac

2012/10/17

Although I might not use it for any scenarios because I am more used to Busch2207's
SPowerSPower

2012/10/17

Thanks and, I don't wanna steal a fan of Busch's scenario but, what makes his engine better than mine?
MatheMagicianMatheMagician

2012/10/17

Sorry it took me so long to accept you into the scrolling collection.
Game/maniacGame/maniac

2012/10/18

you can choose where in the world the screen is placed
SPowerSPower

2012/10/18

You can also do that with mine: use the setCameraLocation method. Didn't you read the documentation? O.O
-nic--nic-

2012/10/18

im using your scrolling world demo and im having trouble using a back ground but what would be the smallest compatable file for a backgroung for greenfoot?
SPowerSPower

2012/10/18

1 by 1 pixel
-nic--nic-

2012/10/18

ive scrapped that im going to start on android
Game/maniacGame/maniac

2012/10/18

oh I didn't see that part I was expecting it to be it the world constructor
SPowerSPower

2012/10/19

@Game/maniac If I would've put it in the world's constructor, then you could only set it once: not so handy.
A new version of this scenario was uploaded on Sun Oct 21 12:38:42 UTC 2012 -Memory optimisation -Changed the name of the moveCameraForward method to moveCamera
A new version of this scenario was uploaded on Tue Oct 23 15:35:52 UTC 2012 Bug fix in ScrollWorld
Blkhwk93Blkhwk93

2012/10/30

Quick question, your scrolling world code has been very helpful (thanks!), I have been trying to work with your removeObject method because I'm trying to "collect" keys and cannot figure out how to send it a "key" when my guy walks over it. So I can't figure out how to determine a "Key" as a ScrollActor object to send to the method. Thanks for the help.
SPowerSPower

2012/10/30

First, thanks for the like :), and I'm glad it is helpful! The second, to get an object of the class Key which intersects another object, use the method getOneIntersectingObject(Key.class). Example: [code]// in the class which wants to interact with keys: Key key = (Key) getOneIntersectingObject(Key.class); // now you can use the key object[/code] Is this what you mean?
A new version of this scenario was uploaded on Tue Oct 30 15:18:11 UTC 2012 -Added 2 new methods in ScrollActor: added turnTowardsGlobalLocation and turnTowardsCameraLocation -Overwrote move in ScrollActor -Speed optimisation in ScrollActor
Blkhwk93Blkhwk93

2012/10/31

:D aaahhhh ok yep, I get it now. Yep works just like I wanted! Thanks so much!! (I was wondering why you had the (Key) part in there but I realized when I complied and said it expected Key but found greenfoot.Actor, found out the (Key) was for the parse :) lol) Thanks again.
A new version of this scenario was uploaded on Thu Nov 01 14:53:07 UTC 2012 Speed optimisation
alejandroalejandro

2012/11/13

sfgdsfadsfasdfsafasfasfafasa
A new version of this scenario was uploaded on Thu Nov 15 16:00:05 UTC 2012 -Made some code improvements in ScrollWorld -Made some little speed improvements in ScrollActor
nachocabnachocab

2012/11/17

Thanks for this code, very usefull for other projects
SPowerSPower

2013/2/21

The 'relationship' is that the fullWidth and fullHeight are the width and height of the greenfootimage 'bigBackground'. That represents the background, which is as big as the full world: that is also what moves when you move the camera. And the background you give can be bigger than the viewport.
CarlosOleaCarlosOlea

2013/4/24

i have an error execution when my camerafollower is trying to remove one object and the error display this: java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:663) at greenfoot.Actor.getX(Actor.java:157) at ScrollWorld.setCameraLocation(ScrollWorld.java:243) at ScrollWorld.moveCamera(ScrollWorld.java:302) at Bug.act(Bug.java:30) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) i dont know if what i am doing wrong with the method please help!!!
m_p_v_13m_p_v_13

2013/5/23

SPower, did you mean to leave out the source?
A new version of this scenario was uploaded on Sat Aug 17 10:54:14 UTC 2013 Improved the removeObject method in ScrollWorld
A new version of this scenario was uploaded on Tue Aug 20 10:12:48 UTC 2013 Bug fixes
slyph88slyph88

2013/10/3

this scenario really help me a lot.. but i have some question sir.. here is my assumption from reading ur API public ScrollWorld(int width, => width of the scroll camera int height, => height of the scroll camera int cellSize, int fullWidth, => map width int fullHeight) => map height and here is my code: super(300, 300, 1, 1000,1000); => i made a 300x300 scroll camera with a 1000x1000 map and i try to put object balok balok = new balok(); addObject(balok, 100, 100); i thought the object is within my map, and my main actor can reach it.. but whenever my actor tried to go there.. it seems i already reach my 1000x1000 limit map.. and from trying a lot.. i get the calculation of the real limit map.. real limit map = 1000x1000 - (300/2.5) x (300/2.5) so actually if i input 1000x1000 then i only get 880x880.. and the conclusion now, i should place the object in 880x880 to be reachable.. is this some kind of bug? and why whenever i bump the map limit, the background map changes a little, but after i backward a little, it changes to normal again.. thx a lot nb: sry for my english
SPowerSPower

2013/10/4

I think you've got the problem where the edges of the camera cannot go out of the world. So if you move to the left, it will stop when it's at 150 x. The same for the other directions.
A new version of this scenario was uploaded on Thu Oct 31 20:11:27 UTC 2013 Bug fixes in the ScrollActor class
A new version of this scenario was uploaded on Thu Oct 31 20:15:25 UTC 2013 Fixed another bug in ScrollActor
A new version of this scenario was uploaded on Fri Nov 01 16:26:32 UTC 2013 Fixed a bug where removing a ScrollActor would case an exception
TaviTavi

2013/11/1

Thanks again :) .
oscarreksoscarreks

2015/10/1

I used this in a small class assignment. ScrollWorld and ScrollActor simplified a lot of stuff. Many thanks! You can find it here: http://www.greenfoot.org/scenarios/15036
max_thuremax_thure

2017/2/2

I am using your Scenario in one of my School Projects and it is helping me a lot. However, I got an issue, where I add an Object to the World and for some reason the globalX and globalY variables become 0 instead of giving the real values. This only happens when the CameraFollower is not moving. Any Suggestions?
danpostdanpost

2017/2/4

@max_thure, please start a discussion thread on this. Include what code you have for your world and point out which part refers to the object you are adding and having the problem with. The moving or not moving of the 'mainActor' should not have any bearing on how other objects are added into the world.
max_thuremax_thure

2017/2/8

Just did so. Still needs to get approved. For anyone that may have an idea: I gave it the topic "Problems with the Scrolling World"
EmelgaEmelga

2017/11/23

Been trying to use this concept of a scrolling screen in a little project of mine, however I am having trouble getting started, I want the camera to move exactly as the main character does but I'm finding it difficult to get my head around the "addCameraFollower" operation as I would assume this would be the operation to make it follow the main character. Any help on how to structure the operation would be greatly appreciated, as I have a main character as "Wombat" as a sub class of ScrollActor but have no idea what to put in the place of "ScrollActor" or "cameraFollower" in this operation (For reference here is the documentation of the operation itself - addCameraFollower(ScrollActor cameraFollower, int x, int y))
Super_HippoSuper_Hippo

2017/11/23

Isn't your wombat exactly what the ladybug is in this project? The 'addCameraFollower' method is not the method which "moves the screen", it adds the actor which will be followed. Open the 'DemoWorld' and check how it was done.