试图对随机图像进行排序,混乱了点计数器
我有一个列表,其中包含8个图像。从索引值0-3是可回收项目的图像,索引值4-7是堆肥项目的图像。我在UI上有2张垃圾箱图片:回收站的图片和堆肥箱的图片。我在屏幕上有另一个空白图像,从8个图像列表中显示了随机图像。当您单击任何一个垃圾箱以确定随机图像是否与垃圾箱匹配时,我正在使用IF-ELSE语句。例如,如果随机图像列表[0],则将是可回收项目。因此,如果用户单击回收箱,则应添加一个点。但是,如果随机图像是列表[0],并且用户单击堆肥箱,则应减去点。我的IF-ELSE陈述没有相应地工作。这是整个代码。 1 HERES是UI的图片。 2
I have a list that contains 8 images on total. From index value 0-3 are images of recyclable items, and from index value 4-7 are images of compost items. I have 2 images of bins on the UI: a picture of a recycle bin and a picture of a compost bin. I have another blank image on the screen that presents a random image from the list of 8 images. I'm using an if-else statement when you click on either of the bins to determine if the random image matches with the bins. For example, if the random image is list[0], it would be a recyclable item. Thus, if the user clicks on the recycle bin, it should add a point. However, if the random image is list[0] and the user clicks on the compost bin, it should subtract a point. My if-else statement is not working accordingly. Here's the full chunk of code. 1 Heres a picture of the UI. 2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该单独创建一个随机变量,并在if语句中使用以进行检查。像这样;
You should separately create a randomTrash variable and use it in the if statement to check. Like so;