最近在做毕设,做跟小学数学相关知识的小游戏,第一个是乘法口诀表,
    图片.png这是游戏界面,填写答案的框是InputField,一开始的想法是独个判断,但是答案一共有45个,太多太繁杂了,我就使用了数组,
    public Text ScoreText;
    public InputField[] inf = new InputField[45];
    public string[] check =new string[]{“1”,
    “2”,”4”,
    “3”,”6”,”9”,
    “4”,”8”,”12”,”16”,
    “5”,”10”,”15”,”20”,”25”,
    “6”,”12”,”18”,”24”,”30”,”36”,
    “7”,”14”,”21”,”28”,”35”,”42”,”49”,
    “8”,”16”,”24”,”32”,”40”,”48”,”56”,”64”,
    “9”,”18”,”27”,”36”,”45”,”54”,”63”,”72”,”81”};
    private int i = 0;
    private int j = 0;
    public void tj()
    {
    for(i=0;i<45;i++)
    {
    if (check[i] !=inf[i].text)
    {
    j++;
    inf[i].image.color = Color.red;//背景颜色变红色
    }
    }
    score = score - j * kf;
    ScoreText.text = “分数:” + score;
    bt.enabled = false;//按钮失效
    Time.timeScale = 0;//停止
    }这是我判断的代码,InputField还可以改变颜色,答案错误或者没有答案,框的填充色就会变红。
    图片.png
    好了,今天草草的写了一点,有疑问的可以下面留言,虽然我也还在摸索着,但我们可以一起探讨学习。