纯前端小游戏,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
相关推荐
Willliam_william8 分钟前
SVA学习之路(1)— SystemVerilog Assertion简介与实战
学习
JIngJaneIL14 分钟前
基于Java+ vueOA工程项目管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
测试人社区-小明16 分钟前
从前端体验到后端架构:Airbnb全栈SDET面试深度解析
前端·网络·人工智能·面试·职场和发展·架构·自动化
im_AMBER17 分钟前
Leetcode 77 数组中的最大数对和 | 统计坏数对的数目
笔记·学习·算法·leetcode
李少兄17 分钟前
前端开发中的 transform、translate 与 transition
前端·css
蓝鲸屿19 分钟前
JS基础第九天——对象(2)+Random
开发语言·前端·javascript
全栈练习生21 分钟前
ESModule的工作原理是什么
前端
代码游侠22 分钟前
学习笔记——Linux 进程管理笔记
linux·运维·笔记·学习·算法
解局易否结局24 分钟前
GitCode口袋工具开发学习
学习·gitcode
逐辰十七25 分钟前
freertos学习笔记12--个人自用-第18章 资源管理(Resource Management)
笔记·学习