怎么将成绩输出到本地呢

来源:3-9 总结

慕粉1728572880

2019-06-23 11:20

怎么将成绩输出到本地呢

写回答 关注

1回答

  • 无心妖
    2020-04-07 18:12:40

    //分值计算

    var dataObj = function () 

    {

    this.fruitNum = 0;

    this.double = 1;

    this.score = 0;

    this.gameOver = false;

    this.alpha = 0;

    }

    dataObj.prototype.draw = function()

    {

    var w = can1.width;

    var h = can1.height;


    ctx1.save();

    ctx1.shadoBlur = 10;

    ctx1.shadowColor = "white";

    ctx1.fillStyle = "white";

    ctx1.fillText("分数 " + this.score, w * 0.5, h - 20);


    if(this.gameOver)

    {

    this.alpha  += deltaTime * 0.0005;

    if(this.alpha > 1)

    this.alpha = 1;



    ctx1.fillStyle = "rgba(255,255,255," + this.alpha +")";

    ctx1.fillText("游戏结束", w * 0.5, h * 0.5);

    }

    ctx1.restore();


    }

    dataObj.prototype.addScore = function()

    {

    this.score += this.fruitNum * 10 * this.double;

    this.fruitNum = 0;

    this.double = 1;

    }


HTML5小游戏---爱心鱼(下)

通过一个清新美好的小游戏教程,熟悉游戏开发流程

46272 学习 · 189 问题

查看课程

相似问题