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

2019/5/30

Key activated Door

Thotson Thotson

2019/5/30

#
So I have 2 doors on this level, Door2 and Door 3. These doors are only meant to be accessible if the player has come into contact with the key "Key". The player is called Isaac. I am just not entirely sure how to use boolean. These doors currently are teleporting the player to xy's upon contact.
if (isTouching(Door2.class))
       {
           setLocation(16, 15);
       }
       if (isTouching(Door3.class))
       {
           setLocation(13, 15);
       }
danpost danpost

2019/5/30

#
What code do you have for contacting a key?
Thotson Thotson

2019/5/30

#
I just have the key at this point no code in the class.
danpost danpost

2019/5/30

#
Thotson wrote...
I just have the key at this point no code in the class.
What do you think it would look like?
Thotson Thotson

2019/5/31

#
    public void Activation()
    {
        if (isTouching(Isaac.class))
        {
            getWorld().removeObject(this);
        }
    }
danpost danpost

2019/5/31

#
Thotson wrote...
<< Code Omitted >>
Have the Isaac actor check for the key and remove it. The key should not do anything (except maybe move -- but it probably does not anyway).
You need to login to post a reply.