This site requires JavaScript, please enable it in your browser!
Greenfoot back
rachpaguia@gmail.com
rachpaguia@gmail.com wrote ...

2017/3/11

BACKGROUND HELP

Hi!! I'm pretty new in Greenfoot and I need help in making an imported file be my background. Can someone help me?
Super_Hippo Super_Hippo

2017/3/11

#
Make sure the file is located in the images folder of your project. Then you can use:
setBackground("filename.png");
Thank you! But it still doesn't work :(
Impoleon117 Impoleon117

2017/3/12

#
you have to put setBackground("filename.png"); in your world class (in the constructor)
did you mean something like this? /** * Constructor for objects of class bg. * */ public bg() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); setBackground("Screen Shot 2017-03-11 at 17.41.40.jpg"); } because my background is still white despite having this code :(
Oh it's working now yay! THANKS! But the image is too big :( What can I do to make it smaller?
Impoleon117 Impoleon117

2017/3/12

#
The Greenfoot documentation is your friend (https://www.greenfoot.org/files/javadoc/): "void scale(int width, int height) Scales this image to a new size." so you have to do something like: GreenfootImage img = new GreenfootImage("Screen Shot 2017-03-11 at 17.41.40.jpg"); img.scale(width,height); <---- insert here your desired width and height or do img.scale(getWidth(),getHeight()); setBackground(img);
Thank you so much!!
You need to login to post a reply.