sprite-kit

Halt when presenting ViewController with SKScene

扶醉桌前 提交于 2019-12-12 10:33:51
问题 EDIT: OK, so this happens even with an empty SpriteKit scene! What could be wrong here?? Why does iOS need 2 seconds to display SpriteKit scene?? EDIT 2: First time i click on tab bar to display view controller with SKScene it displays immediately, but every next time i try to navigate back to this view controller it will take it 2 seconds to display! I have a a tab bar controller in my app with multiple different viewControllers. One of them contains a SpriteKit scene, with a couple of nodes

How to create a separation between two SpriteKit objects

被刻印的时光 ゝ 提交于 2019-12-12 10:23:09
问题 I have a circle and triangles inside and outside. I was looking through my character if it is not in a circle outside the circle touching triangles and vice versa. It does not matter if my character out of my circle it still happens. In fact if I'm in my circle and triangles outside my circle so my character should not touch them. How do I solve this? Does anyone have an idea? My Code : func AddCharacter() { BooCharacter.size = CGSize(width: 30, height: 30) BooCharacter.anchorPoint.y = 0

SkSpriteNode.Run Action don't Works some times

北战南征 提交于 2019-12-12 10:21:42
问题 this is my first SpriteKit game and I didn't had any problems with run action before so I tried but can't figure anything out, only thing I figure out is all code is fine but just run action don't execute some times and didn't seen any king of behaviour in that pattern. I I'm making 4 player board game and all 4 players have 4 pieces. the problem is with returning to home when ever any player piece kills other player's piece that piece comes back to home before it was working fine but I added

Is there a way to create a concave physicsBody in SpriteKit?

末鹿安然 提交于 2019-12-12 09:58:11
问题 I have an object on scene and my hero should not go through it, but it should be able to go inside of it, like a boat into the bay, surrounded by the other element. I tried all kinds of physicsBody having it have body with rectangle, texture, with polygon from path, but to no avail. I was reading somewhere that it is not possible to have a concave physicsBody, but only convex. I really need it to be able to be concave. Does anyone know how to resolve this? 回答1: You can create a concave

How to move an object towards a direction without stopping

徘徊边缘 提交于 2019-12-12 09:53:45
问题 I'm developing a small game in Swift 3 with SpriteKit and I want to move the enemies to the direction of the character, but at all times the enemies stop when they arrive at the character's initial position. I'm doing this: enemigo.name = "enemigo" enemigo.position = CGPoint(x: 280, y: 100) enemigo.xScale = 1/1 enemigo.yScale = 1/15 addChild(enemigo) let movement1 = CGVector( dx: (enemigo.position.x - personaje.position.x)*10, dy: (enemigo.position.y - personaje.position.y)*10 ) let

SKTexture nearest filtering mode doesn't work (Making Pixel Art)

心不动则不痛 提交于 2019-12-12 09:39:44
问题 I used a relatively small image (44pixel tall) and scaled it up to have a pixel art look. I tried to change the filtering mode to nearest so the anti-aliasing would disappear but it didn't. It appears with blurry edges. I tried the same with a background getting the same result. let myNode = SKSpriteNode() class GameScene: SKScene { func makeNode() { myNode.position = CGPoint(x: self.frame.size.width/2, y: self.frame.size.height/2) myNode.size = CGSize(width: 200, height: 200) myNode.texture

AVAudioPCMBuffer for music files

邮差的信 提交于 2019-12-12 09:17:15
问题 I've been trying to play music in my SpriteKit game and used the AVAudioPlayerNode class to do so via AVAudioPCMBuffer s. Every time I exported my OS X project, it would crash and give me an error regarding audio playback. After banging my head against the wall for the last 24 hours I decided to re-watch WWDC session 501 (see 54:17). My solution to this problem was what the presenter used, which is to break the frames of the buffer into smaller pieces to break up the audio file being read.

Creating a Linear Gravity Field in Swift

血红的双手。 提交于 2019-12-12 09:12:31
问题 It seems that linear gravity field with vector method has been deprecated in Swift. There's a bunch of new SKFieldNode in this new language, but I can't seem to find one that resembles linear gravity. The property "direction" isn't even available in Swift. Maybe it can be done using this generic method customFieldWithEvaluationBlock but I'm not sure how. I'm new to SpriteKit. So, how can we make the same physics effect in Swift? 回答1: In Swift 2 (part of Xcode 7), SIMD vectors are available to

Presenting a scene in SpriteKit without discarding the previous?

大憨熊 提交于 2019-12-12 08:54:36
问题 My situation is that I have a GameMenuScene and after the user chooses a level, I want to present the LevelScene . But I do not want to have the previous GameMenuScene discarded because the LevelScene is actually a @property of GameMenuScene and whether or not the user completes the level is to be saved as a @property of LevelScene , which the GameMenuScene should be able to access after the user finishes or exits the level. If I simply use presentScene:transition , the GameMenuScene is

SpriteKit: cannot change node position in contact callback

此生再无相见时 提交于 2019-12-12 08:44:54
问题 I have a node with a dynamic physics body. And I would like to make it static and change its position when it comes in contact with another body. I managed to make the body static with the solution provided in this question: Sprite Kit failing assertion: (typeA == b2_dynamicBody || typeB == b2_dynamicBody) However if I change the position property of the node in one of the contact callback methods (e.g didBeginContact ) the new position is not taken into account. How could I achieve that? 回答1