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

2017/1/30

Scenario not 'Run'ning

1
2
Super_Hippo Super_Hippo

2017/1/31

#
For some reason, when first starting the scenario, it gave me some score, but not showing on the highscore table when pressing H. After restarting, it showed me as well.
Nosson1459 Nosson1459

2017/2/1

#
I guess that's what I was talking about in my previous post. I'm using the Greenfoot ScoreBoard.
Super_Hippo Super_Hippo

2017/2/1

#
It happens because you create the Scoreboard right at the beginning and when adding it to the world, it is not getting updated. Create a new Scoreboard after line 46 in the MyWorld class:
score = new ScoreBoard(getWidth(), getHeight());
Nosson1459 Nosson1459

2017/2/2

#
Nosson1459 wrote...
What is "userIcon.png", is it something that I'm supposed to have or is it just there as an example and I'm supposed to put an image there.
Am I able to do things with my scenario that the users can't since I made it or do I have to use it like everybody else and I'm not able to give myself privileges? (I guess I can technically do:
UserInfo myInfo = UserInfo.getMyInfo();
if (myInfo.isStorageAvailable() && myInfo.getUserName().equals("Nosson1459"))
{
    // things for me
}
but is there any other way or a more official way (this will only work if two people CAN'T have the same UserName which I'll assume they can't)?
Nosson1459 Nosson1459

2017/2/5

#
Nosson1459 wrote...
Nosson1459 wrote...
What is "userIcon.png", is it something that I'm supposed to have or is it just there as an example and I'm supposed to put an image there.
Am I able to do things with my scenario that the users can't since I made it or do I have to use it like everybody else and I'm not able to give myself privileges? (I guess I can technically do:
UserInfo myInfo = UserInfo.getMyInfo();
if (myInfo.isStorageAvailable() && myInfo.getUserName().equals("Nosson1459"))
{
    // things for me
}
but is there any other way or a more official way (this will only work if two people CAN'T have the same UserName which I'll assume they can't)?
Super_Hippo Super_Hippo

2017/2/5

#
I think the userIcon image is not needed. 'getUserImage()' gets the image automatically. There is no method which returns "if player == creater of the scenario" but you can do it with comparing the user name to yours. I am pretty sure you can't take a user name twice. You could try it though. (Obviously, everyone can use your user name offline.) If the storage is not available, your code should give you an error (myInfo is null and you can't call 'isStorageAvailable' on null. Well, I am not sure if it is actually possible to call a static method on null... I would still do it like this:
if (myInfo.isStorageAvailable())
{
   UserInfo myInfo = UserInfo.getMyInfo();
    if (myInfo.getUserName().equals("Nosson1459"))
    {
        //things for me
    }
}
danpost danpost

2017/2/5

#
Nosson1459 wrote...
What is "userIcon.png", is it something that I'm supposed to have or is it just there as an example and I'm supposed to put an image there.
It would be whatever generic image you would want to use for the user when the storage info is not available.
I don't have a "storage.csv" file am I supposed to , and what do I do with it once I get it.
It is added to your project folder when you test UserInfo locally (when the first UserInfo object is stored for that project). You do not need to anything with it.
Nosson1459 Nosson1459

2017/2/5

#
Super_Hippo wrote...
I think the userIcon image is not needed. 'getUserImage()' gets the image automatically.
danpost wrote...
It would be whatever generic image you would want to use for the user when the storage info is not available.
So basically Hippo the place it is used by me is for when there is no user and I can't use 'getUserImage()' that's the whole point in it (this can be seen in the scenario and in the coding here). Welcome back danpost, even if you're not back it's still the first time you are answering a question of MINE since about 6 days ago.
danpost danpost

2017/2/5

#
Super_Hippo wrote...
myInfo is null and you can't call 'isStorageAvailable' on null. Well, I am not sure if it is actually possible to call a static method on null
Interestingly enough, you can actually call a 'static' method on an object reference that is null. Because the 'myInfo' variable is to hold a reference to an object of type UserInfo, any static method in the UserInfo class can be called on 'myInfo' regardless of what value is held by the variable.
Super_Hippo Super_Hippo

2017/2/5

#
Okay, so that's also the reason why getUserImage is returning this dummy image even though the UserInfo object is null.
danpost danpost

2017/2/5

#
Nosson1459 wrote...
Welcome back danpost, even if you're not back it's still the first time you are answering a question of MINE since about 6 days ago.
Internet access was quite limited this past week.
Nosson1459 Nosson1459

2017/2/5

#
Super_Hippo wrote...
Okay, so that's also the reason why getUserImage is returning this dummy image even though the UserInfo object is null.
No. I don't no what it would do if it's null (probably NullPointerException), but I programmed it so that if the user is not logged in it should show that image (also YOUR image).
You need to login to post a reply.
1
2