sprite-kit

how Xcode automatically remove skspritenode form its parent's node

China☆狼群 提交于 2019-12-21 22:04:19
问题 I'm new in objectif-c and sprite-kit development (but not in programming). So I'm starting the Apple's Spri. The app works perfectly, except that the nodes representing the rocks are automatically removed form its parent when rocks fall through the bottom of the scene. This, without implementing the -(void)didSimulatedPhysics method : - (void)didSimulatedPhysics { [self enumerateChildNodesWithName:@"rock" usingBlock:^(SKNode *node, BOOL *stop) { if (node.position.y < 0) [node removeFromParent

iPhone 6+ simulator doesn't load @3x images from atlas

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 21:38:43
问题 What I've noticed when running project on iPhone 6+ simulator is that simulator don't pick up right images. Instead of @3x, @2x images are used. I tried reseting simulators content and settings, clean project and delete derived data from organizer and same thing still happens. When I look for the myatlas.atlasc folder inside the myapp.app (show package contents) at the path: /Users/username/Library/Developer/Xcode/DerivedData/appname-appspecificgeneratedstring/Build/Products/Debug

Sprite Kit Textures Acting Funny

橙三吉。 提交于 2019-12-21 21:37:30
问题 OK, this one's got me screaming to the walls... so bear with me please. I started to code a simple game using the SpriteKit template in Xcode. I added two PNGs to a folder named Stage01.atlas and dragged that to the project. Can't remember if which option I chose, because it appears as a blue folder icon in the project navigator (perhaps because it has an extension?). Next, I instantiated several sprites using [[SKSpriteNode alloc] initWithImageNamed:@"My_Image_Name_Without_The_@2x_Or

iOS SpriteKit SKAction completion call not working/creating odd results

雨燕双飞 提交于 2019-12-21 21:31:05
问题 I'm trying to have a SKNode move onto the screen on command. I've set up the following SKAction chain so that 1) The node moves up and offscreen, then 2) the node moves down into a starting place, then 3) starts moving around. I've used the following code to try and implement this: SKAction *moveUp = [SKAction moveTo: shipIntroSpot1 duration:3.0]; SKAction *moveDown = [SKAction moveTo:shipSpot1 duration:ship1MovementSpeed]; [self enumerateChildNodesWithName:@"ship1" usingBlock:^(SKNode *node,

iOS Application crashes when using SpriteKit's TextureAtlas and building over Xcode command-line

∥☆過路亽.° 提交于 2019-12-21 20:56:28
问题 We use the new SpriteKit framework in iOS 7 to develop small games. To build and distribute new versions of our games, we use a build and deploy server which uses Xcode5's command-line tools. When we use a Texture Atlas in Xcode and open the SpriteKit view which uses images from the texture atlas, the application (built over command-line) crashes. When we build the application Xcode's GUI and deploy it to the device using Xcode's GUI, everything works fine and the application does not crash.

How to make High Score of game to be saved on Leaderboard, with Swift?

 ̄綄美尐妖づ 提交于 2019-12-21 20:47:07
问题 I made a game using SpriteKit and Xcode 7 beta. I tried to put GameCenter and Leaderboard but the problem is that the score in leaderboard won't change it stay all the time 0 (High Score of game won't save in Leaderboard) and I don't know how to fix it. I'm using 3 different files: GameScene.swift , GameViewController.swift , and PointsLabel.swift . GameScene.swift func addPointsLabels() { let pointsLabel = PointsLabel(num: 0) pointsLabel.position = CGPointMake(30.0, view!.frame.size.height -

Load SpriteKit levels from filename

半世苍凉 提交于 2019-12-21 20:44:28
问题 For a game I'm creating, I want to be able to create a lot of custom levels that can be loaded easily. Each level should have a .sks interface file and its own SKScene subclass .swift file. Right now, this is working: extension SKScene { class func unarchiveFromFile(file : NSString, theClass : AnyClass!) -> SKScene? { if let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") { var sceneData = NSData.dataWithContentsOfFile(path, options: .DataReadingMappedIfSafe, error: nil) var

How can I use KVO on SKSpriteNode position property

廉价感情. 提交于 2019-12-21 20:15:29
问题 I would like to use KVO to observe changes to the SKSpriteNode position property, but it doesn't seem to work. Is SKNode's position property observable? 回答1: Nope, it is not. SK behind the scenes is a C++ engine that bypasses most of Objective-C's overhead, like for instance KVO (KVC will still work cause that's entirely on you). Unlike in UI(Kit) apps, most values of most objects change often anyway, so if you're interested in changes to a property it's faster to simply check it every frame

Is there a way to make a soft body with Spritekit using SKSpriteNode and PhysicsBody parameters?

做~自己de王妃 提交于 2019-12-21 20:06:07
问题 I have the following sprite that falls to the bottom of the screen: // The View self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame]; self.physicsWorld.contactDelegate = self; // The Sprite SKSpriteNode *cube = [[SKSpriteNode alloc] initWithImageNamed:@"cube"]; [cube setPosition:CGPointMake(160,250); [self addChild:cube]; // The Physics cube.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:cube.frame.size]; cube.physicsBody.dynamic = YES; cube.physicsBody

Running SpriteKit Game in watchOS on Apple Watch Simulator (xCode 8, Swift 3, iOS 10) - libswiftSwiftOnoneSupport Error

人盡茶涼 提交于 2019-12-21 19:55:58
问题 I downloaded xCode 8.0 beta and opened a recent project written in swift 2 which I then converted to swift 3 using xCode. I then added a watchOS target to my project with the setting "game" File > New > Target: I checked the GameScene.swift in the WatchExtension and sure enough all the code is there and sets up a scene: import SpriteKit class GameScene: SKScene { private var spinnyNode : SKShapeNode? override func sceneDidLoad() { if let label = self.childNode(withName: "//helloLabel") as?