纯前端小游戏,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
相关推荐
星离~7 分钟前
Vue响应式原理详解:从零实现一个迷你Vue
前端·javascript·vue.js
梦65041 分钟前
React 简介
前端·react.js·前端框架
一只小阿乐42 分钟前
react 中的判断显示
前端·javascript·vue.js·react.js·react
光影少年1 小时前
useMemo 和 React.memo区别
前端·react.js·前端框架
小沐°1 小时前
React-页码组件
前端·javascript·react.js
零一科技1 小时前
Vue3学习第三课: ref 与 reactive 选择指南
前端·vue.js
檐下翻书1731 小时前
从入门到精通:流程图制作学习路径规划
论文阅读·人工智能·学习·算法·流程图·论文笔记
SalvoGao1 小时前
Python学习 | 怎么理解epoch?
数据结构·人工智能·python·深度学习·学习
思成不止于此1 小时前
深入理解 C++ 多态:从概念到实现的完整解析
开发语言·c++·笔记·学习·多态·c++40周年
Highcharts.js1 小时前
学习 Highcharts 可视化开发的有效途径
学习·数据可视化·highcharts·图表开发·可视化开发