Spritekit: Touches not matching screen resolution.

Discussion in 'iOS Programming' started by chrono1081, May 15, 2015.

  1. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #1
    Hi guys,

    I have a prototype I'm working on and I've run into a strange issue. My screen resolution is set to that of the iPhone 6 4.7 inch in portrait mode (750, 1334) pixels however my gesture recognizer doesn't see that resolution.

    For example if I touch in the middle of the screen I expect a value close to 375, instead I get a value around 187. My guess is that the coordinate system is somehow different on retina screens but I'm not sure.

    Has anyone seen this? Does anyone know how to get the screen pixel values of the touch or the width of the screen in points instead of pixels?
     
  2. DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
  3. Boris-VTR macrumors regular

    Joined:
    Apr 18, 2013
    #3
    Because you indeed get back result in points. And that is better. Why? Because swift/ ooc is smart enough to deteck which phone you are using and will do automatic conversion.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
  5. chrono1081 thread starter macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #5
    Thanks guys!

    @Boris Unless I'm doing something wrong I haven't found this to be the case. Every time I switch devices my game loses chunks of the screen here and there. I found it much more consistent to detect the screen bounds and work from there.
     

Share This Page