<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>狼的传说</title>
<script src="../phaser.min.js"></script>
<script src="./js/plus.js"></script>
<script src="./assets/sprites/wolf.js"></script>
<script src="./assets/sprites/restore.js"></script>
<script src="./assets/sprites/rattan.js"></script>
<script src="./assets/sprites/ridding.js"></script>
<style>
body{
margin: 0%;
padding: 0%;
}
</style>
</head>
<body>
</body>
<script>
// import './js/libs/weapp-adapter'
// import Phaser from './js/libs/phaser-wx.js'
// import Demon from './assets/demon.js'
//技能图标 1.防御0 2.战斧0 3.风暴3% 4.滚石10% 5.藤曼5% 6.冰柱5% 7.飞跃10% 8.三叶草20% 9.钢叉15%
onload = function(){
var gameScore = 0;
var game = new Phaser.Game({
width: 710,
height: 580,
renderer: Phaser.CANVAS,
// canvas: canvas,
});
var gameState = function (game) {
this.create = function () {
this.game.physics.startSystem(Phaser.Physics.ARCADE);//开启物理引擎
this.bg = this.add.image(0,0,'background');//背景
this.grass = this.add.image(0,0,'battlefield');//草坪
this.underRails = this.add.sprite(0,0,'under-rails');//底座
this.game.physics.arcade.enable(this.underRails);
this.rails = this.add.image(0,0,'rails');//滑道
this.rails.y = 81;
this.underRails.y = 81;
this.underRails.width = this.rails.width;
this.underRails.height = this.rails.height;
this.sky = this.add.image(0,0,'sky');//天空
this.earth = this.add.image(0,0,'earth');//土地
this.wagon = this.add.image(0,this.underRails.y -10,'wagon');//滑板 第一道-10 第二道60 第三道130 第四道200 第五道270 第六道340 累加70
this.wires = this.add.sprite(this.underRails.width,this.underRails.y,'wires');//荆棘
this.wires.active = false;//需要技能图标1 防御 激活
this.wires.hp = 20;
this.wires.hp_ = this.wires.hp;
this.wires.dt = 0;
this.wires.alpha = 0;
this.game.physics.arcade.enable(this.wires);
this.wolf = this.add.image(7,this.wagon.y - 40,'wolf');//狼
this.wolf.y_ = this.wolf.y;
this.wolf.animations.add('walk', [4, 5, 6, 7], 3, true);
this.wolf.animations.add('attack', [0,1, 2, 3], 5, true);
this.attack = false;
this.wolf.animations.play('walk');
this.wolf.bulletSpeed = 60;//quicken 加快 更活跃
this.axe = this.add.image(0,0,'axe');//武器axe hp==1
this.axe.alpha = 0;
this.fork = this.add.image(0,0,'fork');//武器fork hp==2
this.fork.alpha = 0;
this.weapon = this.add.weapon(50,'axe');//武器 //优化时 更换为group weapon.bullets 子弹行为
if (this.weapon.bullets.children[0].key=='axe') {//武器耐性
this.weapon.hp = 1;
}
if (this.weapon.bullets.children[0].key=='fork') {//值
this.weapon.hp = 3;
}
this.weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS;
this.weapon.fireAngle = Phaser.ANGLE_RIGHT;
this.weapon.bulletAngleOffset = 90;
this.weapon.bulletSpeed = 400;
this.weapon.fireRate = 60;
this.weapon.trackSprite(this.wolf, this.wolf.width, this.wolf.height/1.3);
this.pigs = this.add.group();//猪
this.pigs.enableBody = true;
this.skills = this.add.group();//技能图标
for (var i = 0; i < 9; i++) {
let skillIcon = this.skills.create(0,0,'skills');
skillIcon.x = 13 + i * skillIcon.width + i * 13;
skillIcon.y = this.bg.height - 13 - skillIcon.height;
skillIcon.frame = i;
skillIcon.inputEnabled = true;
// if (i>0) {skillIcon.alpha = 0;}
}
this.storm = this.add.group();//技能图标3 风暴 将敌人推出边界
this.storm.enableBody = true;
this.stone = this.add.group();//技能图标4 滚石 碾过敌人
this.stone.enableBody = true;
this.rattan = this.add.group();//技能图标5 藤曼 迟缓诅咒
this.rattan.enableBody = true;
this.ice = this.add.group();//技能图标6 冰冻 冻住敌人
this.ice.enableBody = true;
this.skills.getChildAt(0).events.onInputDown.add(function(){//技能图标1 道具 荆棘防御
this.wires.active = true;
game.add.tween(this.wires).to( { alpha: 1 }, 3000, "Linear", true).onComplete.add(function(){
this.wires.act = true;
},this);
this.skillMask(this.skills.getChildAt(0),100000000);
}, this);
this.skills.getChildAt(1).events.onInputDown.add(function(){//技能图标2 武器 战斧
this.attack = true;
this.wolf.animations.play('attack');
this.weaponReplace(this.weapon,this.axe,this.fork,1);
this.skillMask(this.skills.getChildAt(1),1000000);
}, this);
this.skills.getChildAt(2).events.onInputDown.add(function(){//技能图标3 技能 风暴
if (this.energyEnabled == false) {
return false;
}
this.energy.width -= (this.energy.sum * 3/100);
if (this.storm.length>0) {//风暴出界 风消云散
for (var i = 0; i < this.storm.length; i++) {
if (this.storm.getChildAt(i).x>this.game.world.width) {
this.storm.getChildAt(i).destroy();
}
}
}
for (var i = 0; i < 6; i++) {//六个道路
this.storm_ = this.storm.create(0,0,'storm');
this.storm_.scale.set(2.5);
this.storm_.x = this.underRails.width;
this.storm_.y = 70 + i * 70;
this.storm_.animations.add('storm',[0,1,2,3],5,true);
this.storm_.animations.play('storm');
this.storm_.body.velocity.x = 300;
}
this.skillMask(this.skills.getChildAt(2),3000);//3s
}, this);
this.skills.getChildAt(3).events.onInputDown.add(function(){//技能图标4 技能 滚石
this.iceTo = false;
if (this.energyEnabled == false) {
return false;
}
this.energy.width -= (this.energy.sum * 1/10);
if (this.stone.length>0) {//滚石出界
for (var i = 0; i < this.stone.length; i++) {
if (this.stone.getChildAt(i).x>this.game.world.width) {
this.stone.getChildAt(i).destroy();
}
}
}
for (var i = 0; i < 6; i++) {//六个道路
this.stone_ = this.stone.create(0,0,'stone');
this.stone_.scale.set(2);
this.stone_.x = this.underRails.width + this.wires.width - this.stone_.width;
this.stone_.y = i * 70;
this.stone_.animations.add('stone',[0,1,2,3,4,5,6,7,8,9],5,true);
this.stone_.animations.play('stone');
this.stone_.body.velocity.x = 500;
}
this.skillMask(this.skills.getChildAt(3),10000);//10s
}, this);
this.skills.getChildAt(4).events.onInputDown.add(function(){//技能图标5 道具 藤曼 迟缓诅咒
if (this.energyEnabled == false) {
return false;
}
this.energy.width -= (this.energy.sum * 1/20);
for (let i = 0; i < this.pigs.length; i++) {//生成敌人数目的藤曼
this.rattan_ = this.rattan.create(0,0,'rattan');
this.rattan_.scale.set(.5);
this.rattan_.animations.add('rattan');
this.rattan_.x = this.pigs.getChildAt(i).x - this.pigs.getChildAt(i).width/2;
this.rattan_.y = this.pigs.getChildAt(i).y;
this.pigs.getChildAt(i).body.velocity.x = -30;
var that = this;
没有合适的资源?快使用搜索试试~ 我知道了~
html基础资源大全ll

共3765个文件
png:1996个
js:590个
mp3:237个

需积分: 0 7 浏览量
2023-03-31
19:50:09
上传
评论
收藏 152.91MB ZIP 举报
收集的全部html资源
资源推荐
资源详情
资源评论















收起资源包目录





































































































共 3765 条
- 1
- 2
- 3
- 4
- 5
- 6
- 38
资源评论


ercuj255
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
