Sign Up, Lost Password
Comments for tut-access-p1
Return to tut-access-p1
A new version of this scenario was uploaded on Fri Jan 14 04:54:53 UTC 2011 Fix a bug in the Counter class.
A new version of this scenario was uploaded on Tue Jan 18 04:57:18 UTC 2011 Change the design a little.
A new version of this scenario was uploaded on Tue Jan 18 09:05:27 UTC 2011 Re-added source code.
It's... meant... to... be. It's... a... tutorial.
The code was great! thanks! Do you know to set a counter limit with a success message or perhaps a time limit? Thanks!
Please ask on the forum (the "Discuss" link). :)
okay thanks mate
Could you explain to me what this line of code does: Space spaceWorld = (Space) getWorld(); What do the parentheses mean when you put them around "(Space)"?
'getWorld' return a World object (not particularly a 'Space' object; though it could be one). That is what '(Space)' does. It makes it a 'Space' object. This is called 'typecasting' and it informs the system to look in the 'Space' class for any methods or fields referenced with the World object. Any methods or fields that are declared in the 'Space' class would not be found otherwise.
davecoolkid: as danpost says 'getWorld()' returns a 'World', but in the line of code you specify the variable is of type 'Space'. The compiler doesn't let you assign just a World to a Space variable (even though the World *might* be a Space). In this case we know that the world definitely *is* a space, so we use this type cast to tell the compiler that it's ok. A simple experiment you can do is to remove the type cast (the "(Space)" part) and try to compile. What happens?
Thanks danpost and davmac for the clarification helped me out a lot.
Geez, i made a game myself much like this (as in space and stuff) and what suprised me after checking this page is that the space icon that is used here is IDENTICAL. It doesn't help either that the theme is much the same too. I'll just hope my teacher will believe that it is still original XD. Well, atleast i have a fancy movement engine.