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

2017/3/17

setImage

adlafforest adlafforest

2017/3/17

#
GreenfootImage image = new GreenfootImage("France.png"); getBackground().setFont(new Font("", Font.BOLD, 30)); getBackground().drawString("What country is this?", 23, 120); String questionText = ""; ArrayList<Answer> answers = new ArrayList<Answer>(); answers.add(new Answer("Belgium", false)); answers.add(new Answer("France", true)); answers.add(new Answer("Switzerland", false)); answers.add(new Answer("Netherlands", false)); Collections.shuffle(answers); Question question = new Question(questionText, answers); String explanation = "The correct answer was France"; question.setExplanation(explanation); questions.add(question); I have dozens of questions like this (there is a picture of a country on the screen and the player has to chose the correct name of the country among the four possible answers) in my QuizWorld, but the images do not show up on my Geography quiz. Do you have any suggestions?
Super_Hippo Super_Hippo

2017/3/17

#
In the first line, you create a new image, but you never use that image for anything.
adlafforest adlafforest

2017/3/21

#
How would I go about incorporating the image into the game?
Super_Hippo Super_Hippo

2017/3/21

#
Change the line to:
setBackground("France.png");
I think that is what you are trying to do.
adlafforest adlafforest

2017/3/21

#
Thank you. That worked but I don't want the picture to be the entire background. I would like to be able to set its location.
Super_Hippo Super_Hippo

2017/3/21

#
Then you need to create an actor and give it this image.
You need to login to post a reply.