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

2014/11/29

Need some help with my scenario

qwerty1 qwerty1

2014/11/29

#
Hello! I'm working on a car game and I ran into a problem with getting images to appear when i need them to. I got the FileNotFound error when I tried to make an image appear. From what I've learned reading these forums, you have to import any images that you want to use directly into the scenario file the project is in. However, I went to the scenarios file and found only a few things, like LunarLanders and stuff like that, not the projects that I've created. Any help would be greatly appreciated. Here's the code I have for the image i want to have appear so far. import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class win here. * * @author (your name) * @version (a version number or a date) */ public class win extends Actor { /** * Act - do whatever the win wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { reset(); } public void reset() { if (isTouching(Player1.class)) { getWorld().setBackground(new GreenfootImage("CarGame6.PNG")); } } }
Super_Hippo Super_Hippo

2014/11/29

#
I am not sure if the .png part must be in lowercase letters. You have to save the images into the images folder in your project. If you don't find your project, try to open Greenfoot and click "Save as...". Maybe you saved it at the default place and don't find it now.
qwerty1 qwerty1

2014/11/29

#
Thank you so much Super_Hippo! It works now!
qwerty1 qwerty1

2014/11/29

#
I need help with one more thing, and probably more as I'm not the best programmer. I'm trying to make a game menu and have the game start when the mouse clicks on an image I made that says "start". However, I tried doing the drawImage thing and it won't work. If i try compiling it it says that I need a ) after the GreenfootImage, and if I do that, it tells me to put a semicolon after the ) that I just put in, and then it just stays that its not a statement. Here's the code. drawImage(GreenfootImage "CarGame9.PNG", 200, 300);
danpost danpost

2014/11/29

#
Did you try anything similar to what you used in you last issue?
qwerty1 qwerty1

2014/11/29

#
Yeah i made sure to import it to the images folder for my project. It simply won't compile.
danpost danpost

2014/11/29

#
qwerty1 wrote...
Yeah i made sure to import it to the images folder for my project. It simply won't compile.
I was talking about how it was coded.
qwerty1 qwerty1

2014/11/29

#
Nope. I honestly don't see a reason why it shouldn't work.
qwerty1 qwerty1

2014/11/29

#
So does anyone have any ideas as to what the problem might be?
danpost danpost

2014/11/29

#
I was talking about how you passed the GreenfootImage object to the 'setBackground' method -- how the GreenfootImage object was created.
You need to login to post a reply.