快速提问,
我对编程相当陌生并且遇到了问题。我正在制作游戏,并且在每一轮结束时,该轮得分最高的获胜者出局,我隐藏了该玩家的玩家视图和标签,但需要弄清楚如何制定方法,以便在我的案例 4 切换中( self.players) 未设置标签和隐藏的播放器视图,并且 turn 变量根据我从开关中取出的标签重新排列。
switch (self.players) {
case 5:
switch (self.turn) {
case 1:
explanationLabel.text = [NSString stringWithFormat:@"%d",score];
break;
case 2:
explanationLabelTwo.text = [NSString stringWithFormat:@"%d",score];
break;
case 3:
explanationLabelThree.text = [NSString stringWithFormat:@"%d",score];
break;
case 4:
explanationLabelFour.text = [NSString stringWithFormat:@"%d",score];
break;
case 5:
explanationLabelFive.text = [NSString stringWithFormat:@"%d",score];
break;
例如,如果由 explainLabelFour 代表的 playerFour 赢得了第一轮,那么四名玩家的切换应该是..
switch (self.players) {
case 4:
switch (self.turn) {
case 1:
explanationLabel.text = [NSString stringWithFormat:@"%d",score];
break;
case 2:
explanationLabelTwo.text = [NSString stringWithFormat:@"%d",score];
break;
case 3:
explanationLabelThree.text = [NSString stringWithFormat:@"%d",score];
break;
case 4:
explanationLabelFive.text = [NSString stringWithFormat:@"%d",score];
break;
我发现使它工作的唯一方法是执行 if 语句来查看每个标签是否被隐藏然后相应地设置它们,但它的效率非常低。这是一个骰子游戏,在掷出三轮后,轮数上升一圈。
提前致谢!