3

I'm having an issue with device orientation and input. Using xcode->projects->orientation settings I have disabled everything except Portrait. When I turn the device, the graphics remain in place (as expected), but KKInput gestures (such as panning) seem to offer incorrect coordinates and translations. My number one suspicion is that I'm missing something related to KKInput's handling of convertToGL. To me it seems like Cocos2d is still reading the device's orientation and taking that into account for calculations. Below is an illustration if it helps.

Two 'square' sprites from a grid of squares.

**** | ****
*  * | *  *
**** | ****

Pan my finger over the XX sprite, dragging it to the right.

      **** | ****
  ->  *XX* | *  * (squares move horizontal)
      **** | ****

Turn the device to Landscape.

**** | ****
*  * | *  *
**** | ****

Pan my finger over the XX sprite, dragging it to the right.

     ^ (squares move vertical)
     ^

    **** |
    *XX* | 
    **** |
    ____ | ****
           *  *
    **** | ****
    *  * |
    **** |
Clev3r
  • 1,568
  • 1
  • 15
  • 28

1 Answers1

0

Yes, unfortunately KKInput uses the UIDeviceOrientation of the OS to transform the user input. Even tough the User Interface is locked to portrait the device orientation will return landscape which influences the calculation and results in this error.

If your project isn't too old I would suggest migrating to Cocos2d 3.0, it comes with a much simpler touch handling.

Ben-G
  • 4,996
  • 27
  • 33
  • Actually, I figured out that the problem was that there was one additional touch input that seems to only be received when the device is "FLAT". I was skipping this case in a switch statement, leading to the confusion. – Clev3r Jan 27 '14 at 15:00