Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 9, Xcode 7, Multitouch with SpriteKit

Hello I've made an iOS game named 'Racing Horses' and published it to App Store. It was fine with playing on iOS 8.x.x, but after I installed iOS 9 Beta 3, in the same game (same codes), iPhone cannot recognize multiple touches. I have to leave my finger to make the next touch. But it was not like this, I could make a new tap even if I still hold my previous tap. What is the problem, what should I do?

like image 651
white5tone Avatar asked Jul 19 '15 13:07

white5tone


People also ask

Can you use SpriteKit with SwiftUI?

SwiftUI's SpriteView lets us render any SKScene subclass right inside SwiftUI, and it will even resize the scene if you request it. The game scene you create is fully interactive, so it works just like a regular SKView would do in UIKit.

What is SpriteKit in iOS?

The SpriteKit framework makes it easy to create high-performance, battery-efficient 2D games. With support for custom OpenGL ES shaders and lighting, integration with SceneKit, and advanced new physics effects and animations, you can add force fields, detect collisions, and generate new lighting effects in your games.

What is SpriteKit and SceneKit?

SpriteKit and SceneKit are iOS frameworks designed to make it easy for developers to create 2D and 3D assets in casual games.

How is SpriteKit?

SpriteKit is a general-purpose framework for drawing shapes, particles, text, images, and video in two dimensions. It leverages Metal to achieve high-performance rendering, while offering a simple programming interface to make it easy to create games and other graphics-intensive apps.


2 Answers

I had the same problem on a game launched this summer.
I had to explicitly enable multiple touch in the SKScene:

-(void)didMoveToView:(SKView *)view {
    self.view.multipleTouchEnabled = YES;
}

Here's more detail - The game uses sub-classes of SKSpriteNode. They test for number of touches depending on the the sprite. In the sub-class:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
     NSLog(@"TapCount  = %lu", (unsigned long)touches.count);

     if (touches.count == 2) {
          // do something
     }
}
like image 199
Scott Avatar answered Sep 25 '22 21:09

Scott


It looks like as of ios 9 multitouch has to be explicitly enabled. I don't think this used to be the case. I now have this issue on all my spritekit apps. Just adding self.view.multipleTouchEnabled = YES; in viewDidLoad, fixes it for me.

like image 37
Lurker Avatar answered Sep 26 '22 21:09

Lurker