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

2017/10/2

Check if it will touch wall class

Gendut31 Gendut31

2017/10/2

#
i have 3 class. hero, monster, and wall class. if hero is touching monster, it will "move the hero" but if "move the hero" will result hero touching the wall, it dont move it. how i can make this? sorry for my bad english
Super_Hippo Super_Hippo

2017/10/2

#
Something like this:
if (isTouching(Monster.class))
{
    //move hero
    move(-2);
    if (isTouching(Wall.class))
    {
        move(2);
    }
}
Gendut31 Gendut31

2017/10/2

#
Super_Hippo wrote...
Something like this:
if (isTouching(Monster.class))
{
    //move hero
    move(-2);
    if (isTouching(Wall.class))
    {
        move(2);
    }
}
oh nice thanks, it works!
You need to login to post a reply.