All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.awt.Component | +----java.awt.Canvas | +----jovial.slotCar.animator.Animator
This class interacts with two others: Animatee, and Drawable. At start-up, it is configured with a number of drawables. It then enters a loop, where it tells the Animatee to move (by a time interval), then it draws its Drawables (in increasing order of height, so that overlapping works).
As a concession to efficiency, we adopted the convention that Drawables with a height <= 0 won't be re-drawn in each successive frame. Think of them as a "background" image. In addition, Drawables that canMove() are asked to erase() themselves after each frame. If these restrictions are too much, you can always make sure all your Drawables have a height >= 1, and maybe make your lowest Drawable be a rectangle that erases the entire screen.
Use:
Animator a = new Animator(myAnimatee); new Thread(a).start();
public Animator()
public void init(Animatee a)
public void paint(Graphics g)
public Dimension preferredSize()
public void addDrawable(Drawable d)
public void run()
All Packages Class Hierarchy This Package Previous Next Index