hey im a newbie with greenfoot and programming. my first project is a breakout clone and its working right now.
but now i wanted to implement a winscreen if you hit all 80 blocks it comes up with a "you won" message. i wrote the you won message in the counter class. is that wrong?
i comes up with a message but its missplaced and i dont know how to place it in the middle of the screen.
(sry for bad english its not my mother tongue)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; /** * Write a description of class Counter here. * * @author Julian Kraus * @version 22.01.17 */ public class Counter extends Actor { int score = 0 ; public void act() { setImage( new GreenfootImage( "Score : " + score, 24 , Color.BLACK, Color.WHITE)); Gewonnen(); } public void addScore() { score++; } public void Gewonnen(){ if (score == 80 ) {Victory victory = new Victory(); setImage( new GreenfootImage( "Du hast gewonnen!" , 48 , Color.WHITE, Color.BLACK)); getWorld().addObject ( new Victory(), 310 , 240 ); Greenfoot.delay( 60 ); Greenfoot.setWorld( new StartScreen()); } } } |