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

2012/3/24

GridWorld and setImage()

jpolacco jpolacco

2012/3/24

#
I have no luck changing images when using the Greenfoot version of the AP Computer Science GridWorld case study. I've coded setImage() in a constructor and in the act() method to no avail. Is there a simple fix? I know GridWorld sets the image in a special predetermined way: i.e., the class name followed by jpg or gif, and I think this is rendering the setImage() method useless. I'll try messing with the code some more and see if I can figure out an easy fix. Does anyone have any experience on the matter?
danpost danpost

2012/3/25

#
The setImage() command takes an image as the parameter. A filename ("myImage.jpg") is a String object; use it with a GreenfootImage constructor to create the image; then use that new image in the setImage() command.
You need to login to post a reply.