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

2020/7/16

How to display an int on the screen?

1
2
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/16

#
I am creating a game with a simple scoring system, is there a simple way to display ints on the scene screen without using actors?
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/16

#
Why is no-one replying pls
danpost danpost

2020/7/16

#
ANIMALLOVER09824 wrote...
Why is no-one replying pls
It is summer break. Things are slow this time of year.
ANIMALLOVER09824 wrote...
I am creating a game with a simple scoring system, is there a simple way to display ints on the scene screen without using actors?
Use showText(String, int, int) , a World instance method. Otherwise, to learn how to use an actor, refer to my Value Display Tutorial scenario.
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/17

#
danpost wrote...
ANIMALLOVER09824 wrote...
Why is no-one replying pls
It is summer break. Things are slow this time of year.
ANIMALLOVER09824 wrote...
I am creating a game with a simple scoring system, is there a simple way to display ints on the scene screen without using actors?
Use showText(String, int, int) , a World instance method. Otherwise, to learn how to use an actor, refer to my Value Display Tutorial scenario.
How far off am i with this it says illegal start of statement before both 10s
public void showText(java.lang.String Score, 10, 10);
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/17

#
Also it isn't Summer break for me until Wednesday
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/17

#
Not start of statement it is start of type
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/17

#
Why do some things have big profile pics other small?, is it the size of what you have written?
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/17

#
Would this work to display the variable or would it just say Score
public var Score = 0
public void showText(java.lang.String var Score, 10, 10);
If not how would i do it, sorry i am asking so much
danpost danpost

2020/7/17

#
The showText method is already defined (you do not have to re-define it -- no 'public void). Just use it:
showText("Score:  "+Score, 10, 10);
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/18

#
This is what i mean
danpost danpost

2020/7/18

#
ANIMALLOVER09824 wrote...
<< Image Omitted >> This is what i mean
You are showing an empty method with all 3 parameters written incorrectly (the first one doubly typed and the other two non-typed literals). However, again, you do not need to re-define the method. Even if you got this far (which, still, is not what you want to do at all):
public void showText(String score, int x, int y);
the compiler will not accept it unless the class was declared abstract. And this:
public void showText(String score, int x, int y) {}
will remove any previously given implementation of the method (that is, the method will then not do a darn thing). Refer back to my last posting. Notice that I have a String and two int values as arguments for the parameters as required.
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/20

#
So how would i set the text that shows up to a public int? And how would i make the text white
danpost danpost

2020/7/20

#
ANIMALLOVER09824 wrote...
So how would i set the text that shows up to a public int? And how would i make the text white
If you had referred to the linked tutorial, you would know that you cannot control any state of the text shown by using showText(String, int int). You will need to use an Actor object if you want white text. Again, refer to the tutorial.
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/20

#
I did look
ANIMALLOVER09824 ANIMALLOVER09824

2020/7/20

#
I guess i will just set the background to be white
There are more replies on the next page.
1
2