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

What is happening right now?


reply to How do I get to Level 3 on my Game? Need Help Asap:(

By danpost - about 1 hour ago
You need to see what level world the actor is currently in to determine which world to proceed to. This can be solved by adding a second condition in your 'if' statements in the 'MyWorld', 'Level2' and 'Level3' methods: <Code Omitted> As you currently have it coded, the sum of all your level changing method calls, or this: <Code Omitted>will do the same as the following: <Code Omitted>As you can tell, lines 3 and 4 are bumped by line 5 in that 'next' will never contain a Level2 world at line 7 or 8. When you create and set a new world active, you are not changing the world the current actor is in or what its score value would contain. Only the last world setting will take after the current act method has completed its execution.

reply to The sokoban game

By TomazVDSN - about 4 hours ago
danpost, Thank you!, I will take a look !

reply to Get enemy to follow player

By danpost - about 8 hours ago
Nowhere are you using the assignment operator on the 'myTank' field in the enemy class; and being the field is declared 'private', it cannot have been assigned any value elsewhere. So, of course, the object reference 'myTank' will contain a 'null' value. I do not even think you need to have the 'myTank' field in the enemy class. You could just use thi as our enemy class (change name of class from 'enemy' to 'Enemy', as it is conventional to start class names will a capital letter: <Code Omitted>

reply to How do you make something visible forever after being clicked?

By danpost - about 13 hours ago
Every act cycles, line 18 will reset the transparency back to zero and only if it was clicked on that cycle will it show. However, it will show for only about 0.02 seconds, which may preclude it from actually being visible at all since the screen may not be refreshed before becoming transparent again. Basically, you need to set the initial transparency before the act method is called on the House object. That mean that you need to do it either when the House object itself is created or at the time when it is being added into the world; which in turn means that you code it either in the constructor of the class or in the 'addedToWorld' method. Only lines 19 through 23 should be in the 'act' method.

reply to Reading from files

By danpost - about 13 hours ago
The java tutorial pages on Basic I/O should be of some help -- particularly the File I/O pages on the Path class and Reading, Writing and Creating files