gpt4 book ai didi

iphone - if 语句的问题 ||

转载 作者:太空宇宙 更新时间:2023-11-04 05:46:03 25 4
gpt4 key购买 nike

我正在研究一个新项目,实际上我正在使用简单的坐标:

if (locationOnJoystick.x > joystickArea.frame.size || locationOnJoystick.y > joystickArea.frame.size) {

但是在运行代码时出现错误:

error: invalid operands to binary > (have 'CGFloat' and 'CGSize')

谁能看到解决方案?!

真诚的,特立独行3。

最佳答案

locationOnJoystick.x 是一个 CGFloat,而 joystickArea.frame.size 是一个 CGSize。它们是不同的类型,您无法比较它们。

我猜你应该比较 locationOnJoystick.x 和你的 joystickArea.frame.size 的宽度(y 和高度也一样):

if (locationOnJoystick.x > joystickArea.frame.size.width || locationOnJoystick.y > joystickArea.frame.size.height) {

关于iphone - if 语句的问题 ||,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4984809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com