码迷,mamicode.com
首页 > 其他好文 > 详细

显示当前分与历史最高分数

时间:2016-04-06 20:14:38      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GameOver : MonoBehaviour
{
    public static GameOver _instance;

    public Text bestScore;
    public Text nowScoreText;

    void Awake()
    {
        _instance = this;
        this.gameObject.SetActive(false);
    }

    void Start()
    {
        //bestScore = GetComponent<Text>();
        //nowScore = GetComponent<Text>();
      
    }

    public void Show(float nowScore)
    {
        //这是设定一个存储float类型的数据的位置
        float histotyHighScore = PlayerPrefs.GetFloat("historyHighScore", 0);
        if (nowScore>histotyHighScore)
        {
            //将上面的位置的数据进行替换
            PlayerPrefs.SetFloat("historyHighScore",nowScore);
        }
        bestScore.text = "" + histotyHighScore;
        nowScoreText.text = "" + nowScore;
        this.gameObject.SetActive(true);
    }
}

 

显示当前分与历史最高分数

标签:

原文地址:http://www.cnblogs.com/fuperfun/p/5360903.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!