sprite-kit

SKAudioNode() crashes when plugging in/out headphones

安稳与你 提交于 2020-01-01 08:34:06
问题 I am using a SKAudioNode() to play background music in my game. I have a play/pause function and everything is working fine until I plug in my headphones. There is no sound at all and when I call the pause/play function I get this error AVAudioPlayerNode.mm:333: Start: required condition is false: _engine->IsRunning() com.apple.coreaudio.avfaudio', reason: 'required condition is false: _engine->IsRunning() Does anyone knows what this means? Code: import SpriteKit class GameScene: SKScene {

Metal crash upon adding SKSpriteNode to SKEffectNode

牧云@^-^@ 提交于 2020-01-01 08:18:16
问题 -[MTLDebugRenderCommandEncoder setScissorRect:]:2028: failed assertion `(rect.x(0) + rect.width(1080))(1080) must be <= 240' I am getting this crash when adding a simple SKSpriteNode to a SKEffectNode with the following code SKSpriteNode *warpSprite = [SKSpriteNode spriteNodeWithImageNamed:@"art.scnassets/symbol.png"]; SKEffectNode *entryEffectsNode = [[SKEffectNode alloc] init]; [entryEffectsNode addChild:warpSprite]; [self addChild:entryEffectsNode]; I have not touched these nodes anywhere

In SpriteKit on iOS, scaling a textured sprite produces an incorrect frame?

▼魔方 西西 提交于 2020-01-01 05:35:07
问题 I'm learning SpriteKit game development for the fun of it & I've run across a seemingly simple problem that has me stumped. Basically, after I scale a textured SKSpriteNode, the frame is NOT what I expect. I have figured out a few hacks to force it to what I want, but I'm trying to understand what is going on. Any ideas appreciated! Here's my code WITHOUT SCALING: func addSpaceship() { let spaceship = SKSpriteNode.init(imageNamed: "rocketship.png") spaceship.name = "spaceship" // spaceship

SKAction runAction does not execute completion block

别来无恙 提交于 2020-01-01 04:51:06
问题 A SKSpriteNode is child of a SKNode and is placed on an array of SKSpriteNode for storage purposes. This SKSpriteNode is deleted using an animation. At the end of this animation a completion block is executed to perform some statements... The deletion must occurred both in the SKSpriteNode parent’s and in the array. Depending on the order of these 2 deletions the result is correct or not: if SKSpriteNode is deleted from 1/ the array then 2/ from the SKNode parent’s, the completion block is

add SKAction to Sprite queue run one after another

时光总嘲笑我的痴心妄想 提交于 2020-01-01 03:34:12
问题 I listen to touch and add SKAction to a sprite. If existing actions are not complete yet, I want the action to be added to a queue so it will execute one after another. Any experienced similar design? I did using Array and Block. If there is any easier approach? @interface GAPMyScene() @property(strong,nonatomic)SKSpriteNode*ufo; @property(strong,nonatomic)NSMutableArray*animationQueue; @property(copy,nonatomic)void(^completeMove)(); @end @implementation GAPMyScene -(id)initWithSize:(CGSize

Moving a SKSpriteNode in a downward loop, using Swift

妖精的绣舞 提交于 2020-01-01 03:33:13
问题 Using Swift and SpriteKit, I'd like to move a SKSpritenode in a spiral pattern, but didn't find the right resources to get me started. To be more precise, I'd like to move a sprite node in a downward loop. I've checked a sequence of SKActions, but as they are not executed parallel, a circular movement combined with move-to will not work. I'd be glad for any hints, tutorials or snippets to set me on the right track. Thanx in advance, Marcus 回答1: I've put together some sample code which you can

SpriteKit enumerateChildNodesWithName with advanced searching?

你。 提交于 2020-01-01 03:11:06
问题 The following code doesn't work as expected. According to the SPRITE KIT PROGRAMMING GUIDE, pages 61 and 62 one may perform "advanced searches" by using regular expression like syntax, so, unless I'm misunderstanding the implementation, this should work? SKShapeNode *myCircle = [self getCircle]; myCircle.name = [NSString stringWithFormat:@"CIRCLE_%d_%d", x, y]; myCircle.position = CGPointMake(10,10); [self addChild:myCircle]; // Lets remove ALL SKNodes that begin with the name "CIRCLE_" [self

Stop objects from colliding using SpriteKit

懵懂的女人 提交于 2020-01-01 02:29:08
问题 I am testing out the features of SpriteKit and I ran into a problem. I was reading into bit masks, colliding, category, and contact. I get what they are, mostly at least, I don't get the point of category bitmasks, but I get colliding bitmasks which are the ones I need to solve my problem. Ok so my problem is I have two different types of sprites: object and second. The names don't really make much sense but it is just for the sake of testing. I want second to have an impulse, and I want

How to make Sprite Kit display @2x images from atlas at correct size?

自古美人都是妖i 提交于 2019-12-31 20:41:32
问题 When a project only has @2x images because it only targets retina display devices, atlas Sprite Kit atlas gets the scale wrong with the RGBA8888_COMPRESSED setting to use with PVR textures. RGBA8888_PNG (the default) sometimes works ok. Before switching to atlas, I had all @2x images in a group and loaded them with: sprite = [SKSpriteNode spriteNodeWithImageNamed:@"theImage.png"]; No problems. Correct size. Now with atlas and RGBA8888_COMPRESSED, I get the SKTexture and the image is way too

Shader performance data maybe unavailable due to deployment target older than device version

偶尔善良 提交于 2019-12-31 11:05:19
问题 In a nutshell, I just want to know if I should be concerned about this issue: runtime: GPU Frame Capture : Shader performance data maybe unavailable due to deployment target older than device version The device I am using is running iOS 12.0, and when I had the app set to target iOS 12, this issue was not appearing. However, after I changed the app's target to 11.4, this appeared. Based on my reading of it, and the performance of my app following the change, I do not think this is of any real