sprite-kit

How can I add a single Game Scene from SpriteKit into a normal Single View Swift App

不羁岁月 提交于 2019-12-06 08:05:06
问题 I have built a simple trivia game using a normal Single View type of app using swift. But now, as part of an update, I want to add a more complex trivia level to the game and this level is going to be built using SpriteKit, with animations and whatnot, but I'm not sure how can I transition and show a spriteKit game scene in a simple single view swift app and then transition back to a regular view controller. I did search all around but I could not find any specific answer to this question,

SKAudioNode Crash: AVAudioPlayerNode.mm:333: Start: required condition is false: _engine->IsRunning()

我的未来我决定 提交于 2019-12-06 07:28:21
问题 I've a simple SKAudioNode: let backgroundSound = SKAudioNode(fileNamed: "backgroundSound.mp3") I use to play backgroundSound.runAction(SKAction.play()) and backgroundSound.runAction(SKAction.stop()) to stop. Everything works fine until the app did enter in background mode and I'll resume more than 3 minute. If I go in background mode and resume after 10 - 20 seconds, the Audio doesn't crash. All crash log: 2016-05-29 23:26:43.612 PippiPompiere[1070:199471] 23:26:43.611 ERROR: [0x3a7cf000]

ARKit billboarding effect with SceneKit

a 夏天 提交于 2019-12-06 07:28:11
I am looking to add a billboarding effect that is similar to this application: https://twitter.com/marpi_/status/897130955105644544 I would like SCNodes that use SCNText geometry to always face the camera. I have attempted with out success: SCNLookAtConstraint with sceneView.pointOfView as the target, but this rotates the node to face away from the camera, resulting in backwards text, and unable to change the nodes position or euler angle. Out of the box, an SKLabelNode will always face the camera in ARKit, which is exactly what I want, except using SCNText. You were almost there! Just modify

Get Color of point in a SKScene swift

你离开我真会死。 提交于 2019-12-06 07:27:51
问题 I need to get the color of a pixel/point for my game in Swift. So I tried to find a function that inputs a CGPoint and returns a Color, everything that I have found so far has only returned (0,0,0,0). I think that this is because I am doing this in my game scene class(which is an SKScene), and the scene is only being loaded by a view controller. Any Solutions? (If there is a better way to check if a sprite is touching a color that would work as well) Thanks in advance. 回答1: Add the below

How to properly manage groups of sprites onscreen

送分小仙女□ 提交于 2019-12-06 07:21:59
问题 I'm building my first game in Swift and I wanted to know how to go about handling multiple on screen sprites at once. My game pushes sprites on to screen with addChild continuously, so there are many active at once. I realized that I didn't have a proper way of simultaneously affecting all of them- like if I wanted to affect a physics property of all enemy sprites at once. So far I created an empty array var enemySprites = [enemyType1]() at the begining of GameScene and have been appending

AVAudioSession reactivation issue

戏子无情 提交于 2019-12-06 06:51:03
I am getting the following error: [0x19bf89310] AVAudioSession.mm:646: -[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session. I have read through this post: iOS8 AVAudioSession setActive error however the solution there did not solve my problem. which is: small application (game) audio background music handled in AudioHelper.swift additional 'blip' sounds played with SKActino.playSoundFile reproduction start game (background music starts to play) close game (music stops)

ARKit set ARAnchor transform based on touch location

末鹿安然 提交于 2019-12-06 06:46:55
问题 I'm playing around with the AR starter app on XCode 9 where anchors are created in a scene on tap: override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { guard let sceneView = self.view as? ARSKView else { return } // Create anchor using the camera’s current position if let currentFrame = sceneView.session.currentFrame { // Create a transform with a translation of 0.2 meters in front // of the camera var translation = matrix_identity_float4x4 translation.columns.3.z = -0

Unwrapping optional values: PhysicsBody - Swift SpriteKit

大城市里の小女人 提交于 2019-12-06 06:38:32
So I made some adjustments to the ball in my game and to avoid an unwrapping optional value error, I commmented out the following //didMoveToView self.physicsWorld.gravity = CGVectorMake(0, 0) self.physicsWorld.contactDelegate = self let fieldBody = SKPhysicsBody.init(edgeLoopFromRect: self.frame) self.physicsBody = fieldBody self.physicsBody!.affectedByGravity = false self.physicsBody!.usesPreciseCollisionDetection = true self.physicsBody!.dynamic = true self.physicsBody!.mass = 0 self.physicsBody!.friction = 0 self.physicsBody!.linearDamping = 0 self.physicsBody!.angularDamping = 0 self

Sprite Kit game crashes on Game Over on tvOS 9.1 and iOS 9.2

这一生的挚爱 提交于 2019-12-06 06:23:56
I have a Sprite Kit game that is crashing when the game is over. This happening on the tvOS 9.1 and iOS 9.2. Before, I had it running on iOS 9.1 without crashing. It seems to be an OpenGL issue, but when I search the function in Xcode, it doesn't come up with anything. Unfortunately, the error is not consistent in appearing in the console. Here's the error: Jet: draw_indexed: indexType must be 'unsigned_int' or 'unsigned_short' Assertion failed: (indexType == jet_component_type_unsigned_int || indexType == jet_component_type_unsigned_short), function draw_indexed, file /BuildRoot/Library

Swift SpriteKit edgeLoopFromRect Issue

浪尽此生 提交于 2019-12-06 06:14:31
问题 The following code recognizes the bottom and top edges of the scene and the ball bounces off as expected. However, the left and right edges of the scene are breached all the time. The ball goes off screen and then eventually returns back if enough force is applied. It is as if the edges of the scene are beyond the edges of the iphone simulator window. import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView){ self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self