Hi, in my game is a actor which I want to let it turn to the direction of the mouse. The code that I used kind of worked out. It follows the mouse, but the side of actor is following the mouse en not the top. I've already tried to turn the actor. But tht didn't work. What should I do?
This is my code:
public class Speler extends Actor { int speed = 10; //snelheid public Speler() { setImage("mainship.png"); //invoegen foto getImage().scale(80,80); //grootte foto } public void act() { moveAround(); //de public moveAround laten afspelen MouseInfo mouse = Greenfoot.getMouseInfo(); if (mouse != null) { int x = mouse.getX(), y = mouse.getY(); turnTowards(x, y); } } public void moveAround() { if(Greenfoot.isKeyDown("down")) //als pijltje omlaag dan actor omlaag { setLocation(getX(),getY()+ speed); } if(Greenfoot.isKeyDown("up")) //als pijltje omhoog dan actor omhoog { setLocation(getX(),getY()- speed); } if(Greenfoot.isKeyDown("left")) //als pijltje naar links actor naar links { setLocation(getX() - speed,getY()); } if(Greenfoot.isKeyDown("right")) //als pijltje naar rechts actor naar rechts { setLocation(getX() + speed,getY()); } } }