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

2018/12/4

setRotation but in the opposite

Samwcool Samwcool

2018/12/4

#
I have an enemy in my game and when it hits a wall it rotates by 180, when it hits the next wall it doesn't do anything (thats because the image is already at 180), so how would i do an opposite rotation that flips the image every time? Code:
private void touchingWall()
    {
        move(3);
        if (getOneIntersectingObject(Wall.class) !=null)
        {
            setRotation(180);
        }
    }
Samwcool Samwcool

2018/12/4

#
I guess i could make two separate walls but i feel that there must be another way of doing it
danpost danpost

2018/12/5

#
Samwcool wrote...
I guess i could make two separate walls but i feel that there must be another way of doing it
Use the turrn method instead of setRotation
You need to login to post a reply.