sprite-kit

SKShapeNode(circleOfRadius) results in “unrecognized selector sent to class” in Playground for OSX

狂风中的少年 提交于 2019-12-22 03:42:42
问题 The following playground results in a timeline error "unrecognized selector sent to class..." import SpriteKit let node = SKShapeNode(circleOfRadius: 10) Screenshot Seems to work ok when platform is iOS. Running 10.9.3 回答1: It's because you're running it on an OS X version that's older than the API you're trying to use. The code you're using requires OS X 10.10, or iOS 8 and up. The OS X 10.10 API Differences confirm that all of SKShapeNodes custom initializers have just been added in 10.10.

SpriteKit ball loses all energy hitting wall, restitution=1

◇◆丶佛笑我妖孽 提交于 2019-12-22 03:40:16
问题 If I apply an impulse of 1 in the y direction, the ball bounces back and forth without losing any energy. However, if the initial impulse is 0.5 or below, the ball loses all energy instantly when it hits the wall. Why is this happening? I have a pretty good understanding of the properties of the SKPhysicsBody class. Try this code to see if you get the same behavior on your computer. -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { /* Setup your scene here */ self

CUICatalog: Invalid Request: requesting subtype without specifying idiom (Where is it coming from and how to fix it?)

穿精又带淫゛_ 提交于 2019-12-22 01:24:53
问题 When I run my SpriteKit game, I receive this error multiple times in the console. As far as I can tell (though I'm not completely sure), the game itself is unaffected, but the error might have some other implications, along with crowding the debug console. I did some research into the error, and found a few possible solutions, none of which seem to have completely worked. These solutions include turning ignoresSiblingOrder to false , and specifying textures as SKTextureAtlas(named: "atlasName

Giving properties of a UIButton to a SKSpriteNode in SpriteKit

守給你的承諾、 提交于 2019-12-22 01:05:49
问题 I was wondering if there was a way to give the properties of a UIButton like darkening the button once it has been pressed,... to a SKSpiteNode since an SKSpiteNode has more customization and because I am using SpriteKit . I have seen 1 other question like this but none of the answers worked. Here is the code I have to create the SKSpriteNode and to detect a touch on it: import SpriteKit class StartScene: SKScene { var startButton = SKSpriteNode() override func didMoveToView(view: SKView) {

pausing spritekit game using appdelegate in ios8

我的梦境 提交于 2019-12-22 00:36:27
问题 I have a pause menu in my game that I want to toggle when the i hit my home button. it works when I'm within my game, however when I hit my home button the menu comes up, but the game will not pause. when i restart the app, the menu is still there, but the game un-pauses itself. It seems like spritekit automatically pauses and restarts the game on its own when you leave and enter the app. When I'm within the app I have full control over it. But when I'm exiting/entering the app it behaves how

touchesEnded:withEvent: is not called

左心房为你撑大大i 提交于 2019-12-22 00:34:12
问题 If I tap the screen too fast with two fingers, touchesBegan is called, but touchesEnded is not called for one of the touches. I've googled like crazy and this seems to be a serious issue that people have been having since at least 2010. Apparently it hasn't been fixed. Does anyone know of a workaround for this or is there a way to determine touches without the 4 methods or gesture recognizers? (They tend to cause a delay which isn't practical for me.) By the way, all 4 methods are implemented

How to create joints in Sprite Kit (Xcode)?

瘦欲@ 提交于 2019-12-22 00:05:21
问题 I don't understand how to create a joint to connect two bodies in SpriteKit. Thanks for help. 回答1: The principle is the same for all joint types. First, create a joint connecting two bodies with some additional parameters (refer to the Sprite Kit Framework reference for details). Then add the newly created joint to the physics world: CGPoint anchor = CGPointMake(100, 100); SKPhysicsJointFixed* fixedJoint = [SKPhysicsJointFixed jointWithBodyA:aBody bodyB:otherBody anchor:anchor]; [self.scene

Segue from GameScene to a viewController Swift 3

混江龙づ霸主 提交于 2019-12-21 23:18:47
问题 I need to make a segue from a GameScene to a UIViewController. My code so far is the following: In the GameViewController.swift I added: if let view = self.view as! SKView? { if let scene = SKScene(fileNamed: "GameScene") { scene.scaleMode = .aspectFill scene.viewController = self view.presentScene(scene) } ... and in my GameScene.swift I added class GameScene: SKScene, SKPhysicsContactDelegate { var viewController: UIViewController? ... as well as func returnToMainMenu(){ self.viewController

SKSpriteNode does not let touches pass through when isUserInteractionEnabled false

久未见 提交于 2019-12-21 22:39:37
问题 I'm attempting to create an overlay in SpriteKit which by using an SKSpriteNode . However, I want the touches to pass through the overlay, so I set isUserInteractionEnabled to false. However, when I do this, the SKSpriteNode still seems to absorb all the touches and does not allow the underlying nodes to do anything. Here's an example of what I'm talking about: class TouchableSprite: SKShapeNode { override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { print("Touch began")

How to rotate sprite in sprite kit with swift

本小妞迷上赌 提交于 2019-12-21 22:20:57
问题 Hi my problem is regarding the rotation of two sprites. When I touch the right half of the screen the rotation starts and moving sprite2 and sprite3. If I touch the left half of the screen the rotation stops because velocity-velocity = 0. If I touch the left half again the rotation begins. However, if I touch the half of the screen corresponding with the current rotational-direction the velocity is duplicated. I want to be able to change the direction of the rotation, but for the speed to