Fabio Poloni
Fabio Poloni

Reputation: 8371

Troubles with if-statement ||

I'm just working on a new porject an I'm working actually with simple coordinates:

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

But while running the code I get an ERROR:

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

Can anyone see the solution?!

Sincerly, mavrick3.

Upvotes: 0

Views: 218

Answers (1)

peoro
peoro

Reputation: 26060

locationOnJoystick.x is a CGFloat, while joystickArea.frame.size is a CGSize. They're different types, you cannot compare them.

I guess you should compare locationOnJoystick.x with the width of your joystickArea.frame.size (and the same with y and height):

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

Upvotes: 6

Related Questions