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

2021/9/8

Hey Need help With My First Programm

Monk_08 Monk_08

2021/9/8

#
I'm very new to java and Greenfoot and I don't know how to code a visual counter on screen, my counter code is currently like this -->
private void aufsammeln()
    {
          Actor Schatz = getOneObjectAtOffset(0, 0, Schatz.class);
        if(Schatz != null) {
            getWorld().removeObject(Schatz);
            
            SchatzG++;

            System.out.println("Punkte Abenteurer = " + SchatzG);
            
        }
    } 
    
    private int SchatzG = 0;
    
And I want to kill one actor (Let the other actor win) when the other Touches him This was my attempt
public void Toeten()
    {
     Actor Waechter = getOneObjectAtOffset(0, 0, Abenteurer.class);
        if(Waechter != null) {
            Greenfoot.stop();
        }
    }
Thx for the Help
danpost danpost

2021/9/8

#
Monk_08 wrote...
I'm very new to java and Greenfoot and I don't know how to code a visual counter on screen
Please refer to my Value Display Tutorial scenario on creating a counter on screen. This will also help with a win/lose display.
I want to kill one actor (Let the other actor win) when the other Touches him This was my attempt << Code Omitted >>
Much simpler is to use the isTouching and removeTouching methods. Refer to the Actor class API documentation on the methods available.
Monk_08 Monk_08

2021/9/9

#
Thank you very much i did it :DD
You need to login to post a reply.