sprite-kit

Creating a custom slider using Sprite Kit - how do I pass a @selector?

别等时光非礼了梦想. 提交于 2019-12-05 19:23:16
A Sprite Kit game I'm working on uses a custom slider to act as a color picker (the color is picked from the slider track graphic, which is a UIImage containing a gradient). I looked into using a customised UISlider , but standard IOS UI controls don't play well with Sprite Kit's Scenes: they're difficult to position relative to the rest of the Scene (as they exist as a subview of the main View rather than as a part of a SKScene ), they pop into existence (rather than transitioning with the rest of the Scene) and must be manually removed when exiting the scene. In short, implementing them is a

Prevent player from falling through the ground - Sprite Kit

a 夏天 提交于 2019-12-05 19:19:20
I've been trying to work on a simple Sprite Kit game that involves dodging red balls. I'm using the built-in gravity mechanism, but I'm having trouble preventing the player from falling through the ground. I've looked up a solution (set ground.physicsBody.dynamic = NO), but the player still falls through. What exactly do I need to do? Edit: The green and brown texture is the ground. Right now the player is set to not being dynamic, so it is 'flying' Here is my code in the MyScene.m file: // // MyScene.m // DodgeMan // // Created by Cormac Chester on 3/8/14. // Copyright (c) 2014 Testman

How to select buttons in tvOS menu for SpriteKit game

不羁的心 提交于 2019-12-05 18:54:31
I am extending my iOS game for tvOS. Most of the game controls are handled by touchesBegan , touchesMoved and touchesEnded . All my select buttons are handled in the following way: if button1.contains(location){ let gameplayScene = GamePlayScene(size: self.size) self.view?.presentScene(gameplayScene) } if button2.contains(location){ let settingsScene = SettingsScene(size: self.size) self.view?.presentScene(settingsScene) } if button3.contains(location){ let helpScene = HelpScene(size: self.size) self.view?.presentScene(helpScene) } for an image below: How can I appropriately highlight and

SKSpriteNode : Handling Collision during SKAction

别说谁变了你拦得住时间么 提交于 2019-12-05 18:40:52
I'm making a little game, and I'm now stuck with the following problem. I'm running an action (followPath type) on a particular node : let followTrack: SKAction = SKAction.followPath(ballPath!.CGPath, duration: ACTION_SPEED) movingBall.runAction(followTrack) But during the animation, if the node collide with another one (like a wall for exemple), the animation stops and there is no collision animation. I tried some things like : func didBeginContact(contact: SKPhysicsContact) { var firstBody: SKPhysicsBody = contact.bodyA var secondBody: SKPhysicsBody = contact.bodyB firstBody.node?

Memory Leak in Sprite Kit Application

给你一囗甜甜゛ 提交于 2019-12-05 18:34:38
I have a Sprite Kit game that I created in Xcode 5 and when profiling it for leaks using Instruments I see that there are indeed some leaks: The problem is that I can't tell where in my application this is coming from as the "Responsible Frame" column doesn't point me to anywhere in my application. How would one go about debugging/tracking the origins of this issue? Update #1 There is only one file in which I'm interacting w/ CGPath but I am calling CGPathRelease ... CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 0, 0); CGPathAddLineToPoint(path, NULL, size.width,

having a node follow at a constant speed

北慕城南 提交于 2019-12-05 18:32:43
I'm trying to make a small mini game where you drag a ball around the screen and every 10 seconds a ball gets added in that follows you. so far the you can drag a ball around the screen and a ball follows you, but when another ball gets added in the balls group together. I think this is because the ball is following me depending on how fast I'm going. so is there a certain way in which I can have the balls follow me at a certain speed constantly, like 10 pixels a second or something, and that should prevent the balls from grouping together. I am currently working on the score so it should soon

Swift Displaying Game Center Leaderboards

左心房为你撑大大i 提交于 2019-12-05 18:22:31
Right now I am trying to make a leaderboard I created show up. The player is authenticated just fine, but when the game center window opens it is very strange. Here is a picture: Here is the code I am using to display this image: override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { self.showLeaderboard() } func showLeaderboard() { var leaderView = UIViewController() var leaderViewController = GKGameCenterViewController(rootViewController: leaderView) leaderViewController.viewState = GKGameCenterViewControllerState.Leaderboards leaderViewController.leaderboardIdentifier =

After Closing SKScene, Memory Remains High

泪湿孤枕 提交于 2019-12-05 18:20:55
问题 I use a dispatch_once NSObject to create data pointers. So all game asset pointers are made when the main viewcontroller appears. In order to play a game, the user taps a UIButton corresponding to a particular level on a UIViewController . Let me call it LevelSelectionController. When the game is over, the user will tap a label ( SKLabel ). And all actions and nodes will be removed. [self removeAllActions]; [self removeAllChildren]; [self removeFromParent]; Moreover, an SKScene subclass for a

\n not working in Sklabel SpriteKit

与世无争的帅哥 提交于 2019-12-05 18:12:30
问题 I have been using the following code in my game. The Problem is that i am unable to make multi-line label in spritekit as i was able to do using CCLabelTTF...... Can Somebody help me. Also i am unable to use either \t or \n in my code... Thanks for the reply in advance SKLabelNode *winner = [SKLabelNode labelNodeWithFontNamed:@"Arial"]; winner.text = @"Another\nTest"; winner.fontSize = 32; winner.fontColor = [SKColor blueColor]; winner.position = CGPointMake(100 , 160); [self addChild:winner]

iOS7 SKScene how to make a sprite bounce off the edge of the screen?

烂漫一生 提交于 2019-12-05 18:01:28
I'm building a game with balls bouncing within the iPad's screen. Similar to a Pong game. I see that SKScene's SKPhysicsWorld has gravity property, and also controls how objects collide with each other. Is there some way I can automatically detect if a sprite's edge has collided with the screen's edge, so it can bounce off that? Or do I need to write my own collision code? You don't need to write much code to make the ball bounce off the edge of the screen. the physics environment can handle all of the above, you just need to instantiate the sprites in the correct way. First, you will have to