以下是 愤怒的小鸟html5网页游戏特效代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>愤怒的小鸟html5网页游戏</title>
<script type="text/javascript" src="lib/Box2dWeb-2.1.a.3.min.js"></script>
<script type="text/javascript" src="lib/lufylegend-1.9.1.js"></script>
<script type="text/javascript" src="main/Main.js"></script>
<script type="text/javascript">
init(10,"mylegend",800,480,main);
</script>
<style>
#chinaz {width:778px; margin:0 auto; text-align:center;}
</style>
</head>
<body>
<div id="chinaz">
<div id="mylegend">loading……</div>
</div>
</body>
</html>
JS代码(Pig.js):
function Pig(){
base(this,LSprite,[]);
var self = this;
self.hp = 200;
self.name = "pig";
self.list = ["pig01","pig02"];
self.bitmap = new LBitmap(new LBitmapData(imglist[self.list[0]]));
self.addChild(self.bitmap);
self.addBodyCircle(24,self.bitmap.getHeight()*0.5,self.bitmap.getWidth()*0.5,1,5,.4,.13);
}
Pig.prototype.hit = function(value){
var self = this;
if(value < 10)return;
if(self.hp == 200)self.bitmap.bitmapData = new LBitmapData(imglist[self.list[1]]);
self.hp -= value;
}
JS代码(Stage.js):
function Stage(list,rotate,m,ctrl){
base(this,LSprite,[]);
var self = this;
self.name = "stage";
self.ctrl = ctrl;
self.list = list;
self.bitmap = new LBitmap(new LBitmapData(imglist[self.list[0]]));
self.hp = 200;
self.addChild(self.bitmap);
self.addBodyPolygon(self.bitmap.getWidth(),self.bitmap.getHeight(),1,m,.4,.2);
if(rotate != 0)self.setRotate(rotate*Math.PI/180);
}
Stage.prototype.hit = function(value){
var self = this;
if(!self.ctrl)return;
if(value < 1)return;
if(self.hp == 200)self.bitmap.bitmapData = new LBitmapData(imglist[self.list[1]]);
self.hp -= value;
}