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

2017/5/16

How do I make the Maincharacter stop if it hits a platform?

ketschma ketschma

2017/5/16

#
I have a huge problem concerning the main character who doesnt want to stop when i hit the platform(jump n run). I already tried it with obejctatoffset but that wont work, cause greenfoot doesnt recongnize the character.
    private boolean an = true;
Actor contactleftdown = getOneObjectAtOffset(-50,1,Figur.class);
            Actor contactleftup = getOneObjectAtOffset(-50,19,Figur.class);
            if ( contactleftdown !=null || contactleftup !=null)
            {
                an = false; //off
            }
            else
            {
                an = true;//on again
            }
        if (Greenfoot.isKeyDown("left")) //&& an == true)
        {
            moveRight();
        }
this code is written in the Platform.class cause they are the ones moving same with the right side is there any other possibility? Please let me know, thanks in advance!
You need to login to post a reply.