纯前端小游戏,4096小游戏,有音效,Html5,可学习使用

复制代码
  // 游戏开始运行
    create: function(){
        this.fieldArray = [];
        this.fieldGroup = this.add.group();
        this.score = 0;//4096 增加得分
        this.bestScore = localStorage.getItem(gameOptions.localStorageName) == null ? 0 : localStorage.getItem(gameOptions.localStorageName);
        for(var i = 0; i < 4; i++){
            this.fieldArray[i] = [];
            for(var j = 0; j < 4; j++){
                var spot = this.add.sprite(this.tileDestination(j, COL), this.tileDestination(i, ROW), "spot")
                var tile = this.add.sprite(this.tileDestination(j, COL), this.tileDestination(i, ROW), "tiles");
                tile.alpha = 0;
                tile.visible = 0;
                this.fieldGroup.add(tile);
                this.fieldArray[i][j] = {
                    tileValue: 0,
                    tileSprite: tile,
                    canUpgrade: true
                }
            }
        }
        var restartButton = this.add.sprite(this.tileDestination(3, COL), this.tileDestination(0, ROW) - 200, "restart");
        restartButton.setInteractive();
        restartButton.on("pointerdown", function(){
            this.scene.start("PlayGame");
        }, this)
        this.add.sprite(this.tileDestination(1, COL), this.tileDestin
相关推荐
扑火的小飞蛾6 分钟前
网络安全小白学习路线图 (基于提供文档库)
学习·安全·web安全
优雅的潮叭10 分钟前
c++ 学习笔记之 malloc
c++·笔记·学习
李剑一29 分钟前
uni-app实现本地MQTT连接
前端·trae
EndingCoder32 分钟前
Any、Unknown 和 Void:特殊类型的用法
前端·javascript·typescript
oden33 分钟前
代码高亮、数学公式、流程图... Astro 博客进阶全指南
前端
GIS之路34 分钟前
GDAL 实现空间分析
前端
JosieBook1 小时前
【Vue】09 Vue技术——JavaScript 数据代理的实现与应用
前端·javascript·vue.js
pusheng20251 小时前
算力时代的隐形防线:数据中心氢气安全挑战与技术突破
前端·安全
起名时在学Aiifox2 小时前
前端文件下载功能深度解析:从基础实现到企业级方案
前端·vue.js·typescript