Swift 4 - SpriteKit over SceneKit - prevent touch for underlying camera controls - ios

I'm quite new to Swift development. In my project i have a SpriteKit overlaying the SceneKit scene with allowsCameraControl set to true.
The SpriteKit layer contains buttons - what is the best way to disable the touch/pan events to trigger camera controls when these buttons are interacted with? (e.g. double tap on a button now triggers camera reset to default position)

Turn off allowsCameraControl and implement your own camera controls instead. The allowsCameraControl is handy for testing/debugging purposes and cannot be disabled partly such as for the doubletap behavior only. Which besides conflicts with other gestures gets annoying as a double tap is easily made by accident and resets the screen.

Related

How to build a PagerView in WatchOS

How can I build or get (library) a PagerView in WatchOS. I can't find a way to do it without SwiftUI. I have a library for UIKit (https://github.com/WenchaoD/FSPagerView) but i cant use it for watchOS
Use SpriteKit for custom ui on watchOS
If you can't use SwiftUI, WatchOS only has SpriteKit and SceneKit.
Your app isn't a game, but there's no difference to the computer, only to the user. A game is just a fun app.
You need to have a WKInterfaceController that hosts a WKInterfaceSKScene view and the WKInterfaceSKScene presents an SKScene
For a pager type view of images that you can swipe between, then you might have a scene with some SKSpriteNodes, for example 3, with one on screen, one to the left, one to the right, and move them around and change their images as user drags about. Or whatever you want, maybe a SKTileMapNode or so.
For dragging, maybe a WKPanGestureRecognizer on the WKInterfaceController - you need to ensure you're not in a paged based interface, only fullscreen or navigation based would work for that. You also want to allow the crown to be used, so implement WKCrownDelegate

How does the default SceneKit application in Xcode handle the double click?

When I open a game application in Xcode, and go to SceneKit there is already some code written. The code draws an airplane and allows the user to rotate it. When you double tap anywhere on the screen the plane returns to its original position. How can you do that. I looked through the whole application and there is no hint of a double tap gesture or bringing the view back to its position. How does that happen without any code?
There's no code there to allow you to rotate the plane either.
That functionality as well as the double tap to reset the camera functionality is added by the scnView.allowsCameraControl = YES line in the view controller.

Swift SpriteKit: Recognize multiple taps

I have a game and at the moment there is an AI player and human but I want to make it multiplayer. The game is designed where when you press the top left/right the sprite on top would move left/right and if you press the lower left/right the lower sprite would move towards the left/right. Imagine the iPhone to always be in portrait mode.
The issue is that I am using touchesBegan and I can't figure out how to make that work with possible multiple taps coming in at the same time

Change sensitivity of shake gesture in SpriteKit: goal is to create quicker shake?

Is it possible to change the sensitivity of the shake gesture in SpriteKit? Specifically, we want to trigger the shake gesture on a faster shake than the default. It's not clear from the Apple documentation: https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/motion_event_basics/motion_event_basics.html.
This SO post is also outdated: iPhone App increase Shake gesture Sensitivity
Is the only option to implement a custom handler using accelerometer data? Or would using gyroscope data be better?
There's no setting for shake sensitivity. You can however use CoreMotion to create your method and set custom parameters for detecting movement/shaking of your device.

Disabling iOS multitask gesture recognizer during game play

I am developing a game where the user could draw using up to 5 fingers, 1 finger for each line.
When multitask gesture is enabled and the user try to draw using more than 4 fingers from right to left, the gesture recognizer from iOS on iPad switch to another application.
How can I programmatically disable this recognizer when the user enters on my application?
There is no API for that.
There might be a way to consume the gesture, so it is not forwarded to the system, but I think the order of the messaging chain is in the other way.
You can only ask your users to disable the Multitasking Gestures in the System Preferences, under the General section. Not really great, I know.

Resources