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

2012/2/2

Text?

1
2
toytttttt toytttttt

2012/4/3

#
What do you mean constructor? (sorry, total newb here).
danpost danpost

2012/4/3

#
danpost wrote...
@sp33dy, I revised your method to
setImage(new GreenfootImage(" Click here for dialog ", 30, Color.BLACK, Color.RED));
The constructor I referenced was the 'new GreenfootImage(String, int, Color, Color)' statement which 'constructs' a new GreenfootImage using the String 'text', the int 'fontSize', and the two Colors for the foreground and background. Once the GreenfootImage object is constructed, it can be used in the 'setImage(GreenfootImage)' statement to set the image of your scoreboard object. You will need to 'import java.awt.Color;' to make use of this constructor.
sp33dy sp33dy

2012/4/3

#
>toyttttt, A constructor is the first method that is called in a class, when it is 'constructed'; i.e. created. I.E. a
new MyClass();
Would create a new class, for which java will look for a constructor method and call it if exists. A constructor class method happens to be the name of the class with no return parameters, for example:
public MyClass() {
     //some initialisation or similar code
}
This code will execute on construction. You'll note that there is no return value between public and the method name; therefore indicating that this is a constructor. A constructor can have have parameters, for which the new MyClass(<params>) would have to be supplied. I hope that makes sense. Kind regards sp33dy
toytttttt toytttttt

2012/4/12

#
I got it working! thanks for all the help! I had made quite a few silly mistakes, but ive flattened them out , and its working. This forum is great!
sp33dy sp33dy

2012/4/12

#
Great to hear!!! :)
You need to login to post a reply.
1
2