The if statement is:
//these x & y do not affect the if statement they are used for the result 6 lines down.
int x = enemy.position.x;
int y = enemy.position.y;
NSLog(@"%G,%G", leftJoystick.velocity.x, leftJoystick.velocity.y);
if ((leftJoystick.stickPosition.x < 1 && leftJoystick.stickPosition.x > -1)&& leftJoystick.stickPosition.y > 0) {
enemy.position = ccp(x,y-1);
NSLog(@"North");
return;
}
In the feedback it shows that -0.0544645,0.998516 works and it logs North, but -0.0725357,0.997366 doesn’t work. I don’t understand why?
I’m trying to do this in cocos2d BTW.
you are logging velocity, yet your logic operates on position. Clear that up, maybe the answer will come to you more clearly.