sprite-kit

How to turn off user interaction of child node when parent node has it enabled in SpriteKit

女生的网名这么多〃 提交于 2019-12-24 03:09:25
问题 I have an SKNode that has user interaction enabled and I am adding an SKEmitterNode to that and I want the user interaction to be disabled for just the child. This code does not work. SKNode* parentNode = [[SKNode alloc] init]; parentNode.userInteractionEnabled = YES; NSString* path = [[NSBundle mainBundle] pathForResource:@"ABCDEFG" ofType:@"xyz"]; SKEmitterNode* childNode = [NSKeyedUnarchiver unarchiveObjectWithFile:path]; childNode.userInteractionEnabled = NO; [parentNode addChild

Sprite Kit Physics Assertion failed: (typeA == b2_dynamicBody || typeB == b2_dynamicBody)

喜你入骨 提交于 2019-12-24 01:57:42
问题 I am trying to make a game with fully IOS 7 features using SpriteKit including Physics. So when user tabs to the screen, I am throwing a ball through some other balls (which are not moving and I set dynamic=NO for these target balls). What I want to do is: Immadiately stop the ball (I am using resting=YES for this) Switching categoryBitMask and contactTestBit mask from throwing ball to target ball's category / contactBitMask Stopping dynamics for this ball. Everything is okay except one thing

Mixing Sprite Kit with Empty Application

随声附和 提交于 2019-12-24 01:55:44
问题 I am currently developing an application for the iPhone with the Empty Application default. This means that the only thing created by Xcode is an AppDelegate. The only framework imported in my .pch file is the <Foundation/Foundation.h> Framework. This is working out for most of my application, but in some places, I would like to use SpriteKit . Is it possible to use the SpriteKit framework in my application that uses the Empty Application default? I'm asking this because normally, I have to

How do I add a scroll view to my gameScene.swift, that will scroll through a series of sprites?

夙愿已清 提交于 2019-12-24 01:27:52
问题 So I've created a 3x10 grid of sprites, that go off the bottom edge of the screen. I've added a UIScrollView, and the scroll indicators appear, but no movement actually occurs. Here's the code: import SpriteKit var buyButton = SKSpriteNode() var pic = SKTexture(imageNamed: "Button") class GameScene: SKScene, UIScrollViewDelegate { var scrollView = UIScrollView() var scrollFrame = CGRect!() override func didMoveToView(view: SKView) { /* Setup your scene here */ print(self.frame.size.width)

Swift SpriteKit: Best practice to access UIViewController in GameScene [closed]

痞子三分冷 提交于 2019-12-24 01:19:58
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . I wanted to see what the best practice(s) of accessing UIViewController methods from GameScene is/are. Right now I have been using NSNotificationCenter, but I don't want to use this due to specific functionality that I am trying to achieve. Also, if there are not any other

Create a subclass of a SKSpriteNode subclass

吃可爱长大的小学妹 提交于 2019-12-24 01:14:53
问题 Let's say I want to create a bunch of different types of Spaceships. I want to setup a base spaceship class that I can use to create other spaceships with minor differences. My base class looks like this. // BaseSpaceship.h @interface SpaceshipNode : SKSpriteNode @property NSColor color; @property CGFloat engineThrust; + (id)baseSpaceshipWithImageNamed:(NSString *)name; @end // BaseSpaceship.m @implementation BaseSpaceship + (id)baseSpaceshipWithImageNamed:(NSString *)name { BaseSpaceship

Confusing reversed touch event in Swift

天大地大妈咪最大 提交于 2019-12-24 00:57:50
问题 In my function override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?){ for touch in touches{ let touchLocation = touch.location(in: self.view) print("X: \(touchLocation.x) Y: \(touchLocation.y)") } } I get reversed Y value. If I click at the top I get ~0 value and if I click at the bottom I get high value. This makes my sprite im moving move in the wrong Y direction. However if I remove '.view' in self.view it works as it should. Does anyone know why it's reversed when I

How to create CGPath from a SKSpriteNode in SWIFT

爷,独闯天下 提交于 2019-12-24 00:52:05
问题 I have a SKSpriteNode create with the level generator. I need to create exactly the same shape using CGPath. self.firstSquare = childNodeWithName("square") as! SKSpriteNode var transform = CGAffineTransformMakeRotation(self.firstSquare.zRotation) let rect = CGRect(origin: self.firstSquare.position, size: self.firstSquare.size) let firstSquareCGPath:CGPath=CGPathCreateWithRect(rect, &transform) print(self.firstSquare.position) => firstSquare position (52.8359451293945, -52.9375076293945) To

SpriteKit: how to smoothly animate SKCameraNode while tracking node but only after node moves Y pixels?

廉价感情. 提交于 2019-12-24 00:48:51
问题 This question and others discuss how to track a node in SpriteKit using a SKCameraNode. However, our needs vary. Other solutions, such as updating the camera's position in update(_ currentTime: CFTimeInterval) of the SKScene, do not work because we only want to adjust the camera position after the node has moved Y pixels down the screen. In other words, if the node moves 10 pixels up, the camera should remain still. If the node moves left or right, the camera should remain still. We tried

SpriteKit drag and drop through wall

徘徊边缘 提交于 2019-12-24 00:46:53
问题 I did simple drag and drop in SpriteKit with physics. It works as expected, but when I use fast drag, element goes through wall. self.runner is wall self.runner2 is square Wall have dynamic set to NO. Movie shows everything: https://www.dropbox.com/s/ozncf9i16o1z80o/spritekit_sample.mov?dl=0 Tested on simulator and real device, both iOS 7. I want to prevent square from going through wall. Any ideas? #import "MMMyScene.h" static NSString * const kRunnerImg = @"wall.png"; static NSString *