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

2019/4/3

How do i fix this?

t.jongsma t.jongsma

2019/4/3

#
public void speler2Wins()
    { 
        
        Actor speler1ZietExplosie; 
        speler1ZietExplosie = getOneObjectAtOffset(getX(), getY(), Explosie.class);
        if (speler1ZietExplosie != null)
        {
            Greenfoot.stop();
            
        }
    }
this code for my bomberman game needs to make sure that if player1(speler1) is at same x and y as an explosion, the game needs to end. this code is also at my other player(2), there it works fine. but at this player it doesn't. someone?
danpost danpost

2019/4/3

#
t.jongsma wrote...
<< Code Omitted >> this code for my bomberman game needs to make sure that if player1(speler1) is at same x and y as an explosion, the game needs to end. this code is also at my other player(2), there it works fine. but at this player it doesn't. someone?
"at same x and y" would be with NO offset. Your code is looking at a location twice the distance away from the top-left corner of the world window than the actor currently is at.
t.jongsma t.jongsma

2019/4/3

#
this code was to complicated for sure. i fixed it with a much more simple code
if (isTouching(Explosie.class))
        {
            Greenfoot.stop();
            Greenfoot.setWorld(new wereld2());
        }
You need to login to post a reply.