2048小游戏,h5,纯前端

部分代码

复制代码
    //score
    var scoreSprite = game.add.sprite(10, 10);
    var scoreGraphics = game.add.graphics(0, 0);
    scoreGraphics.lineStyle(5, 0xA1C5C5);
    scoreGraphics.beginFill(0x308C8C);
    scoreGraphics.drawRoundedRect(0, 0, 70, 50, 10);
    scoreGraphics.endFill();
    scoreSprite.addChild(scoreGraphics);
    var scoreTitle = game.add.text(0, 5, "SCORE", titleStyle);
    scoreTitle.setTextBounds(0, 0, 70, 50);
    scoreSprite.addChild(scoreTitle);
    this.scoreText = game.add.text(0, 20, this.score, scoreStyle);
    this.scoreText.setTextBounds(0, 0, 70, 50);
    scoreSprite.addChild(this.scoreText);
    //best
    var bestSprite = game.add.sprite(90, 10);
    var bestGraphics = game.add.graphics(0, 0);
    bestGraphics.lineStyle(5, 0xA1C5C5);
    bestGraphics.beginFill(0x308C8C);
    bestGraphics.drawRoundedRect(0, 0, 70, 50, 10);
    bestGraphics.endFill();
相关推荐
遂心_25 分钟前
为什么 '1'.toString() 可以调用?深入理解 JavaScript 包装对象机制
前端·javascript
IT_陈寒25 分钟前
JavaScript 性能优化:5 个被低估的 V8 引擎技巧让你的代码快 200%
前端·人工智能·后端
岛风风1 小时前
关于手机的设备信息
前端
ReturnTrue8681 小时前
nginx性能优化之Gzip
前端
w_y_fan2 小时前
Flutter 滚动组件总结
前端·flutter
wuli金居哇2 小时前
我用 Turborepo 搭了个 Monorepo 脚手架,开发体验直接起飞!
前端
Asort2 小时前
JavaScript 从零开始(五):运算符和表达式——从零开始掌握算术、比较与逻辑运算
前端·javascript
一枚前端小能手2 小时前
🚀 缓存用错了网站更慢?前端缓存策略的5个致命误区
前端·javascript
艾小码2 小时前
为什么你的页面会闪烁?useLayoutEffect和useEffect的区别藏在这里!
前端·javascript·react.js
艾小码2 小时前
告别Vue混入的坑!Composition API让我效率翻倍的3个秘密
前端·javascript·vue.js