Posted by sheel on Sun 1 Nov 18:30
report abuse | download | new post
- package
- { // start package
- import flash.display.MovieClip;
- public class Enemy extends MovieClip
- { // start public class Enemy
- var speed:Number = 2;
- var attackFrame:String;
- var walkFrame:String;
- var idleFrame:String;
- public var jumpSpeed:Number = 0; // velocity
- public function Enemy()
- { // start public function Enemy (constructor)
- var RNG=(Math.floor((Math.random() * 50)) %3)
- if (RNG == 0)
- {
- createEnemy1();
- }
- else if (RNG == 1)
- {
- createEnemy2();
- }
- else if (RNG == 2)
- {
- createEnemy3();
- }
- } // start public function Enemy (constructor)
- private function createEnemy1()
- { // start createEnemy1
- trace("createEnemy1")
- attackFrame = "rockAttack";
- walkFrame = "rockWalk";
- idleFrame = "rockIdle";
- } // end createEnemy1
- private function createEnemy2()
- { // start createEnemy2
- trace("createEnemy2")
- attackFrame = "scissorAttack";
- walkFrame = "scissorWalk";
- idleFrame = "scissorIdle";
- } // end createEnemy2
- private function createEnemy3()
- { // start createEnemy3
- trace("createEnemy3")
- attackFrame = "paperAttack";
- walkFrame = "paperWalk";
- idleFrame = "paperIdle";
- } // end createEnemy3
- public function Chase(handCharx, handChary)
- { // start public function Chase
- if (handCharx < this.x-10)
- {
- this.x -= speed;
- this.scaleX = -1;
- gotoAndStop(walkFrame);
- }
- else if (handCharx > this.x+10)
- {
- this.x += speed;
- this.scaleX = 1;
- gotoAndStop(walkFrame);
- }
- //else enemyIdle(handCharx);
- } // end public function Chase
- /*public function enemyIdle(handCharx)
- { // start public function enemyIdle
- if (handCharx < this.x-3)
- {
- this.x -= speed;
- this.scaleX = -1;
- gotoAndStop(idleFrame);
- }
- else if (handCharx > this.x+3)
- {
- this.x += speed;
- this.scaleX = 1;
- gotoAndStop(idleFrame);
- }
- } // end public function enemyIdle*/
- } // end public class Enemy
- } // end package
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.