sprite-kit

Why are objects in the same SKNode layer not interacting with each other?

心已入冬 提交于 2019-12-22 08:17:11
问题 I have less than 1 year using SpriteKit so I didn't use SKNodes as layers before until recently. I have an SKNode layer that holds all of the fish and the user's position, for example: var layerMainGame = SKNode() layerMainGame.zPosition = 50 layerMainGame.addChild(userPosition) layerMainGame.addChild(pipFish) addChild(layerMainGame) The interaction whether the user touched a fish or not is handled with this function, which is basically checking if their frames crossed: if

SpriteKit Gesture Recognizer

我与影子孤独终老i 提交于 2019-12-22 08:13:29
问题 Hi I'm trying to use gesture recognizer with my sprite kit game , i wrote this code @interface GameScene() <UIGestureRecognizerDelegate>{ UISwipeGestureRecognizer *swipeGestureLeft; ISwipeGestureRecognizer *swipeGestureRight; } @end @implementation GameScene -(id)initWithSize:(CGSize)size{ if(self = [ super initWithSize:size]){ } return self; } -(void)didMoveToView:(SKView *)view{ swipeGestureLeft = [[UIGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft)];

How to select buttons in tvOS menu for SpriteKit game

家住魔仙堡 提交于 2019-12-22 07:59:54
问题 I am extending my iOS game for tvOS. Most of the game controls are handled by touchesBegan , touchesMoved and touchesEnded . All my select buttons are handled in the following way: if button1.contains(location){ let gameplayScene = GamePlayScene(size: self.size) self.view?.presentScene(gameplayScene) } if button2.contains(location){ let settingsScene = SettingsScene(size: self.size) self.view?.presentScene(settingsScene) } if button3.contains(location){ let helpScene = HelpScene(size: self

SpriteKit Weird 'PKPhysicsBody' Crash

旧街凉风 提交于 2019-12-22 07:25:12
问题 I am trying to implement a simple category for SKPhysicsBody that will allow me to apply 'perfect bouncing' to a physics body. What this will simply do is when perfectBouncing = YES the following will happen: restitution = 1.0 linearDamping = 0.0 friction = 0.0 However, when I try to use my implementation as shown below, I get a weird crash telling me that I can't send perfectBouncing messages to PKPhysicsBody , which is a class that I never refer to and doesn't exist in my project or to my

SKShapeNode filltexture() does not display image

我们两清 提交于 2019-12-22 05:27:01
问题 I want to create a circle that whose content is an image (.png), and based on the SKShapeNode class reference, I thought that I could use SKShapeNode.filltexture() function to set the texture to the image. But when i run the code below, I get the circle, but the image of the "cat-black" I am trying to load doesn't show. I checked that my Image.Assets have the image with the correct name, so something else is up. Any ideas? I attached the output below: func newCircle(photo:String, position

Error: Attemped to add a SKNode which already has a parent

﹥>﹥吖頭↗ 提交于 2019-12-22 05:14:20
问题 I'm doing a game with Swift 3 and SpriteKit and I'm trying to declare a global variable to work with it in the rest of the GameScene class but I can't. What I did: class GameScene: SKScene { ... let personaje = SKSpriteNode(imageNamed: "Ball2.png") ... After the global declaration I tried to use it in the sceneDidLoad just like that: ... personaje.position = CGPoint.zero addChild(personaje) ... I don't know why but Xcode returns this error: *** Terminating app due to uncaught exception

In SpriteKit does touchesBegan run in the same thread as the SKScene update method?

廉价感情. 提交于 2019-12-22 05:04:40
问题 In the Apple documentation here Advanced Scene Processing it describes the update method and how a scene is rendered, but it does not mention when input is processed. It is not clear if this is in in the same thread as the rendering loop, or whether it is concurrent with it. If I have an object that I update from both the SKScene update method and the touchesBegan method (in this case of a SKSpriteNode ) do I have to worry about synchronising the two accesses to my object? 回答1: So after a few

TouchesBegan delay on left hand side of the display

我是研究僧i 提交于 2019-12-22 04:44:07
问题 On iPhone's with 3D touch enabled, there is a feature where long pressing the left hand side of the screen with enough force opens lets you change which app is active. Because of this, when a non-moving touch happens on the left hand side of the screen, the touch event is delayed for a second or two until the iPhone verifies that the user is not trying to switch tasks and is interacting with the app. This is a major problem when developing a game with SpriteKit, as these touches are delayed

SKVideoNode as texture for SCNSphere

为君一笑 提交于 2019-12-22 04:17:17
问题 i'm trying to use a SKVideoNode as a video texture source for a SCNSphere within my SCNView I'm following this answer: SKVideoNode (embedded in SKScene) as texture for for Scene Kit Node not working And with my code (pasted at the end of the question) I do get a video and an audio playing. Issue is, the mapping only occurs on a quarter of the sphere (the all xy-positive quarter). The cameraNode is inside (0,0,0) the sphere and independent of the sphereNode. I do apply a scale to the sphere

SpriteKit's Update Function: time vs. framerate

喜夏-厌秋 提交于 2019-12-22 04:13:19
问题 I'm new to programming and Spritekit in general, and am interested in exploring the relationship between milliseconds & framerate, and how the update function is used as an intermediary between both. Framerate vs. milliseconds Essentially, the main difference between framerate and time is that time is always consistant, while framerate is not (it could dip due to intensive graphics procedures). However, time is usually checked and set during SKScene's update event (which is called every frame