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

2019/4/6

Illegal State Exception

1
2
AdiBak AdiBak

2019/4/10

#
Hi, When I play my game for a while, it starts slowing down and the actors move more slowly. I noticed that this happens when I reach the score 6000. I tried adjusting the speed bar to make it faster but it won't work. I'm not sure why this is happening (maybe it has to do with the fact that I currently have 19 subclasses of actor), so can someone please help? Thank you. Here's the scenario with source code: https://www.greenfoot.org/scenarios/23673
Super_Hippo Super_Hippo

2019/4/10

#
I am a bit lost in your code to be honest. What is the purpose of the State class and its subclasses? Why don't you just put that in the world subclass? It is also weird that you have several variables in which you save the world, but you still use 'getWorld' instead most of the time. I couldn't reach 6000 points yet, so I have no clue what is causing it. Is anything special happening at 6000? Lag usually happens if too many actors are in the world at the same time. For example if actor A is spawning another actor A every act cycle, then the scenario will basically stop after a second. By the way, when you shoot and you don't hit anything (it moves out of the screen on the top), you can never ever shoot again. The y-coordinate is 0 at the top not at the bottom. You have to adjust the shouldRemoved method in the Laser class. For a better gaming experience, try (or at least think about) the following suggestions: - always move the player to the X coordinate of the mouse no matter what, follow Y only to a certain "line" (for example like this)
        MouseInfo m = Greenfoot.getMouseInfo();
        if (m != null)
        {
            setLocation(m.getX(), Math.max(m.getY(), getWorld().getHeight()*4/5));
        }
- this line (or the area to which walking is restricted) should be visible. Otherwise it seems quite weird why your moving stops without any apparent reason
You need to login to post a reply.
1
2