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

2013/10/21

I'm climbing damn high!

ddvink ddvink

2013/10/21

#
I'm trying to climb in steps of ten, but instead I'm climbing immediately to y=-10 (the Y value of my start position is about 300).
    public void checkLiane(){
        Actor lianeActor = getOneIntersectingObject(Liane.class);

        yValue = getY();

        while(lianeActor != null && Greenfoot.isKeyDown("up")){
            System.out.println(yValue);
            System.out.println("Ik probeer te klimmen.");
            climbInLiane();
        }
    }

    public void climbInLiane(){
        // Vallen uitschakelen
        yValue = getY();
        yValue -= 10;
        setLocation(getX(), yValue);
    }
Someone? Yours, Dennis
Gevater_Tod4711 Gevater_Tod4711

2013/10/21

#
You are using a while loop. That causes that your actor climbes up the liane in only one act. If you don't use any loops but just use an if clause your actor will climb up 10 cells every act.
You need to login to post a reply.