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

2020/6/26

Check if my Actor is touching an edge

DenisHtl DenisHtl

2020/6/26

#
public void act() 
    {   
        movement();
        click();
        leave();
    }
    static String thisPlayer;[quote]im trying to create a new World (in this Case the world is calles Room) as soon as he hits the edge the world is 1300 and 900 big, i used 450 so the player has to hit the middle of the edge put when i slide around the right edge nothing happens[/quote]

    public void leave(){
        thisPlayer = "";
        if(this.getX() == 1300 && this.getY() == 450){thisPlayer = "player1";Greenfoot.setWorld(new Room());}
    }
Super_Hippo Super_Hippo

2020/6/26

#
If the size of the world is 1300×900 and you don’t allow objects to be outside the visible part of the world, then the object is inside the rectangle defined by the following four points: (0|0), (1299|0) (0|899), (1299|899) It will never be at x=1300. And even if it could be there exactly at (1300|450), it might not be very much fun to find this exact cell to move forward.
You need to login to post a reply.