Class SmoothMover

java.lang.Object
  extended by greenfoot.Actor
      extended by SmoothMover

public abstract class SmoothMover
extends greenfoot.Actor

A superclass for specific actor classes that add smooth movement functionality. Movement is based on doubles (rather than ints), and thus generates smoother movement for fast moving actors in high resolution worlds. The SmoothMover also implements world wrap-around: when moving out of the world at any edge, the actor will enter again at the opposite side. Requires class Vector.

Author:
Poul Henriksen

Constructor Summary
SmoothMover()
           
SmoothMover(Vector speed)
          Create new thing initialised with given speed.
 
Method Summary
 Vector getSpeed()
          Return the current speed.
 void increaseSpeed(Vector s)
          Increase the speed with the given vector.
 void move()
          Move forward one step.
 void setLocation(double x, double y)
          Providing 'setLocation' based on doubles.
 void setLocation(int x, int y)
          Override the default 'setLocation' method to keep our own coordinates up-to-date.
 
Methods inherited from class greenfoot.Actor
act, addedToWorld, getHeight, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWidth, getWorld, getX, getY, intersects, setImage, setImage, setRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmoothMover

public SmoothMover()

SmoothMover

public SmoothMover(Vector speed)
Create new thing initialised with given speed.

Method Detail

getSpeed

public Vector getSpeed()
Return the current speed.


increaseSpeed

public void increaseSpeed(Vector s)
Increase the speed with the given vector.


move

public void move()
Move forward one step.


setLocation

public void setLocation(double x,
                        double y)
Providing 'setLocation' based on doubles. This will eventually call the built-in 'setLocation' method in Actor.


setLocation

public void setLocation(int x,
                        int y)
Override the default 'setLocation' method to keep our own coordinates up-to-date.

Overrides:
setLocation in class greenfoot.Actor
Parameters:
x - Location index on the x-axis
y - Location index on the y-axis