-1

I am experimenting with SpriteKit. As a template, it opens with this:

override func touchesBegan(_ touches: Set<UITouch>, _ withEvent event: UIEvent) {
    // Touch code here
}

It passes a touches parameter that is a set of all the current touches, and their positions on the screen. When I click on the screen in the area that should be (0,0), the CGPoints are off by near 120? How can I recalibrate and position the scene to be at (0,0)?

0-1
  • 702
  • 1
  • 10
  • 30
BiOS
  • 21
  • 1
  • Did you try anything? – Dharmesh Kheni Jul 02 '15 at 05:03
  • yes I've tried disabling auto-sizing but the problem still persists. I am fairly new and don't know what to do – BiOS Jul 02 '15 at 05:04
  • It's literally the template when you start a sprite kit game : import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView) { /* Setup your scene here */ } override func touchesBegan(touches: Set, withEvent event: UIEvent) { /* Called when a touch begins */ for touch in (touches as! Set) { let location = touch.locationInNode(self) println(location) } } – BiOS Jul 02 '15 at 05:07
  • 1
    See the answer to this question. [link](http://stackoverflow.com/questions/25233506/why-wont-my-skspritenodes-not-appear-in-the-scene) – 0x141E Jul 02 '15 at 08:36
  • See this http://stackoverflow.com/q/25205882/2158465 – Epic Byte Jul 02 '15 at 19:42
  • None of these fixes have worked? In fact, it made it worse. It's like I'm zoomed in too much now. Anyone else have any ideas? – BiOS Jul 02 '15 at 20:16

1 Answers1

-1

After experimenting for a bit I have found a fix for the issue. The scene size by default is (1024, 768) and the view size by default is (667, 375).

This code fixes the problem: scene?.size = self.view!.frame.size

I am concerned that I should have to configure this and I feel I am missing a configuration setting on creation of a project. Is this something they forgot to set up by default with Xcode or am I missing something?

BiOS
  • 21
  • 1