[HTML5 게임개발] ACT의 수평버전에 도전하다(3) : 아름다운 영웅을 만났을 때 열정을 느낀다

黄舟
풀어 주다: 2017-03-01 16:24:08
원래의
1566명이 탐색했습니다.


이 시리즈의 세 번째 기사입니다. 다른 기사는 아래 게시물의 목차를 참조하세요

http ://www.php.cn/html5-tutorial-354344.html

시작이 길다

이 튜토리얼 시리즈는 제가 처음으로 개발한 것입니다. 기사의 대부분은 침에 불과합니다. 누구나 무료로 읽을 수 있으므로 침수되지 않도록 조심하십시오.

이러한 개발에서 첫 번째 병목 현상은 자료입니다. 많은 자료 URL을 제공해 주신 네티즌 요롬왕님께 감사드립니다.

이번 개발 결과는 다음과 같으니, 먼저 미리 확인해주세요.


소재 변환 도구

이번에 찾은 소재는 모두 gif 형식의 사진입니다. 게임에 사용하시려면 꼭 필요합니다. gif 사진을 변환하려면 각 프레임을 꺼내어 새로운 사진을 만듭니다. 플래시를 사용하여 간단한 변환 도구를 만들었습니다. 필요한 친구는 다음과 같이 사용할 수 있습니다.

http://lufylegend.com/flash/demo/GifToPng

주제

황장군은 나 때문에 전장에서 제외됐다고 할 수 있다 요즘 너무 심심해서 전쟁터에서 칼을 들고 베고, 달리고, 으르렁거리고...

더 이상 읽을 수가 없어서 다짐합니다. 그의 노인에게 재미를 더하기 위해 몇 줄을 계속 작성하십시오.

1. 전장 이동

우선, 전장 맵을 어떻게 움직여도 같은 곳에서는 이동할 수 없습니다.

var back_run = true;
로그인 후 복사

이 변수가 true일 경우 전장의 배경맵을 이동할 수 있고, 그렇지 않으면 이동할 수 없습니다.

그런 다음 Player.js의 이동 기능에 전장의 움직임을 제어하는 ​​코드를 추가합니다. 왜 Character.js에는 없고 Player.js에 있나요? 왜냐하면 주인공인 황장군이 움직일 때만 맵이 움직이기 때문입니다. 캐릭터가 부모 클래스이고 적들도 나중에 이 클래스를 상속받게 되기 때문입니다.

Player.prototype.move = function (){
	var self = this, mx = 0, my = 0;
	if(keyCtrl[KEY.LEFT] && charaLayer.x + self.x > 0){
		mx = -1;
	}else if(keyCtrl[KEY.RIGHT] && charaLayer.x + self.x < LGlobal.width){
		mx = 1;
	}
	if(keyCtrl[KEY.UP]){
		my = -1;
	}else if(keyCtrl[KEY.DOWN]){
		my = 1;
	}
	self.mx = mx;
	self.my = my;
	if(self.action == ACTION.RUN){
		mx *= 2;
		my *= 2;
	}else if(self.action == ACTION.HIT){
		mx = 2*(self.direction == DIRECTION.RIGHT ? 1 : -1);
		my = 0;
	}
	if(back_run && mx > 0 && charaLayer.x + self.x > LGlobal.width * 0.5){
		var setX = mx*MOVE_STEP;
		if(backLayer.data.x + setX + backLayer.data.width > backLayer.data.image.width){
			back_run = false;
			setX = backLayer.data.image.width - backLayer.data.width - backLayer.data.x;
		}
		charaLayer.x -= setX;
		backLayer.data.setCoordinate(backLayer.data.x + setX,backLayer.data.y);
		addEnemy();
	}
	self.callParent("move",arguments);
};
로그인 후 복사

보시다시피 주인공이 움직일 때 지도 좌표가 반대 방향으로 증가하고 감소하여 시각적 지도 이동을 구현합니다. 이 함수는 다음과 같습니다. 전장에 적이 추가되었는지 확인합니다.

둘째, 적 추가

적을 추가하는 방법을 살펴보겠습니다. Sun Shangxiang의 여러 자료를 찾았는데, 이 자료는 하나씩 나열되지는 않습니다. . 밖으로.


아래에 Enemy.js 클래스를 추가하세요.

function Enemy(list,speed){
	var self = this;
	base(this,Character,[list,speed]);
	self.belong = "enemy";
	self.hp = 100;
};
Enemy.prototype.onjump = function (){
	var self = this;
	self.callParent("onjump",arguments);
	self.setLocation();
	var index = self.anime.colIndex;
	self.yArr = [0,-10,-20,-30,-40,-40,-30,-20,-10,0];
	self.anime.y += self.yArr[index];
};
Enemy.prototype.onjump_attack = function (){
	var self = this;
	self.callParent("onjump_attack",arguments);
	self.setLocation();
	var index = self.anime.colIndex;
	if(index >= self.yArr.length)return;
	self.anime.y += self.yArr[index];
};
Enemy.prototype.setAction = function (action,direction){
	var self = this,yArr = new Array();
	if(action == ACTION.MOVE && self.action == ACTION.JUMP)return;
	if(action == ACTION.JUMP_ATTACK){
		var index = self.anime.colIndex,i;
		for(i = index;i0){
		self.anime.y += self.yArr[0];
	}
};
Enemy.prototype.overActionRun = function (lastAction,animeAction){
	var self = this;
	self.callParent("overActionRun",arguments);
	keylock = false;
	
	if(lastAction == ACTION.FALL){
		if(self.direction == DIRECTION.LEFT){
			self.x += 80;
		}else{
			self.x -= 80;
		}
	}
};
Enemy.prototype.move = function (){
	var self = this, mx = 0, my = 0;
	self.mx = mx;
	self.my = my;
	self.callParent("move",arguments);
};
로그인 후 복사

이 클래스는 Player.js와 유사하며 둘 다 Character 클래스에서 상속되며 방금 생성한 각 해당 배열을 프로세서에 전달하는 번거로움이 있는 대신 설정해야 할 모든 매개변수가 포함된 배열 목록을 전달했습니다.

적을 추가하는 addEnemy() 함수 호출 시, 적을 무한정 추가할 수 없으므로, 추가할 적과 언제 추가할지 미리 준비하세요.

var enemy_list = new Array(
	{name:"sunji",x:800,y:350,when_x:300,back_run:false},
	{name:"huangzhong",x:1200,y:280,when_x:800,back_run:true}
);
function addEnemy(){
	if(enemy_list.length == 0)return;
	if(enemy_list[0].when_x > hero.x)return;
	var charadata = CharacterList[enemy_list[0].name]();
	var enemy = new Enemy(charadata);
	enemy.x = enemy_list[0].x;
	enemy.y = enemy_list[0].y;
	charaLayer.addChild(enemy);
	enemy_list.shift();
}
로그인 후 복사

적을 추가할 시점의 when_x, 적이 나타나는 위치의 좌표, 캐릭터가 나타난 후 지도의 이동이 멈추는지 여부 등의 정보가 포함된 적군 목록 배열을 추가했습니다. addEnemy 함수가 호출되면 호출 시 when_x와 주인공의 위치를 ​​이용하여 적 추가 여부를 판단합니다.

3. 공격

적과의 싸움이 있을 것이다.

공격 판정은 실제로 충돌 감지입니다. 물론 픽셀 수준의 충돌을 사용할 수도 있지만 이런 종류의 게임에서는 다소 과하고 효율성이 너무 낮기 때문에 직사각형을 사용합니다. 여기서 충돌 감지.

lufylegend.js 엔진에는 LGlobal.hitTest() 함수가 있는데, 이 함수를 사용하면 사각형의 충돌 여부를 확인할 수 있습니다. 하지만 그림 자료에는 공백 영역이 많기 때문에 이 방법을 직접 사용하면 됩니다. , 에러가 좀 크네요. 그래서 캐릭터의 각 프레임별로 감지해야 할 공격 범위와 공격 범위를 아래 CharacterList.js 에서 미리 설정해 두었습니다.

var CharacterList = {
	huangzhong:function(){
		//图片数据
		var dataList = new Array();
		dataList.push(new LBitmapData(imglist["player_stand"],0,0,106,77));
		dataList.push(new LBitmapData(imglist["player_move"],0,0,115,85));
		dataList.push(new LBitmapData(imglist["player_run"],0,0,125,87));
		dataList.push(new LBitmapData(imglist["player_jump"],0,0,131,134));
		dataList.push(new LBitmapData(imglist["player_attack"],0,0,242,143));
		dataList.push(new LBitmapData(imglist["player_big_attack"],0,0,232,143));
		dataList.push(new LBitmapData(imglist["player_jump_attack"],0,0,232,143));
		dataList.push(new LBitmapData(imglist["player_hit"],0,0,161,88));
		dataList.push(new LBitmapData(imglist["player_skill"],0,0,324,140));
		dataList.push(new LBitmapData(imglist["player_big_skill"],0,0,441,166));
		dataList.push(new LBitmapData(imglist["player_hert"],0,0,179,87));
		dataList.push(new LBitmapData(imglist["player_fall"],0,0,298,157));
		//图片分割数据
		var coordinateList = new Array();
		coordinateList.push(LGlobal.pideCoordinate(1272,77,1,12));
		coordinateList.push(LGlobal.pideCoordinate(920,85,1,8));
		coordinateList.push(LGlobal.pideCoordinate(750,87,1,6));
		var jumpList = LGlobal.pideCoordinate(655,134,1,5);
		coordinateList.push([[jumpList[0][0],jumpList[0][0],jumpList[0][1],jumpList[0][1],jumpList[0][2],jumpList[0][2],jumpList[0][3],jumpList[0][3],jumpList[0][4],jumpList[0][4]]]);
		var attackList = LGlobal.pideCoordinate(484,143,1,2);
		coordinateList.push([[attackList[0][0],attackList[0][1],attackList[0][1],attackList[0][1]]]);
		var bigattackList = LGlobal.pideCoordinate(927,143,1,4);
		coordinateList.push(bigattackList);
		var jumpattackList = LGlobal.pideCoordinate(927,143,1,4);
		coordinateList.push(jumpattackList);
		coordinateList.push(LGlobal.pideCoordinate(966,88,1,6));
		coordinateList.push(LGlobal.pideCoordinate(2268,140,1,7));
		var bigskillList = LGlobal.pideCoordinate(2205,830,5,5);
		coordinateList.push([[bigskillList[0][0],bigskillList[0][1],bigskillList[0][2],bigskillList[0][3],bigskillList[0][4]
				,bigskillList[1][0],bigskillList[1][1],bigskillList[1][2],bigskillList[1][3],bigskillList[1][4]
				,bigskillList[2][0],bigskillList[2][1],bigskillList[2][2],bigskillList[2][3],bigskillList[2][4]
				,bigskillList[3][0],bigskillList[3][1],bigskillList[3][2],bigskillList[3][3],bigskillList[3][4]
				,bigskillList[4][0],bigskillList[4][1],bigskillList[4][2],bigskillList[4][3],bigskillList[4][4]]]);
		var hertList = LGlobal.pideCoordinate(358,87,1,2);
		coordinateList.push([[hertList[0][0],hertList[0][0],hertList[0][1],hertList[0][1]]]);
		var fallList = LGlobal.pideCoordinate(2682,157,1,9);
		coordinateList.push([[fallList[0][0],fallList[0][1],fallList[0][2],fallList[0][3],fallList[0][4],fallList[0][5],fallList[0][6],fallList[0][6],fallList[0][6],fallList[0][7],fallList[0][7],fallList[0][6],fallList[0][6],fallList[0][7],fallList[0][8]]]);
		//图片位置数据
		var locationList = new Array();
		locationList.push({x:0,y:0});
		locationList.push({x:0,y:0});
		locationList.push({x:0,y:0});
		locationList.push({x:0,y:0});
		locationList.push({x:20,y:20});
		locationList.push({x:20,y:20});
		locationList.push({x:20,y:20});
		locationList.push({x:0,y:0});
		locationList.push({x:100,y:0});
		locationList.push({x:150,y:20});
		locationList.push({x:5,y:0});
		locationList.push({x:-30,y:10});
		//被攻击范围
		var hertList = [[[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50],[-30,-60,60,50]],
		[[-30,-70,50,60],[-30,-70,50,60],[-30,-70,50,60],[-30,-70,50,60],[-30,-70,50,60],[-30,-70,50,60],[-30,-70,50,60],[-30,-70,50,60]],
		[[-30,-70,60,60],[-30,-70,60,60],[-30,-70,60,60],[-30,-70,60,60],[-30,-70,60,60],[-30,-70,60,60]],
		[[-25,-70,50,60],[-25,-70,50,60],[-25,-70,50,60],[-25,-70,50,60],[-25,-70,50,60]],
		[[-10,-60,30,60],[-10,-60,30,60],[-30,-60,30,60],[-30,-60,30,60]],
		[[0,-60,40,60],[0,-60,40,60],[-20,-60,30,60],[-20,-60,30,60]],
		[],
		[[-20,-60,30,60],[-20,-60,30,60],[-20,-60,30,60],[-20,-60,30,60],[-20,-60,30,60],[-20,-60,30,60]],
		[[0,-70,40,60],[0,-70,40,60]],
		[],[],[]
		];
		//攻击范围
		var attackList = [[],[],[],[],
		[[0,0,0,0],[0,0,0,0],[-10,-70,115,60],[-10,-70,115,60]],
		[[0,0,0,0],[0,0,0,0],[-10,-100,140,90],[-10,-100,140,90]],
		[[0,0,0,0],[0,0,0,0],[-10,-130,115,60],[-10,-110,140,120]],
		[[10,-70,30,70],[10,-70,30,70],[10,-70,30,70],[10,-70,30,70],[10,-70,30,70],[10,-70,30,70]],
		[[0,0,0,0],[0,0,0,0],[-40,-70,80,60],[-60,-100,80,60],[20,-100,130,100],[20,-100,130,100]],
		[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],
		[50,-105,50,20],[60,-100,120,40],[60,-90,150,40],[50,-80,190,40],[50,-80,210,40],
		[50,-75,310,60],[50,-75,310,60],[50,-75,310,60],[50,-75,310,80]],[],[]
		];
		return [dataList,coordinateList,locationList,hertList,attackList];
	},
	sunji:function(){
		//图片数据
		var dataList = new Array();
		dataList.push(new LBitmapData(imglist["sunji_stand"],0,0,129,89));
		dataList.push(new LBitmapData(imglist["sunji_move"],0,0,128,97));
		dataList.push(new LBitmapData(imglist["sunji_run"],0,0,125,77));
		dataList.push(new LBitmapData(imglist["sunji_jump"],0,0,131,134));
		dataList.push(new LBitmapData(imglist["sunji_attack"],0,0,197,103));
		dataList.push(new LBitmapData(imglist["sunji_big_attack"],0,0,198,103));
		dataList.push(new LBitmapData(imglist["sunji_jump_attack"],0,0,182,143));
		dataList.push(new LBitmapData(imglist["sunji_hit"],0,0,238,86));
		dataList.push(new LBitmapData(imglist["sunji_skill"],0,0,215,102));
		dataList.push(new LBitmapData(imglist["sunji_big_skill"],0,0,275,139));
		dataList.push(new LBitmapData(imglist["sunji_hert"],0,0,131,79));
		dataList.push(new LBitmapData(imglist["sunji_fall"],0,0,249,136));
		//图片分割数据
		var coordinateList = new Array();
		coordinateList.push(LGlobal.pideCoordinate(1548,89,1,12));
		coordinateList.push(LGlobal.pideCoordinate(640,97,1,5));
		coordinateList.push(LGlobal.pideCoordinate(1000,77,1,8));
		var jumpList = LGlobal.pideCoordinate(655,134,1,5);
		coordinateList.push([[jumpList[0][0],jumpList[0][0],jumpList[0][1],jumpList[0][1],jumpList[0][2],jumpList[0][2],jumpList[0][3],jumpList[0][3],jumpList[0][4],jumpList[0][4]]]);
		var attackList = LGlobal.pideCoordinate(394,103,1,2);
		coordinateList.push([[attackList[0][0],attackList[0][1],attackList[0][1],attackList[0][1]]]);
		var bigattackList = LGlobal.pideCoordinate(792,103,1,4);
		coordinateList.push(bigattackList);
		var jumpattackList = LGlobal.pideCoordinate(728,143,1,4);
		coordinateList.push(jumpattackList);
		coordinateList.push(LGlobal.pideCoordinate(1428,86,1,6));
		coordinateList.push(LGlobal.pideCoordinate(2365,102,1,11));
		var bigskillList = LGlobal.pideCoordinate(1650,695,5,6);
		coordinateList.push([[bigskillList[0][0],bigskillList[0][1],bigskillList[0][2],bigskillList[0][3],bigskillList[0][4],bigskillList[0][5]
				,bigskillList[1][0],bigskillList[1][1],bigskillList[1][2],bigskillList[1][3],bigskillList[1][4],bigskillList[1][5]
				,bigskillList[2][0],bigskillList[2][1],bigskillList[2][2],bigskillList[2][3],bigskillList[2][4],bigskillList[2][5]
				,bigskillList[3][0],bigskillList[3][1],bigskillList[3][2],bigskillList[3][3],bigskillList[3][4],bigskillList[3][5]
				,bigskillList[4][0],bigskillList[4][1],bigskillList[4][2],bigskillList[4][3],bigskillList[4][4],bigskillList[4][5]]]);
		var hertList = LGlobal.pideCoordinate(262,79,1,2);
		coordinateList.push([[hertList[0][0],hertList[0][0],hertList[0][1],hertList[0][1]]]);
		var fallList = LGlobal.pideCoordinate(1245,544,4,5);
		coordinateList.push([[fallList[0][0],fallList[0][1],fallList[0][2],fallList[0][3],fallList[0][4],fallList[1][0],fallList[1][1],fallList[1][2],fallList[1][3],fallList[1][4],fallList[2][0],fallList[2][1],fallList[2][2],fallList[2][3],fallList[2][4],fallList[3][0],fallList[3][1],fallList[3][2],fallList[3][3],fallList[3][4]]]);
		//图片位置数据
		var locationList = new Array();
		locationList.push({x:0,y:0});
		locationList.push({x:0,y:0});
		locationList.push({x:0,y:0});
		locationList.push({x:0,y:0});
		locationList.push({x:40,y:8});
		locationList.push({x:20,y:0});
		locationList.push({x:20,y:20});
		locationList.push({x:0,y:0});
		locationList.push({x:0,y:0});
		locationList.push({x:70,y:10});
		locationList.push({x:5,y:0});
		locationList.push({x:-35,y:0});
		//被攻击范围
		var hertList = [[[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60],[-25,-70,60,60]],
		        		[[-25,-90,50,80],[-25,-90,50,80],[-25,-90,50,80],[-25,-90,50,80],[-25,-90,50,80],[-25,-90,50,80],[-25,-90,50,80],[-25,-90,50,80]],
		        		[[-30,-60,70,40],[-30,-60,70,40],[-30,-60,70,40],[-30,-60,70,40],[-30,-60,70,40],[-30,-60,70,40]],
		        		[[-25,-90,50,70],[-25,-90,50,70],[-25,-90,50,70],[-25,-90,50,70],[-25,-90,50,70]],
		        		[[-20,-80,50,70],[-20,-80,50,70],[-10,-60,70,50],[-10,-60,70,50]],
		        		[[-10,-80,50,60],[-10,-80,50,60],[-10,-80,50,60],[-10,-80,50,60]],
		        		[[-30,-80,50,70],[-30,-80,50,70],[-30,-80,50,70],[-30,-80,50,70]],
		        		[[-20,-70,60,60],[-20,-70,60,60],[-20,-70,60,60],[-20,-70,60,60],[-20,-70,60,60],[-20,-70,60,60]],
		        		[[-10,-80,40,70],[-10,-80,40,70]],
		        		[],[],[]
		        		];
		//攻击范围
		var attackList = [[],[],[],[],
			          		[[0,0,0,0],[0,0,0,0],[30,-70,75,60],[30,-70,75,60]],
			          		[[0,0,0,0],[0,0,0,0],[20,-100,80,90],[20,-100,80,90]],
			          		[[0,0,0,0],[0,0,0,0],[-10,-90,100,80],[-10,-90,100,80]],
			          		[[10,-70,50,70],[10,-70,50,70],[10,-70,50,70],[10,-70,50,70],[10,-70,50,70],[10,-70,50,70]],
			          		[[0,0,0,0],[0,0,0,0],[-30,-70,90,60],[-90,-70,130,60],[-100,-80,140,70],[-40,-80,140,70]],
			          		[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,-100,100,40],[0,-110,100,50],[0,-110,100,50],
			          		[0,0,0,0],[20,-120,140,120],[20,-120,130,120],[-50,-120,160,120],[-60,-80,180,80],
			          		[-20,-50,150,60],[-10,-60,150,60],[50,-60,90,60],[50,-75,150,70],[50,-75,150,70],
			          		[50,-75,150,70],[50,-75,150,70]],[],[]
			          		];
		return [dataList,coordinateList,locationList,hertList,attackList];
	}
}
로그인 후 복사

이러한 사전 설정된 범위를 사용하여 충돌을 감지하면 이러한 직사각형 충돌을 감지하는 방법은 무엇입니까? 물론 lufylegend.js 엔진의 사각형 클래스 LRectangle이 사용됩니다. 구체적인 사용법은 공식 API 문서를 참조하세요. 이번에 사용된 충돌 감지는 intersects() 함수입니다. 객체가 겹쳐지는지, 즉 충돌할지 여부입니다.

우리 쪽과 장소 모두 공격을 받을 수 있으므로 공격 감지는 상위 클래스인 Character에 탑재하고, Character 클래스의 onframe 함수에 다음 코드를 추가합니다.

if(self.action == ACTION.ATTACK || self.action == ACTION.BIG_ATTACK || self.action == ACTION.HIT || 
			self.action == ACTION.JUMP_ATTACK || self.action == ACTION.SKILL || self.action == ACTION.BIG_SKILL){
		for(key in charaLayer.childList){
			chara = charaLayer.childList[key];
			if(self.belong == chara.belong)continue;
			self.checkAction(chara);
		}
	}
로그인 후 복사

즉, 현재 캐릭터의 행동이 공격 또는 기타 행동이고, 적일 경우 공격 감지 checkAction 함수가 들어갑니다. checkAction 함수는 다음과 같습니다.

Character.prototype.checkAction = function (chara){
	var self = this;
	var attack_rect = self.getAttackRect();
	var hert_rect = chara.getHertRect();
	if(!attack_rect || !hert_rect)return;
	if(attack_rect.intersects(hert_rect) && Math.abs(self.y - chara.y) < 30){
		if(self.action == ACTION.ATTACK){
			chara.setAction(ACTION.HERT,chara.direction);
		}else{
			var dir = DIRECTION.RIGHT;
			if(self.x < chara.x)dir = DIRECTION.LEFT;
			chara.setAction(ACTION.FALL,dir);
		}
	}
}
로그인 후 복사

getAttackRect函数和getHertRect函数分别返回当前的攻击和被攻击的范围LRectangle对象,然后通过intersects函数判断是否攻击到了对方,如果是普通攻击,则被攻击方变为被攻击状态,其他攻击方式的话,变为摔倒状态。

getAttackRect和getHertRect函数如下。

Character.prototype.getAttackRect = function(){
	var self = this;
	attackList = self.attackList[self.action];
	if(self.anime.colIndex >= attackList.length)return false;
	var rect = attackList[self.anime.colIndex];
	var x = rect[0],y=rect[1],w=rect[2],h=rect[3];
	if(x == 0 && y == 0 && w == 0 && h == 0)return false;
	y += self.y;
	if(self.direction == DIRECTION.LEFT){
		x = self.x - x - w;
	}else{
		x = self.x +x;
	}
	return new LRectangle(x,y,w,h);
}
Character.prototype.getHertRect = function(){
	var self = this;
	var hertList = self.hertList[self.action];
	if(self.anime.colIndex >= hertList.length)return false;
	var rect = hertList[self.anime.colIndex];
	var x = rect[0],y=rect[1],w=rect[2],h=rect[3];
	if(x == 0 && y == 0 && w == 0 && h == 0)return false;
	y += self.y;
	if(self.direction == DIRECTION.LEFT){
		x = self.x - x - w;
	}else{
		x = self.x +x;
	}
	return new LRectangle(x,y,w,h);
}
로그인 후 복사

好了,剩下的敌人的AI和声效等部分,咱们留着以后再继续。现在,大家可以点击下面的测试连接,看看本次的成果了

http://lufy.netne.net/lufylegend-js/act03/index.html

黄老将军听说即将登场的是孙尚香后激动不已,那叫一个美啊,眼睛整个眯成了一个心形,大吼着,尚香啊,老夫等你几百年了。这是在令我大吃一惊,孙尚香不是刘备老婆吗,是这老家伙的主子啊,这真是太不像话了。可老将军在一旁兴奋的吼着,“靠!我会让你知道我暗恋她几百年吗?老夫绝对不会承认的。”,“如果当年我年轻个几十年,呸,我怎么会这么想,她毕竟是主公的老婆。”,“不对,主公也老了。啊,老夫可是忠臣,我是不会跟主公抢的。”,“老夫什么都没说。lufy,你给我听着,老夫什么都没说。”。我急忙说“啊啊,我什么都没听见啊……”

不过,这有什么用啊,这老家伙一上场,就开始往前跑,边跑边嘟囔“妞,给大爷摸一个……”。由于某种原因,这里省略1000字。

终于,孙尚香出现了,老黄忠一下子就扑了过去,刚伸手去摸了一把,就发现孙尚香被他打的满地跑,立马吼道“lufy,老夫要的是摸,不是砍啊”。

lufy:“哼哼,老色鬼,我岂能给你方便,让你得逞……”,另外他还不知道在前面,还给他准备了另一个黄忠,一个孙尚香,看他们怎么抢吧,哈哈。

唉,真是:
神箭威名数黄忠,斩将杀敌显神通。百年宝刀仍未老,一遇红颜梦成空。

源码

现在给出本次源码下载,喜欢的可以看一下。

http://fsanguo.comoj.com/download.php?i=act03.rar

注意:该附件只包含本次文章源码,lufylegend.js引擎请到http://lufylegend.com/lufylegend进行下载。

 以上就是[HTML5游戏开发]挑战横版ACT(三):遇红颜英雄亦多情的内容,更多相关内容请关注PHP中文网(www.php.cn)!


관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!