import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Zeigt eine Nachricht in der Welt an
 * 
 * @author Florian
 */
public class Message extends UI
{
    String[] text;
    GreenfootImage img; 
    int scale = 0;

    public Message(String[] txt){
        text = txt;
        img = new GreenfootImage("Skins/button/message.png");
    }

    public void show(){
        float scale = 1;
        while(scale < 320f){
            img = new GreenfootImage("Skins/button/message.png");
            img.scale((int)scale*4/3, (int)scale);
            setImage(img);
            getWorld().repaint();
            Greenfoot.delay(1);
            scale*=1.4f;
        }
        img.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 17));
        int i;
        for(i = 0; i < text.length; i++){
            img.drawString(text[i], 10, 80 + 20 * i);
        }
        img.scale(420, 320);
        setImage(img);
        getWorld().repaint();

        //getWorld().removeObject(this);
    }

    public void hide(){
        float scale = 320;
        while(scale > 10f){
            img.scale((int)scale*4/3, (int)scale);
            setImage(img);
            getWorld().repaint();
            Greenfoot.delay(1);
            scale/=1.6f;
        }
    }
}
