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

2013/6/10

what id the mover code? can't find it on here anywhere

dangamecreator dangamecreator

2013/6/10

#
Just watched a youtube video on shooting, it told me to copy the mover code but I can't find it anywhere???
Gevater_Tod4711 Gevater_Tod4711

2013/6/10

#
Probably it meant a move method like one of this methods:
    /**
     * Make an Actor move the given distance.
     * 
     * @param distance
     *      The distance the Actor is moved.
     */
    public void move(double distance) {
        double angle = Math.toRadians(getRotation());
        int x = (int) Math.round(getX() + Math.cos(angle) * distance);
        int y = (int) Math.round(getY() + Math.sin(angle) * distance);
        setLocation(x, y);
    }
    /**
     * Make an Actor move the given distance into a given direction.
     * 
     * @param angle
     *      The angle to which the actor should be moved.
     * 
     * @param distance
     *      The distance the Actor is moved.
     */
    public void move(double angle, double distance) {
        angle = Math.toRadians(angle);
        setLocation((int) (getX() + Math.cos(angle) * distance), (int) (getY() + Math.sin(angle) * distance));
    }
You need to login to post a reply.