/* This class makes a platform. Its constructor takes a position; that is where the platform stays. It provides two functions; collides and onIt collides returns 1 when an object is both near its top and going down fast enough to be about to go through the platform onit returns 1 when an object is near to it-- use for jumping */ package { import flash.display.Sprite; public class enemy extends Sprite { private var mySymbol : youSymbol; private const youSpeed = 6; // how fast the enemy moves // constructor. makes platform appear in the right place public function enemy(myX, myY: Number) { mySymbol = new youSymbol(); mySymbol.x = myX; mySymbol.y = myY; addChild(mySymbol); } // call this function every frame to move the enemy public function killedMe(playerX, playerY:Number):int { var dx, dy:Number; // use pythagorean theorem to detect touches dx = mySymbol.x - playerX; dy = mySymbol.y - playerY; if (Math.sqrt(dx*dx+dy*dy)<20) { return 1; } return 0; } // call this function every frame to move the enemy public function updater(playerX, playerY:Number):void { // move you closer to me if (mySymbol.x>playerX) { mySymbol.x = mySymbol.x - youSpeed; } if (mySymbol.y>playerY) { mySymbol.y = mySymbol.y - youSpeed; } if (mySymbol.x