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

2015/7/7

Need Help

sllewis sllewis

2015/7/7

#
Hi All, I keeping getting an error that says: cannot find symbol- variable image public Emoticon (String newImage, String newSound) { Image= newImage; setImage(new GreenfootImage(image)); setImage(new GreenfootImage(image+".png")); } What am I doing wrong?
danpost danpost

2015/7/7

#
The code you gave was this (repeated to show line numbers):
public Emoticon (String newImage, String newSound)
{
    Image= newImage;
    setImage(new GreenfootImage(image));
    setImage(new GreenfootImage(image+".png"));
}
Here is what I see: (a) you have two Strings, 'newImage' and 'newSound' declared as parameters; (b) you are setting 'Image' to one of the String parameters; (c) you are setting the image of the actor at line 4 (I presume this code to be in an Actor subclass) to a new image from 'image', which: - is not declared anywhere within the method; - is is probably not declared outside the method either (or you would not get that error message); - is required to be the name of a file with its file extension (d) you are setting the image a second time unnecessarily at line 5; As a final note: 'Image' is not 'image' as java is case sensitive. So try this for line 4 and remove line 5:
setImage(new GreenfootImage(Image+".png"));
You need to login to post a reply.