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

2017/3/24

count a timer while an special actor is in the game

1
2
danpost danpost

2017/3/27

#
To include the time in the win display, change the image text:
// from
"Du hast: " +(AnzahlGrapes)
// to
"Du hast: "+AnzahlGrapes+"\nTime: "+(timer/60)
Fifilein Fifilein

2017/3/28

#
Thank you,now there always more than 2 Grapes. Is there a method for move an actor once to a special place? I tried this, but it did not work like I want it:
if(getObjects(Grape.class).isEmpty())
        {
         setBackground(iimmaage);
                 windisplay.move(20);
        } 
Can you help me please?
danpost danpost

2017/3/28

#
Fifilein wrote...
Thank you,now there always only 2 Grapes.
I hope you mean 'at least', not 'only'. (EDIT: I see you edited it to 'more than')
Is there a method for move an actor once to a special place? I tried this, but it did not work like I want it: < Code Omitted >
You can use:
winDisplay.setLocation(<< wherever >>);
Fifilein Fifilein

2017/3/28

#
Thank you now it works, but when the grapeclass is empty I want to make the size bigger. Do you know how I could do this?
danpost danpost

2017/3/28

#
Fifilein wrote...
Thank you now it works, but when the grapeclass is empty I want to make the size bigger. Do you know how I could do this?
Like I said before, you can create, set the image and display the winDisplay object at this time:
if(getObjects(Grape.class).isEmpty() && winDisplay == null)
{
    setBackground(iimmaage);
    winDisplay = new SimpleActor();
    String text = "Du hast: "+AnzahlGrapes+"\nTime: "+(timer/60);
    winDisplay.setImage(new GreenfootImage(text, 96, Color.RED, new Color(0, 0, 0, 0)));
    addObject(winDisplay, << wherever >>);
}
Remove the 'updateWinDisplay' method and remove lines 31, 32 and 34 from the constructor. You can also remove the 'SimpleActor2' class.
Fifilein Fifilein

2017/3/28

#
Thank you very much no it works like it should!
You need to login to post a reply.
1
2