I have created two classes. One for in-game text and another for the background images to be used. This is what I have so far:
Text class:
Frames class:
How would I get it so that when I add the text to the world, it picks up a specific background from the frames.class and the text shown is that which is defined at the top of text.class. My game is located here http://www.greenfoot.org/scenarios/11862
import greenfoot.*;
import java.awt.Color;
/**
* Write a description of class Language here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Text extends Tiles
{
public String intro_text1 = "Storyline1 \n";
public String intro_text2 = "Storyline2 \n";
public String intro_text3 = "Storyline3";
public String palletTown_Sign1 = "OAK POKéMON RESEARCH LABS";
public String palletTown_Sign2 = "Pallet Town \n Shades of your journey await!";
public Text(String text)
{
updateImage(text);
}
private void updateImage(String text)
{
Color txtColor = new Color(96, 96, 96);
Color bgColor = new Color(0, 0, 0, 0);
setImage(new GreenfootImage(text, 20, txtColor, bgColor));
}
public void setText(String text)
{
updateImage(text);
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Message here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Frames extends Tiles
{
public Frames(String selection)
{
this.selection = selection;
this.directory = "Frames/";
if (selection == "type1")
setImage(directory + "type1.png");
// else if (selection == "type2")
// setImage(directory + "type2.png");
// else if (selection == "type3")
// setImage(directory + "type3.png");
}
public void act()
{
if (Greenfoot.isKeyDown("enter"))
{
getWorld().removeObject(this);
}
}
}
