在IOS应用中比较2个掷骰子

问题描述 投票:0回答:2

我有一个具有2个图像视图的应用。每个人随机显示一张骰子脸的图像(从1到6),最终结果看起来像是模拟玩家和计算机掷骰子的过程。

它看起来像这样:

enter image description here

我有一个数组,其中包含所显示的每个图像的名称:let des: Array = ["one", "two", "three", "four", "five", "six"]

我还有一个功能可以随机显示两个玩家的图像

        UIView.animate(withDuration: 0.5) {
            self.dicePlayer.image = UIImage(named: self.des.randomElement() ?? "one")
            self.diceComputer.image = UIImage(named: self.des.randomElement() ?? "two")

        }
        // on appelle la fonction qui gere les scores
        gestionDesScores()
    } 

[我想在这2次掷骰之间进行比较(即:如果一个掷骰子的玩家胜过掷2个骰子的玩家,则获胜,反之亦然)]]

我有一个具有2个图像视图的应用。每个骰子随机显示一张骰子脸的图像(从1到6),最终结果看起来像是模拟玩家和计算机掷骰子的结果。它...

ios arrays swift xcode uiimageview
2个回答
0
投票

您可以尝试


0
投票

我建议将这两个抛弃物存储为人类可读的Int值。将这些属性添加到您的班级:

© www.soinside.com 2019 - 2024. All rights reserved.