| |
#1 (permalink)
| |||||||
| Forum Junior Level: 8 Level up: 77% Activity: 0%
Posts: 347
Status:
Offline
|
Make sure you have the program MACROMEDIA FLASH version 7 or higher 1.) Open Flash 2.) Select NEW FLASH DOCUMENT 3.) Create or Upload your Enemy Ship image and convert to movie clip. 4.) Click the drop arrow and select EXPORT FOR ACTIONSCRIPT and EXPORT IN FIRST FRAME 5.) (after object is created) Go to FILE>NEW>ACTIONSCRIPT FILE 6.) paste the code below into that spot. class EnemyShip extends MovieClip { var speed; var shootTimer; function onLoad() { _x = 700; _y = Math.random()*300; speed = Math.random()*5 + 5; shootTimer = 0; } function onEnterFrame() { _x -= speed; if(_x < -100) { this.removeMovieClip(); } if(this.hitTest(_root.ship)) { _root.ship.updateHealth(-20); explode(); } shootTimer +=1; if(shootTimer > 30) { shootTimer = 0; var missile = _root.attachMovie("EnemyMissile","EnemyMissile" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); missile._x = _x - 50; missile._y = _y + 2; } } function explode() { var explosion = _root.attachMovie("Explosion","Explosion" + _root.getNextHighestDepth(),_root.getNextHighestDe pth()); explosion._x = _x; explosion._y = _y; this.removeMovieClip(); _root.ship.updateScore(50) } } 7.) Save the document as class.as in the same folder your SWF is in (example: Class-Enemy Ship I wold save it as Enemy Ship.as) 8.) Save the SWF in the same folder as the actionscript TEST MOIVE to check if works if anyone needs a tutorial/question, please notify me and I will try to help/asses the problem/help/tutorial/ If you see any other flash tutorials like this one and were made by me: They all go to the same game | |||||||
|
|
| Thread Tools | |
|