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

2014/1/6

Why does ball move to the right, and not left.

Moynzy Moynzy

2014/1/6

#
    
        //move left
        player=getOneObjectAtOffset(10,0,player.class);
        if (player !=null)
        {

            setLocation(getX() - 3, getY());
         if (Greenfoot.isKeyDown("space"))
        {

            move(10);
            //For the basic solution this is where you put your new code.
        }
            //For the basic solution this is where you put your new code.
        }
nosyarg nosyarg

2014/1/7

#
rather than setLocation(getX() - 3, getY()); use setLocation(getX() + 3, getY());
Moynzy Moynzy

2014/1/7

#
nosyarg wrote...
rather than setLocation(getX() - 3, getY()); use setLocation(getX() + 3, getY());
No no, that's fine. I want my ball to move that way when there's collision Sorry i should have been clearer. When the space button is pressed the ball should move to the left (move(10), instead the son of a gun moves to the right. any solutions please?
nosyarg nosyarg

2014/1/7

#
well the same thing works, try using move(-10)
bourne bourne

2014/1/7

#
move(int distance) Move this actor the specified distance in the direction it is currently facing.
Moynzy Moynzy

2014/1/7

#
Thank you guys, you guys are amazing.
You need to login to post a reply.