package NGPdemos; /** * AlienTimer.java * * * Created: Tue Feb 20 14:42:33 2001 * * @author Brown U. lecture notes modified by Stuart C. Shapiro */ public class AlienTimer extends NGP.Timer{ /* associated with a generic AlienShape (polymorphism!) */ private AlienShape _myAlien; public AlienTimer (AlienShape myAlien){ super(100); // this timer will call activate every 100 ms _myAlien = myAlien; } /** * Each time this method is called, the * AlienShape that's associated with this * instance will move 5 pixels to the right * and 10 pixels up. */ public void activate() { _myAlien.moveToPosition(new java.awt.Point(_myAlien.getLocation().x + 5, _myAlien.getLocation().y - 10)); } }// AlienTimer