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

2017/2/3

Help with setting font?

harini001 harini001

2017/2/3

#
I'm working on Asteroids(chapter 7) and I'm trying to set the font but r keeps giving me the error "cannot find symbol".
scoreCounter = newCounter("Score: ");
scoreCounter.setFont(scoreCounter.deriveFont(new Font("Ariel",12,Font.BOLD)));
addObject(scoreCounter,60, (getHeight()-20));
danpost danpost

2017/2/4

#
First off, 'new' should be a word by itself (not concatenated with 'Counter...'). The first line should be:
scoreCounter = new Counter("Score: ");
This is provided you have something like the following line within the class (outside of any methods):
Counter scoreCounter;
Next, the Counter object does not (unless you added one or one is supplied that I am not aware of) a 'setFont' method. Maybe you mean to set the font of the image of the Counter object (the GreenfootImage object set to the Counter actor). There is a 'setFont' method that belongs to the GreenfootImage class.
You need to login to post a reply.