sprite-kit

How to prevent run SKAction on paused scene (after unpaused), texture of node not change after pause/unpause scene

不羁的心 提交于 2019-12-10 20:38:46
问题 I have two problems with pausing and unpausing scene. I have button: playPause = SKSpriteNode(imageNamed: "buttPause.png") playPause.name = "pause" playPause.setScale (0.65) playPause.position = CGPoint(x: -self.frame.width / 2.55 , y: self.frame.height / 2.27) playPause.zPosition = 10 self.addChild(playPause) I have set function to pause and unpause scene + change texture of button: func buttonpauseplayTouched() { if isPlaying { playPause.texture = SKTexture(imageNamed: "buttPlay") isPlaying

warning when adding event listener to turn based ios game

时光毁灭记忆、已成空白 提交于 2019-12-10 19:07:29
问题 here is the code in gamekithelper.m - (void)authenticateLocalPlayer { //1 GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; //add a weak local player __weak GKLocalPlayer *blockLocalPlayer = localPlayer; if (localPlayer.isAuthenticated) { [[NSNotificationCenter defaultCenter] postNotificationName:LocalPlayerIsAuthenticated object:nil]; return; } //2 localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) { //3 [self setLastError:error]; if(viewController

Applying a custom SKShader to SKScene that pixelates the whole rendered scene in iOS 8 SpriteKit with Swift

寵の児 提交于 2019-12-10 19:02:22
问题 I'm trying to create a full-screen pixelation effect on SKScene. I've learned that there should be two options to do this: Using a custom SKShader using GLES 2.0. Using Core Image filters. I've tried to add a custom SKShader that should modify the whole screen by pixelating it. I'm not sure that if it's possible, but documentation from SKScene (which is a subclass of SKEffectNode ) suggests it: An SKEffectNode object renders its children into a buffer and optionally applies a Core Image

Layer for pause menu

╄→гoц情女王★ 提交于 2019-12-10 18:39:22
问题 I'm trying to make a pause menu (like this), but if I use the same layer, I can't interact with the scene when it's paused (I guess?!). Everywhere I looked for "pause menu", people said to use another layer . I tried to do it a million times, but it doesn't work (or maybe I'm the one who doesn't know) =( Thats what I've done so far: **Declaring** var gameLayer = SKNode() var pauseLayer = SKNode() var gameStarted = Bool() var Ground = SKSpriteNode() var Character = SKSpriteNode() var

Spritekit Joystick

旧街凉风 提交于 2019-12-10 18:27:58
问题 I'm trying to execute some animations of my player sprite whenever I change the direction of the joystick. I'm using TheSneakyNarwhal's drop in Joystick class which uses the following methods: if (joystick.velocity.x > 0) { [self walkRightAnim]; } else if (joystick.x < 0) { [self walkLeftAnim]; } if (joystick.velocity.y > 0) { [self walkUpAnim]; } else if (joystick.velocity.y < 0) { [self walkDownAnim]; } if (joystick.velocity.x == 0 && joystick.velocity.y == 0) { [self idleAnim]; } My [self

Key data not storing to iCloud with NSUbiquitousKeyValueStore.defaultStore

≡放荡痞女 提交于 2019-12-10 18:17:43
问题 So I have a simple goal, just to get this working. So theoretically if you ruined this. Triggered save players waited a bit Deleted the app Rebuilt (downloaded) Triggered restore then the word "MEDO" would print to the console But instead it is null, making me pretty sure that it is not saving to iC cloud some reason. I followed this tutorial. Perhaps it is too outdated to work? func c_restoreCharecters() { let icloud = NSUbiquitousKeyValueStore.defaultStore() println(icloud.objectForKey(

What is a selector in SKAction: perform(_:onTarget:)

孤者浪人 提交于 2019-12-10 17:42:42
问题 The docs say: Declaration: class func perform(_ selector: Selector, onTarget target: Any) -> SKAction selector The selector of the method to call. I am uncertain what a selector of a method is. Hence the question. It seems like it would be the name of the method/function, but creates (in me) uncertainty because it's never described as being this, so I kind of think it might be something else, something more profound, perhaps. I'm presupposing perform(_:onTarget) is a way for a part of code to

SpriteKit score is acting randomly

梦想的初衷 提交于 2019-12-10 17:39:44
问题 I am creating a game with SpriteKit and attempting to increase the score upon a collision. For some odd reason every time the score increase it is by a random number not just 1. In the didBeginContact method I have a collision between a bullet and an alien. Every time the collide I would like the score to increase the score by 1. Except it has a mind of it's own and will randomly increase it by a number between 1 - 6. I have been through every line of code and have attempted to add scoring

Changing image of a skspritenode()

淺唱寂寞╮ 提交于 2019-12-10 17:22:07
问题 This is how I add my player's texture/image: Player = SKSpriteNode(imageNamed:"player8") How do I change the players texture/image without adding or deleting spritenodes? 回答1: You assign a different texture: player = SKSpriteNode(imageNamed:"player8") Sometime later: player.texture = SKTexture(imageNamed:"player123") Hint: it is bad style to begin variable, property and method names with an uppercase character as it makes them appear to be classes. 来源: https://stackoverflow.com/questions

Physics body size not changing with SKSpriteNode size change in Touch moved method

巧了我就是萌 提交于 2019-12-10 16:55:28
问题 I am trying to create a spring launcher where when touch is moved on scene the spring will coil as much the touch is dragged down and thn launch the item above the spring on touch end method. For that i changed the size and position of SKSpriteNode in touch move method as - launcher.position = CGPointMake(frame.size.width*0.97, launcher.position.y-1) launcher.size = CGSizeMake(frame.size.width*0.05, launcher.frame.size.height-2) But the Physics body of SKSpriteNode not changing it comes like