纯前端小游戏,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

 

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 07:54:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 07:54:02       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 07:54:02       58 阅读
  4. Python语言-面向对象

    2024-07-19 07:54:02       69 阅读

热门阅读

  1. jEasyUI 显示海量数据

    2024-07-19 07:54:02       20 阅读
  2. 团队高效地使用 Git 进行协同开发

    2024-07-19 07:54:02       20 阅读
  3. ArrayList

    2024-07-19 07:54:02       21 阅读
  4. vue项目使用iview☞Modal后页面不能滚动的诡异问题

    2024-07-19 07:54:02       21 阅读
  5. STM32 | 看门狗+RTC源码解析

    2024-07-19 07:54:02       21 阅读
  6. 富文本中提取信息并去除其中的HTML或XML标签

    2024-07-19 07:54:02       21 阅读
  7. 2024前端面试真题【手写篇】

    2024-07-19 07:54:02       18 阅读
  8. 聊聊最近在看的一本书-《从极简到极致》

    2024-07-19 07:54:02       20 阅读
  9. Python数据获取(网页视频、音频版)

    2024-07-19 07:54:02       22 阅读
  10. Log4j2原理及应用详解(九)

    2024-07-19 07:54:02       23 阅读