@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.
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)
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
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?
@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
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.
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
: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
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
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.
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!!!
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
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
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
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?
@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.
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))
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.
2012/9/15
2012/10/10
2012/10/10
2012/10/10
2012/10/16
2012/10/16
2012/10/16
2012/10/16
2012/10/16
2012/10/17
2012/10/17
2012/10/17
2012/10/17
2012/10/18
2012/10/18
2012/10/18
2012/10/18
2012/10/18
2012/10/18
2012/10/19
2012/10/30
2012/10/30
2012/10/31
2012/11/13
2012/11/17
2013/2/21
2013/4/24
2013/5/23
2013/10/3
2013/10/4
2013/11/1
2015/10/1
2017/2/2
2017/2/4
2017/2/8
2017/11/23
2017/11/23