⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 poseidon.as

📁 一款模仿雷电的小游戏,包括关卡设计,判断加分,物理碰撞检测等.主要用as3.0开发.
💻 AS
字号:
package Classes.Enemies.Boss{
	import flash.events.Event;	
	import flash.display.Sprite;
	
	import Classes.Enemies.*;
	import Classes.Elements.*;
	import Classes.Utils.*;
	import Classes.Weapons.*;
	import Classes.Weapons.Bullets.*;
	import Classes.Weapons.Rockets.*;
	import Classes.Interface.*;
	import Classes.Sounds.GameSound;
	import Classes.Explode.*;

	public class Poseidon extends Aircraft implements ILaunch{
	
		public var tmpx:Number,tmpy:Number;
		private var radius:Number;
		private var crtr:Number;
		public var rocketType:Object;
		private var numGuns:int;
		
		public function Poseidon(){						
			speed = 3;
			life = 3500;
			mcLifeBar.max = life;
			hp = life;
			execution = 40;
			crtspeed = 0;
			accelerate = .5;
			condition = 110;
			score = UnitType.Poseidon.score;
			fireable  = false;
			radius 		= 100;
			crtr		= 1;
			numGuns 	= 2;
			weaponType 	= WeaponType.PhotonBullet;
			rocketType 	= WeaponType.Penguin;
		}

		override public function fire():void{
			if(inc % weaponType.interval == 0){
				for(var i:int=0;i<24;i++){
					var photon:PhotonBullet = new PhotonBullet();
					photon.aTargets = this.aTargets;
					photon.sender = this;
					photon.x = this.x;
					photon.y = this.y;
					photon.rotation = 15*i;
					photon.angle = photon.rotation;
					bulletLayer.addChild(photon);				
				}
			}
		}
		
		public function launch():void{
			if(WeaponType != WeaponType.Nothing){
				if(inc%(rocketType.interval*2)==0){
					createMissile();				
				}
			}
		}		
		
		private function createMissile():void{
			for(var i:int=0;i<numGuns;i++){
				var penguin:Penguin = new Penguin();
				penguin.moverange = moverange;
				penguin.aTargets = this.aTargets;		
				penguin.dimension = dimension;
				penguin.x = this.x -(i- numGuns/2 + .5) * 20;
				penguin.y = this.y;	
				if(aTargets.length){
					Moving.pointTo(penguin,aTargets[0]);
				}
				penguin.angle = -penguin.rotation;
				dimension.addChildAt(penguin,0);
				aFriends.push(penguin);
			}
		}
		
		override protected function move():void{			
			if(!aTargets.length)
				fireable = false;
			if(fireable){
				fire();
				launch();
			}
			if(!this.moveable)
				return;
			if(this.y<condition && inc==0){
				this.y+= this.speed;
				tmpx = this.x;
				tmpy = this.y;
				this.gotoAndStop("Normal");
			}			
			else{
				fireable = true;
				crtr = inc==1?1:crtr;
				if(crtr<radius)
					crtr += accelerate;
				this.hstate = Moving.moveCircle(this,speed,crtr,inc*1.5,tmpx,condition);
				if(hstate==-1)
					this.gotoAndStop("MoveLeft");
				else if(hstate==1)						
					this.gotoAndStop("MoveRight");
				else
					this.gotoAndStop("Normal");
				inc++;			
			}
			hitTest();
		}
		
		override public function set hp(value:Number):void{
			_hp = value;
			mcLifeBar.value = _hp;
			if(_hp<=0){
				var ex:Explode = new BossExplode();
				ex.x = this.x;
				ex.y = this.y;
				parent.addChild(ex);
			}
			live();
		}
		override public function get hp():Number	{
			return _hp;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -