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

2013/4/26

Scrolling World problem with removing objects

CarlosOlea CarlosOlea

2013/4/26

#
i have a problem when my scroll actor bug removes every Scroll Actor and if i move the bug. throw an error explaining there is no bug in the world and really i donĀ“t know what to do because the bug is still there please help there is the project i chose http://www.greenfoot.org/scenarios/5806 and i put my code in the act of the bug for remove the every Scroll Actor public void checaAnillo() { Actor anillo; anillo=super.getOneIntersectingObject(ScrollActor.class); if(anillo!=null) { ScrollWorld mundo; mundo=super.getWorld(); mundo.removeObject(anillo); }
danpost danpost

2013/4/26

#
Sounds to me like you set one bug object as the scrolling actor bug and are trying to move a different bug object that was not placed in the world. Check the code where you created/set the bug to a scrolling object/camerafollower. Search that class for 'new Bug' and see how many times it occurs (it should only occur once).
CarlosOlea CarlosOlea

2013/4/26

#
thanks for post, check this is the code i put in the class DemoWorld and i think there is no problem with the constructor and adding the camera follower (the bug) and the other classes because the autor of the project puts the code. public class DemoWorld extends ScrollWorld { Bug bicho=new Bug(); /** * Constructor for objects of class DemoWorld. */ public DemoWorld() { super(600, 400, 1, 1000, 700); addObject(new Mushroom(), 100,100); addObject(new Apple(), 700, 300); addObject(new Rock(), 400, 254); addCameraFollower(bicho, 0, 0); addObject(new FPS(), 85, 15); // FPS isn't a subclass of // ScrollActor, so it will looklike it's a camera follower } }
danpost danpost

2013/4/26

#
I will take a look at the scenario. I cannot promise I will be able to figure it out as I am somewhat unfamiliar with that ScrollWorld class and how it works with the ScrollActor class. Oh, that is to the Scrolling World scenario, I thought the link above was to your scenario. I guess I will not be able to look at your code unless you either post it here or comment out those areas that are causing errors and upload the scenario on the site. If you do comment out those areas, note which areas they are so I can uncomment them and work with it.
danpost danpost

2013/4/26

#
If you do post your code here, prefix it with and postfix it with .
danpost danpost

2013/4/26

#
OK, there is no problem with the way the world is constructed. Please post your Bug class code.
danpost danpost

2013/4/26

#
Sorry, wrong discussion.
You need to login to post a reply.