纯前端小游戏,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
相关推荐
天若有情67312 小时前
ES6 模块与 CommonJS 的区别详解
前端·javascript·es6
大猫会长12 小时前
postgreSQL中,RLS的using与with check
开发语言·前端·javascript
好奇龙猫12 小时前
【人工智能学习-AI入试相关题目练习-第六次】
人工智能·学习
慧一居士12 小时前
vite.config.ts 配置使用说明,完整配置示例
前端
wusp199413 小时前
nuxt3模块化API架构
前端·javascript·nuxt3
[H*]13 小时前
鸿蒙跨端Flutter学习:InheritedWidget嵌套使用
学习·flutter
2501_9418649613 小时前
科学记忆法提升学习效率
学习
沛沛老爹13 小时前
Web开发者进阶AI:企业级Agent Skills安全策略与合规架构实战
前端·人工智能·架构
好奇龙猫13 小时前
【日语学习-日语知识点小记-日本語体系構造-JLPT-N2前期阶段-第一阶段(4):单词语法】
学习
别了,李亚普诺夫13 小时前
运算放大器的参数、选型与应用-学习笔记
笔记·学习