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

Comments for Negative Color

Return to Negative Color

A new version of this scenario was uploaded on Sun Oct 06 19:09:24 UTC 2013 Changed thumbnail
A new version of this scenario was uploaded on Sun Oct 06 19:15:23 UTC 2013 Source
I get the scroll-bars on the sides when I try viewing this. :\
I know why, you used getKey(), but didn't look for getKey() to equal null. Assign getKey() to a variable, then in your if statement, write this: "if (key != null & key.equals("space"))".
Busch2207Busch2207

2013/10/6

@FlyingRabidUnicornPig: I don't see any problem with the getKey method: He wrote: 'Greenfoot.getKey() == "space"' and if getKey() returns 'null', this query will return false, because this only checks, whether this two inputs are the same! He hasn't written 'Greenfoot.getKey().equals("space")', which would throw an error, when 'getKey()' returns 'null', because then, the compiler trys to run the method from an object, which don't exists. ;)
Oh, but how come I keep getting null pointer exceptions?
Busch2207Busch2207

2013/10/6

He wrote: UserInfo.getMyInfo().getUserImage() and sometimes, when you're not logged in or when there's a login-mistake, UserInfo.getMyInfo() returns 'null' and then an error occures! :)
Well, I'm logged in... I'll log in and back out and see if that works.
Not working still...
Busch2207Busch2207

2013/10/6

Maybe try to restart your browser. That always works for me! :)
Other scenarios that use my image work, just not this one... I'll try resetting browser as well.
Got the scrollbars, instead of an error.
JetLennitJetLennit

2013/10/6

Try zooming out and zooming back in in your browser
Entity1037Entity1037

2013/10/7

Then negative color of my blue fire in my Profile Pic is red fire... interesting...
SPowerSPower

2013/10/7

About the getKey stuff, I think if ("space".equals(Greenfoot.getKey()) is best, because the thing you check on is never null and is capable of being compared to something that is null. And I think if (Greenfoot.getKey() == "space") compares the pointers, because the 2 Strings are instances, not data types like integers, so this will always return false. But I may be wrong, because I can't run the scenario on this device and therefore don't know if it will work :)
Busch2207Busch2207

2013/10/7

In older Java-versions 'Greenfoot.getKey() == "space"' always returned wrong. But in the current version, this will return true, if both strings are the same! :)
SPowerSPower

2013/10/8

Oh, ok, thanks for the info!