sprite-kit

sknode can't see added children

徘徊边缘 提交于 2019-12-13 01:26:24
问题 Here i created a menu class which contains a few items. I want to display these sprites in the main class. I experimented with this by creating an object associating with the sknode class in the touches began method, but when i added the menu object in the main class using the addChild thing, nothing showed up. class menu:SKNode { let background = SKSpriteNode(imageNamed:"background") required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override init

How to keep SKActions running through an SKTransition in Sprite Kit?

帅比萌擦擦* 提交于 2019-12-13 00:48:54
问题 I have tried the following code when trying to transition between scenes in my Sprite Kit project: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ XYZGameScene *gameScene = [[XYZGameScene alloc] initWithSize:CGSizeMake(self.size.width, self.size.height)]; crossFade = [SKTransition fadeWithColor:[UIColor blackColor] duration:2]; [playButtonSprite runAction:changePlayButtonTextureOFF]; if(toGameAction){ [self.scene.view presentScene:gameScene transition:crossFade]; }else{} }

Sprite Kit random positions

↘锁芯ラ 提交于 2019-12-13 00:48:46
问题 I am trying to position my 1 nodes at random between 3 Points. Lets say these Positions are : 1: CGPoint(x: CGRectGetMidX(self.frame) - 123.5 , y: CGRectGetMidY(self.frame) * 2.5) 2: CGPoint(x: CGRectGetMidX(self.frame) , y: CGRectGetMidY(self.frame) * 2.5) 3: CGPoint(x: CGRectGetMidX(self.frame) + 123.5 , y: CGRectGetMidY(self.frame) * 2.5) My code: let arabaHareketi = SKAction.moveByX(0, y: -self.frame.size.height * 2, duration: 2.5) let turuncuYapılışı = SKTexture(imageNamed: "turuncu")

Global function call in Swift? Howto?

荒凉一梦 提交于 2019-12-13 00:40:13
问题 I have a Swift noobie question on class method calls. I'm building a simple learning app for my kids using Sprite Kit. I have a global variable scoreCount defined in GameScene, where I pretty much do all my game logic such as detect correct answer and increment scoreCount. I also have GameOverScene. On both I show the Score -label. I'm keeping count of scores with the scoreCount-parameter (in GameScene). However as I'm quite new to Swift and Sprite Kit, I'm wondering how should I update the

Xcode 7 SpriteKit Error with Blocks

醉酒当歌 提交于 2019-12-13 00:28:59
问题 Does anybody know why this won't work anymore in Xcode 7 GM? I have debugged and verified, but even though the nodes are appearing on the scene, they no longer pass touch events to parent nodes. Below is a fully working example. If you replace the default GameScene from the "New Sprite Kit Game" you can reproduce it yourself. class GameScene: SKScene { override func didMoveToView(view: SKView) { let card = Card(imageNamed: "card_background_blank") card.name = "Card" let stack = Stack

Why won't this SKPhysicsJointPin keep these 2 sprites together?

半世苍凉 提交于 2019-12-12 21:19:37
问题 I clearly don't understand the SKPhysicsJoint very well, but there is so little info on the web yet, other than the Apple docs of course. What is wrong with the following code, which I would think should keep the head and neck permanently joined - my intention is that they act like 2 pieces of paper with a pin, so that they can rotate a bit, but not just totally come apart. When I run this code, they fall to the bottom of the SKScene they're in, hit the ground, then the head falls off the

Spritekit/Universal images from assets not showing up on iOS 9?

Deadly 提交于 2019-12-12 19:18:56
问题 I made a universal app using SpriteKit and Swift. Users have sent out bug reports on iOS 9 where sprite node images are showing up white/blank. But I haven't been able to reproduce this in the simulator. The images that don't show up are all device-specific in images.xcassets. The images that do show up are the ones that are universal in images.xcassets. What could I do to solve this (besides making them not device-specific) and could this possibly be an XCode/iOS bug? 回答1: Yeah it's a bug

SKEase action, how to use Float changing Action Setter Block?

浪子不回头ぞ 提交于 2019-12-12 19:07:08
问题 In the following use case, I'm trying to animate the lineWidth of an SKShapeNode . SKEase is part of the wonderful SpriteKitEasing github repo from Craig Grummitt. One of its facilities is a Float changing ease action that appears to change the value of a float over time. However I can't figure out how to use it. Xcode gives the following suggestions when typing it in: let lineWeight = SKEase.createFloatTween(<start: CGFloat, end: CGFloat, time: TimeInterval, easingFunction: AHEasingFunction,

iOS7 SpriteKit how to wait for an animation to complete before resuming method execution?

混江龙づ霸主 提交于 2019-12-12 18:17:57
问题 Is there a way to make a method wait for a SpriteKit action initiated within the method to complete before continuing code execution? Here's what I have so far, but it just hangs at the wait loop. __block BOOL wait = YES; SKAction* move = [SKAction moveTo:destination duration:realMoveDuration]; SKAction* sequence = [SKAction sequence:@[[SKAction waitForDuration:0.07],move,[SKAction waitForDuration:0.07] ]]; [spellEffect runAction:sequence completion:^{ [spellEffect removeFromParent]; wait =

Does userInteractionEnabled property work correctly on SpriteKit nodes?

允我心安 提交于 2019-12-12 18:10:54
问题 I have following simple code: // // BGMyScene.m // Test1 // // Created by AndrewShmig on 3/10/14. // Copyright (c) 2014 Bleeding Games. All rights reserved. // #import "BGMyScene.h" @implementation BGMyScene - (id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { /* Setup your scene here */ self.backgroundColor = [SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0]; // first label SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"]; // myLabel