javascript實現(xiàn)飛機大戰(zhàn)小游戲
更新時間:2022年05月08日 09:17:33 作者:絨尾
這篇文章主要為大家詳細(xì)介紹了javascript實現(xiàn)飛機大戰(zhàn)小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了javascript實現(xiàn)飛機大戰(zhàn)游戲的具體代碼,供大家參考,具體內(nèi)容如下
文檔結(jié)構(gòu)如下

其中tool文件中只使用了隨機數(shù),audio中是存放的音樂文件,images中是己方和敵方飛機的圖片。

HTML部分
<!DOCTYPE html> <html lang="en"> <head> ? ? <meta charset="UTF-8"> ? ? <meta http-equiv="X-UA-Compatible" content="IE=edge"> ? ? <meta name="viewport" content="width=device-width, initial-scale=1.0"> ? ? <title>Document</title> ? ? <link rel="stylesheet" href="css/game.css" > </head> <body> ? ? <section> ? ? ? ? <input type="button" value="GAME START" id="btn"> ? ? ? ? <div id="socre"> ? ? ? ? ? ? <p id="num">當(dāng)前分?jǐn)?shù)為:</p> ? ? ? ? ? ? <p id="historynum">歷史最高:</p> ? ? ? ? </div> ? ? </section> ? ? ? <script src="js/tool.js"></script> ? ? <script src="js/game.js"></script> </body> </html>
CSS部分
section{
? ? background-image: url(../material/images/startBG.png);
? ? background-repeat: no-repeat;
? ? background-size: 320px,570px;
? ? width: 320px;
? ? height: 570px;
? ? margin: auto;
? ? margin-top: 30px;
? ? position: relative;
? ? overflow: hidden;
}
?
section>input{
? ? width: 150px;
? ? position: absolute;
? ? bottom: 65px;
? ? left: 85px;
}
?
#socre{
? ? display: none;
}JS部分
主要是通過類方法創(chuàng)建敵機和我方飛機,再通過類的繼承給予小/中/大/boss等敵機屬性和方法。
const section = document.querySelector("section");
const enemy = document.getElementsByClassName("enemys");
let [flag1, flag2, flag3, flag4] = [false, false, false, false];
//小飛機
let splane;
//中飛機
let mplane;
//大飛機
let bplane;
//boss
let boss;
let shoot;
let bossshoot;
//得分
let number;
let move1;
//本地獲取數(shù)據(jù)
let arr = localStorage.getItem("scort");
arr = JSON.parse(arr);
//音頻
var mp3;
var gameover;
var bossrun;
?
//游戲開始
btn.addEventListener("click", function () {
? ? //console.log(gameover);
? ? if (gameover) {
? ? ? ? gameover.pause();
? ? }
? ? mp3 = "./material/audio/bgm.mp3";
? ? mp3 = new Audio(mp3);
? ? mp3.play(); //播放mp3這個音頻對象
?
? ? //計算分?jǐn)?shù)
? ? number = 0;
? ? num.innerText = `當(dāng)前分?jǐn)?shù)為:0`;
? ? //從本地獲取分?jǐn)?shù)
? ? arr = localStorage.getItem("scort");
? ? arr = JSON.parse(arr);
? ? const newmyplane = document.getElementById("myplane");
? ? if (newmyplane) {
? ? ? ? section.removeChild(newmyplane)
? ? }
?
? ? //判斷本地是否有數(shù)據(jù)
? ? if (arr == null) {
? ? ? ? historynum.innerText = `歷史最高:0`
? ? } else {
? ? ? ? historynum.innerText = `歷史最高:${arr}`
? ? }
? ? //得分面板
? ? socre.style.display = "block";
? ? btn.style.display = "none";
? ? //更改背景
? ? section.style.backgroundImage = "url(./material/images/background_1.png)";
? ? //實例化自身飛機
? ? let myplane = new Myplane(0, 127);
? ? //實例化敵機
? ? splane = setInterval(
? ? ? ? function () {
? ? ? ? ? ? let smallenemys = new Smallenemys(random(0, 286), "material/images/enemy1_fly_1.png", -24, 1);
? ? ? ? }, 1000)
? ? mplane = setInterval(
? ? ? ? function () {
? ? ? ? ? ? let midenemys = new Midenemys(random(0, 274), "material/images/enemy3_fly_1.png", -60, 3);
? ? ? ? }, 6000)
? ? bplane = setInterval(
? ? ? ? function () {
? ? ? ? ? ? let bigenemys = new Bigenemys(random(0, 210), "material/images/enemy2_fly_1.png", -164, 10);
? ? ? ? }, 10000)
?
? ? boss = setInterval(
? ? ? ? function () {
? ? ? ? ? ? let boss = new Bossenemys(random(0, 210), "material/images/boss.png", -118, 20);
? ? ? ? ? ? bossrun = "./material/audio/bossrun.mp3";
? ? ? ? ? ? bossrun = new Audio(bossrun);
? ? ? ? ? ? bossrun.play(); //播放mp3這個音頻對象
? ? ? ? ? ? //延遲器
? ? ? ? ? ? setTimeout(() => {
? ? ? ? ? ? ? ? bossrun.pause();
? ? ? ? ? ? }, 3000)
? ? ? ? }, 50000)
?
});
?
//己方飛機
class Myplane {
? ? constructor(firstbot, firstleft) {
? ? ? ? this.node = document.createElement("img");
? ? ? ? // console.log(this.node);
? ? ? ? this.firstbot = firstbot;
? ? ? ? this.firstleft = firstleft;
? ? ? ? this.init();
? ? }
?
? ? init() {
? ? ? ? this.create();
? ? ? ? this.render();
? ? ? ? this.action();
? ? ? ? this.crash();
? ? ? ? shoot = setInterval(() => {
? ? ? ? ? ? let bullet = new Bullet(this.firstbot + 80, this.firstleft + 31);
? ? ? ? ? ? num.innerText = `當(dāng)前分?jǐn)?shù)為:${number}`
?
? ? ? ? }, 230)
? ? }
?
? ? render() {
? ? ? ? Object.assign(this.node.style, {
? ? ? ? ? ? position: `absolute`,
? ? ? ? ? ? bottom: `${this.firstbot}px`,
? ? ? ? ? ? left: `${this.firstleft}px`,
? ? ? ? })
? ? }
?
? ? create() {
? ? ? ? this.node.setAttribute('src', 'material/images/myPlane.gif');
? ? ? ? this.node.setAttribute('id', 'myplane')
? ? ? ? section.appendChild(this.node);
? ? }
?
? ? action() {
? ? ? ? //鍵盤按下
? ? ? ? document.addEventListener("keydown", (event) => {
? ? ? ? ? ? if (this.move) {
? ? ? ? ? ? ? ? this.move(event);
? ? ? ? ? ? }
?
? ? ? ? });
? ? ? ? //鍵盤抬起
? ? ? ? document.addEventListener("keyup", function (event) {
? ? ? ? ? ? switch (event.key) {
? ? ? ? ? ? ? ? case "w":
? ? ? ? ? ? ? ? ? ? flag1 = false;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "a":
? ? ? ? ? ? ? ? ? ? flag2 = false;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "s":
? ? ? ? ? ? ? ? ? ? flag3 = false;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "d":
? ? ? ? ? ? ? ? ? ? flag4 = false;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
?
? ? ? ? })
?
? ? }
? ? //移動
? ? move(event) {
? ? ? ? switch (event.key) {
? ? ? ? ? ? case "w":
? ? ? ? ? ? ? ? flag1 = true;
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case "a":
? ? ? ? ? ? ? ? flag2 = true;
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case "s":
? ? ? ? ? ? ? ? flag3 = true;
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? case "d":
? ? ? ? ? ? ? ? flag4 = true;
? ? ? ? ? ? ? ? break;
? ? ? ? }
? ? ? ? if (move1) {
? ? ? ? ? ? clearInterval(move1)
? ? ? ? }
? ? ? ? move1 = setInterval(() => {
? ? ? ? ? ? //左側(cè)邊框
? ? ? ? ? ? if (flag2) {
? ? ? ? ? ? ? ? if (parseInt(getComputedStyle(this.node).left) <= 0) {
? ? ? ? ? ? ? ? ? ? this.firstleft = 0;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? this.firstleft -= 2;
? ? ? ? ? ? ? ? this.render()
? ? ? ? ? ? }
? ? ? ? ? ? //上側(cè)邊框
? ? ? ? ? ? else if (flag1) {
? ? ? ? ? ? ? ? this.firstbot += 2;
? ? ? ? ? ? ? ? if (parseInt(getComputedStyle(this.node).bottom) >= 490) {
? ? ? ? ? ? ? ? ? ? this.firstbot = 490;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? this.render()
? ? ? ? ? ? }
? ? ? ? ? ? //右側(cè)邊框
? ? ? ? ? ? else if (flag4) {
? ? ? ? ? ? ? ? if (parseInt(getComputedStyle(this.node).left) >= 255) {
? ? ? ? ? ? ? ? ? ? this.firstleft = 255;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? this.firstleft += 2;
? ? ? ? ? ? ? ? this.render()
?
? ? ? ? ? ? }
? ? ? ? ? ? //下側(cè)邊框
? ? ? ? ? ? else if (flag3) {
? ? ? ? ? ? ? ? if (parseInt(getComputedStyle(this.node).bottom) <= 0) {
? ? ? ? ? ? ? ? ? ? this.firstbot = 0;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? this.firstbot -= 2;
? ? ? ? ? ? ? ? this.render()
? ? ? ? ? ? }
? ? ? ? ? ? this.render()
? ? ? ? }, 10)
?
?
? ? }
?
? ? crash() {
? ? ? ? let time = setInterval(() => {
? ? ? ? ? ? let bottom = parseInt(getComputedStyle(this.node).bottom);
? ? ? ? ? ? let left = parseInt(getComputedStyle(this.node).left);
? ? ? ? ? ? for (let item of enemy) {
? ? ? ? ? ? ? ? //碰撞判斷
? ? ? ? ? ? ? ? if (bottom <= parseInt(getComputedStyle(item).bottom) + parseInt(getComputedStyle(item).height) &&
? ? ? ? ? ? ? ? ? ? bottom >= parseInt(getComputedStyle(item).bottom) - parseInt(getComputedStyle(this.node).height) &&
? ? ? ? ? ? ? ? ? ? left >= parseInt(getComputedStyle(item).left) - parseInt(getComputedStyle(this.node).width) &&
? ? ? ? ? ? ? ? ? ? left <= parseInt(getComputedStyle(item).left) + parseInt(getComputedStyle(item).width)) {
?
? ? ? ? ? ? ? ? ? ? this.node.setAttribute('src', 'material/images/本方飛機爆炸.gif');
? ? ? ? ? ? ? ? ? ? this.move = null;
?
? ? ? ? ? ? ? ? ? ? //游戲結(jié)束時清除除自身外飛機
? ? ? ? ? ? ? ? ? ? for (let item1 of enemy) {
? ? ? ? ? ? ? ? ? ? ? ? item1.style.display = 'none';
? ? ? ? ? ? ? ? ? ? }
?
? ? ? ? ? ? ? ? ? ? clearInterval(bossshoot);
? ? ? ? ? ? ? ? ? ? clearInterval(time);
? ? ? ? ? ? ? ? ? ? clearInterval(splane);
? ? ? ? ? ? ? ? ? ? clearInterval(mplane);
? ? ? ? ? ? ? ? ? ? clearInterval(bplane);
? ? ? ? ? ? ? ? ? ? clearInterval(shoot);
? ? ? ? ? ? ? ? ? ? clearInterval(boss);
?
? ? ? ? ? ? ? ? ? ? mp3.pause();
?
? ? ? ? ? ? ? ? ? ? gameover = "./material/audio/gameover.mp3";
? ? ? ? ? ? ? ? ? ? gameover = new Audio(gameover);
? ? ? ? ? ? ? ? ? ? gameover.play(); //播放mp3這個音頻對象
? ? ? ? ? ? ? ? ? ? if (arr < number) {
? ? ? ? ? ? ? ? ? ? ? ? localStorage.setItem('scort', JSON.stringify(number));
? ? ? ? ? ? ? ? ? ? ? ? historynum.innerText = `歷史最高:${number}`;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? btn.style.display = "block";
? ? ? ? ? ? ? ? ? ? // alert("游戲結(jié)束");
? ? ? ? ? ? ? ? ? ? // location.reload(true);?
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }, 10)
? ? }
?
};
?
?
//子彈類
class Bullet {
? ? constructor(firstbot, firstleft) {
? ? ? ? this.node = document.createElement("img");
? ? ? ? this.firstbot = firstbot;
? ? ? ? this.firstleft = firstleft;
? ? ? ? this.init();
? ? ? ? // console.log(this.firstbot);
? ? }
?
? ? init() {
? ? ? ? this.create();
? ? ? ? this.render();
? ? ? ? this.move();
? ? ? ? this.crash();
? ? }
?
? ? create() {
? ? ? ? this.node.setAttribute('src', 'material/images/bullet1.png');
? ? ? ? section.appendChild(this.node);
? ? }
? ? render() {
? ? ? ? Object.assign(this.node.style, {
? ? ? ? ? ? position: `absolute`,
? ? ? ? ? ? bottom: `${this.firstbot}px`,
? ? ? ? ? ? left: `${this.firstleft}px`,
? ? ? ? })
? ? }
? ? move() {
? ? ? ? let time = setInterval(() => {
? ? ? ? ? ? this.crash();
? ? ? ? ? ? this.firstbot += 2;
? ? ? ? ? ? if (this.firstbot >= 550 || getComputedStyle(this.node).display == 'none') {
? ? ? ? ? ? ? ? section.removeChild(this.node);
? ? ? ? ? ? ? ? clearInterval(time);
? ? ? ? ? ? }
? ? ? ? ? ? this.render();
? ? ? ? }, 10);
? ? }
? ? //碰撞
?
? ? crash() {
? ? ? ? //獲取所有敵機
? ? ? ? const enemy = document.getElementsByClassName("enemys");
? ? ? ? //console.log(enemy);
? ? ? ? let bottom = parseInt(getComputedStyle(this.node).bottom);
? ? ? ? let left = parseInt(getComputedStyle(this.node).left);
? ? ? ? for (let item of enemy) {
? ? ? ? ? ? //子彈撞擊敵方飛機
? ? ? ? ? ? if (bottom <= parseInt(getComputedStyle(item).bottom) + parseInt(getComputedStyle(item).height) &&
? ? ? ? ? ? ? ? bottom >= parseInt(getComputedStyle(item).bottom) - parseInt(getComputedStyle(this.node).height) &&
? ? ? ? ? ? ? ? left >= parseInt(getComputedStyle(item).left) - parseInt(getComputedStyle(this.node).width) &&
? ? ? ? ? ? ? ? left <= parseInt(getComputedStyle(item).left) + parseInt(getComputedStyle(item).width)) {
? ? ? ? ? ? ? ? // 停止子彈碰撞計時器
? ? ? ? ? ? ? ? this.node.style.display = "none";
? ? ? ? ? ? ? ? item.dataset.id--;
? ? ? ? ? ? ? ? if (item.dataset.id < 0) {
? ? ? ? ? ? ? ? ? ? item.dataset.id = 0;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (parseInt(getComputedStyle(item).width) == 34) {
? ? ? ? ? ? ? ? ? ? if (item.dataset.id == 0) {
? ? ? ? ? ? ? ? ? ? ? ? //圖片替換
? ? ? ? ? ? ? ? ? ? ? ? item.setAttribute('src', 'material/images/小飛機爆炸.gif');
? ? ? ? ? ? ? ? ? ? ? ? //延遲器
? ? ? ? ? ? ? ? ? ? ? ? setTimeout(() => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? item.style.display = "none";
? ? ? ? ? ? ? ? ? ? ? ? }, 300)
? ? ? ? ? ? ? ? ? ? ? ? number += 1;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (parseInt(getComputedStyle(item).width) == 46) {
? ? ? ? ? ? ? ? ? ? if (item.dataset.id == 0) {
? ? ? ? ? ? ? ? ? ? ? ? item.setAttribute('src', 'material/images/中飛機爆炸.gif');
? ? ? ? ? ? ? ? ? ? ? ? setTimeout(() => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? item.style.display = "none";
?
? ? ? ? ? ? ? ? ? ? ? ? }, 300)
? ? ? ? ? ? ? ? ? ? ? ? number += 5;
? ? ? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? ? ? item.setAttribute('src', 'material/images/中飛機挨打.png');
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (parseInt(getComputedStyle(item).width) == 110) {
? ? ? ? ? ? ? ? ? ? if (item.dataset.id == 0) {
? ? ? ? ? ? ? ? ? ? ? ? item.setAttribute('src', 'material/images/大飛機爆炸.gif');
? ? ? ? ? ? ? ? ? ? ? ? //大飛機爆炸
? ? ? ? ? ? ? ? ? ? ? ? let bigboom = "./material/audio/bigboom.mp3";
? ? ? ? ? ? ? ? ? ? ? ? bigboom = new Audio(bigboom);
? ? ? ? ? ? ? ? ? ? ? ? bigboom.play(); //播放mp3這個音頻對象
?
? ? ? ? ? ? ? ? ? ? ? ? setTimeout(() => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? item.style.display = "none";
? ? ? ? ? ? ? ? ? ? ? ? ? ? bigboom.pause();
? ? ? ? ? ? ? ? ? ? ? ? }, 300)
? ? ? ? ? ? ? ? ? ? ? ? number += 30;
? ? ? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? ? ? item.setAttribute('src', 'material/images/大飛機挨打.png');
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
?
? ? ? ? ? ? ? ? //boss爆炸
? ? ? ? ? ? ? ? if (parseInt(getComputedStyle(item).width) == 160) {
? ? ? ? ? ? ? ? ? ? if (item.dataset.id == 0) {
? ? ? ? ? ? ? ? ? ? ? ? item.setAttribute('src', 'material/images/boomx.png');
? ? ? ? ? ? ? ? ? ? ? ? clearInterval(bossshoot);
?
? ? ? ? ? ? ? ? ? ? ? ? let bossover = "./material/audio/bossover.mp3";
? ? ? ? ? ? ? ? ? ? ? ? bossover = new Audio(bossover);
? ? ? ? ? ? ? ? ? ? ? ? bossover.play(); //播放mp3這個音頻對象
?
? ? ? ? ? ? ? ? ? ? ? ? setTimeout(() => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? item.style.display = "none";
? ? ? ? ? ? ? ? ? ? ? ? ? ? bossover.pause();
? ? ? ? ? ? ? ? ? ? ? ? ? ? mp3.play();
? ? ? ? ? ? ? ? ? ? ? ? }, 300)
? ? ? ? ? ? ? ? ? ? ? ? number += 200;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
?
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
?
//敵機
class Enemys {
? ? constructor(x, url, height) {
? ? ? ? this.node = document.createElement("img");
? ? ? ? this.x = x;
? ? ? ? this.y = 546;
? ? ? ? this.url = url;
? ? ? ? this.height = height;
? ? ? ? this.init();
? ? }
?
? ? init() {
? ? ? ? this.create();
? ? ? ? this.render();
? ? ? ? this.move();
? ? }
?
? ? create() {
? ? ? ? this.node.setAttribute('src', this.url);
? ? ? ? this.node.setAttribute('class', "enemys");
? ? ? ? section.appendChild(this.node);
? ? }
? ? render() {
? ? ? ? Object.assign(this.node.style, {
? ? ? ? ? ? position: `absolute`,
? ? ? ? ? ? bottom: `${this.y}px`,
? ? ? ? ? ? left: `${this.x}px`,
? ? ? ? })
?
? ? }
?
? ? move() {
? ? ? ? let enemytime = setInterval(() => {
? ? ? ? ? ? this.y -= 1;
? ? ? ? ? ? if (this.y <= this.height || getComputedStyle(this.node).display == 'none') {
? ? ? ? ? ? ? ? section.removeChild(this.node);
? ? ? ? ? ? ? ? clearInterval(enemytime)
? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? this.render();
? ? ? ? ? ? }
? ? ? ? }, 10);
? ? }
};
?
//小飛機
class Smallenemys extends Enemys {
? ? constructor(x, url, height, hp) {
? ? ? ? super(x, url, height);
? ? ? ? this.hp = hp;
? ? ? ? this.node.dataset.id = hp;
? ? }
?
};
?
//中飛機
class Midenemys extends Enemys {
? ? constructor(x, url, height, hp) {
? ? ? ? super(x, url, height)
? ? ? ? this.hp = hp;
? ? ? ? this.node.dataset.id = hp;
? ? }
};
//大飛機
class Bigenemys extends Enemys {
? ? constructor(x, url, height, hp) {
? ? ? ? super(x, url, height)
? ? ? ? this.hp = hp;
? ? ? ? this.node.dataset.id = hp;
? ? }
};
?
//boss
class Bossenemys extends Enemys {
? ? constructor(x, url, height, hp) {
? ? ? ? super(x, url, height)
? ? ? ? this.hp = hp;
? ? ? ? this.node.dataset.id = hp;
? ? ? ? this.bottom = 570;
? ? ? ? this.left = 80;
? ? ? ? this.render();
? ? ? ? this.move();
? ? ? ? this.shoot();
? ? }
? ? render() {
? ? ? ? Object.assign(this.node.style, {
? ? ? ? ? ? position: `absolute`,
? ? ? ? ? ? bottom: `${this.bottom}px`,
? ? ? ? ? ? left: `${this.left}px`,
? ? ? ? })
? ? }
? ? move() {
? ? ? ? let i = -2;
? ? ? ? let time = setInterval(() => {
? ? ? ? ? ? this.bottom--;
? ? ? ? ? ? if (this.bottom <= 452) {
? ? ? ? ? ? ? ? clearInterval(time);
? ? ? ? ? ? }
? ? ? ? ? ? this.render();
? ? ? ? }, 10);
? ? ? ? let newaction = setTimeout(() => {
? ? ? ? ? ? if (parseInt(getComputedStyle(this.node).bottom) <= 452) {
? ? ? ? ? ? ? ? let transverse = setInterval(() => {
? ? ? ? ? ? ? ? ? ? this.left += i;
? ? ? ? ? ? ? ? ? ? if (this.left <= 0) {
? ? ? ? ? ? ? ? ? ? ? ? i = 2;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? if (this.left >= 160) {
? ? ? ? ? ? ? ? ? ? ? ? i = -2;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? this.render();
? ? ? ? ? ? ? ? }, 50)
? ? ? ? ? ? }
? ? ? ? }, 1000)
? ? }
? ? shoot() {
? ? ? ? bossshoot = setInterval(() => {
? ? ? ? ? ? let midenemys = new Midenemys(this.left + 56, "material/images/fire.png", -117, 1);
? ? ? ? }, 5000)
? ? }
};以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript自定義日期格式化函數(shù)詳細(xì)解析
下面的一個例子就是以獨立函數(shù)寫出的JavaScript日期格式化函數(shù),獨立的format函數(shù)?;氐礁袷交倪@一知識點上,我們考查的是怎么實現(xiàn)的、運用了哪些原理2014-01-01

