纯前端小游戏,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
相关推荐
\xin15 分钟前
pikachu自编CSRF(GET),CSRF(POST),CSRF(token)
前端·csrf
从负无穷开始的三次元代码生活17 分钟前
Docker生产环境实战从0-1学习基础指南——快速掌握
学习·docker·容器·云技术
是大强18 分钟前
前端一个项目用node20 一个项目用node14 怎么切换
前端
KuaCpp21 分钟前
Docker从0到1学习
学习·docker·容器
ting945200021 分钟前
动手学深度学习(PyTorch版)深度详解(1)(含实操+避坑)
pytorch·深度学习·学习
不老刘24 分钟前
Git Cherry-Pick:微前端架构下的“精准医疗”与最佳实践
前端·git
nervermore99039 分钟前
3. 人工智能学习-PyTorch框架学习
人工智能·pytorch·学习
handler0142 分钟前
进程状态流转的本质:Linux 内核队列与底层数据结构解密
linux·运维·c语言·数据结构·c++·笔记·学习
LIO1 小时前
ESLint 极简指南:让代码既规范又一致
前端·eslint
Shan12051 小时前
大学计算机初学者之学习课程推荐
学习