支付宝赞助帐号:service@kuitao8.com 

下载地址

html5开发的一个简单游戏教程

Created2013-08-05   Views 1285    Author 懒人程序
html5开发的一个简单游戏教程
更多html电子书载 请进入http://www.kuitao8.com/cdbook
function handleInteractions(){
	// up arrow
	// 1
	var collision = world.m_contactList;
	player.canJump = false;
	if (collision != null){
		if (collision.GetShape1().GetUserData() == 'player' || collision.GetShape2().GetUserData() == 'player'){
			if ((collision.GetShape1().GetUserData() == 'ground' || collision.GetShape2().GetUserData() == 'ground')){
				var playerObj = (collision.GetShape1().GetUserData() == 'player' ? collision.GetShape1().GetPosition() :  collision.GetShape2().GetPosition());
				var groundObj = (collision.GetShape1().GetUserData() == 'ground' ? collision.GetShape1().GetPosition() :  collision.GetShape2().GetPosition());
				if (playerObj.y < groundObj.y){
					player.canJump = true;
				}
			}
		}
	}
	// 2
	var vel = player.object.GetLinearVelocity();
	// 3
	if (keys[38] && player.canJump){
		vel.y = -150;	
	}
	
	// 4
	// left/right arrows
	if (keys[37]){
		vel.x = -60;
	}
	else if (keys[39]){
		vel.x = 60;
	}
	
	// 5
	player.object.SetLinearVelocity(vel);
}

上一篇: html5例子批量下载
下一篇: html游戏教程免费下载
支持键盘 ← →

邮件订阅

订阅我们的精彩内容