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

mjrb4's Comments

Back to mjrb4's profile

Ah, you seem to have solved the error :-) The levels work nicely, though the hardest is pretty impossible! Also, the game over screen appears immediately so you can't see your score - any chance of changing that?
Not bad at all! It seems like it's possible to never lose by just staying in one place and holding down space though - perhaps you could alter it slightly to make it a bit harder? An upper limit on the amount of health you can have might also be an idea :-)
You don't need to create another class, just declare the fields at the top of your existing class. Then as you said it's just a case of calling setImage to display the image you want. When images are created statically they're only created once per class, not once per instance of that class - and in this case that means they're only loaded once, not once for every letter that's created. That's probably what's happening with them at the moment, hence the lag!
Note that if fields are constants (final), it's ok to have them as public. Just thought I'd jump in there quickly because yes, fields should usually always be private - this is the one exception where it's ok to do otherwise!
Just declare them as normal fields, but put static in the declaration. You may also want final in there (this stops them being changed.) So it'd be something like: public static final GreenfootImage imageA = new GreenfootImage("images/a.png");
Nice - is it possible to kill the big scary guys? Or are you just meant to let them go past? Also, I'm guessing the jumping at the top is being used to stop the turtle going over a certain height, but you can accomplish that without the jumping quite easily :-) Something like if(getY()<40) setLocation(getX(), 40); should do the trick. (Adjust 40 accordingly.) Michael
The atWorldEdge method shouldn't cause any errors if you haven't modified it from the mover class - what error are you getting?
In terms of the gameplay, you might also want to start off a bit slower - I wouldn't say I'm a slow typer but I'm struggling to get more than 20! (Or perhaps I am just a slow typer...) some of the letters also sometimes appear a bit off the bottom of the screen, so you might want to put some more code in to prevent that happening (it makes it hard to see what they are.)
The game may indeed end, but that doesn't change the fact that there's a problem with it! I'm getting the following when letters reach the other side of the screen: java.lang.StackOverflowError at java.lang.Math.floor(Unknown Source) at greenfoot.Actor.getPaintX(Actor.java:510) at greenfoot.Actor.getXMax(Actor.java:475) at greenfoot.Actor.getWidth(Actor.java:167) at greenfoot.Actor.intersects(Actor.java:630) at greenfoot.ActorVisitor.intersects(ActorVisitor.java:30) at greenfoot.collision.GOCollisionQuery.checkCollision(GOCollisionQuery.java:40) at greenfoot.collision.ibsp.IBSPColChecker.checkForOneCollision(IBSPColChecker.java:755) at greenfoot.collision.ibsp.IBSPColChecker.getOneObjectDownTree(IBSPColChecker.java:786) at greenfoot.collision.ibsp.IBSPColChecker.getOneIntersectingObject(IBSPColChecker.java:1070) at greenfoot.World.getOneIntersectingObject(World.java:731) at greenfoot.Actor.getOneIntersectingObject(Actor.java:751) at bar.stopSimulation24(bar.java:419) at bar.stopSimulation24(bar.java:425) at bar.stopSimulation24(bar.java:425) at bar.stopSimulation24(bar.java:425) at bar.stopSimulation24(bar.java:425) at bar.stopSimulation24(bar.java:425) The images will probably work fine on your computer because it'll take next to no time to load them, on the gallery it's different. You can declare them as static fields instead at the top of your class, and then just reference the images from there - that should reduce the lag a lot.