skspritenode

Serious SpriteKit UIColor bug on iPhone 5S

旧巷老猫 提交于 2019-12-11 22:13:57
问题 I've found a serious swift-bug in SpriteKit while working with SKSpriteNodes and their colors. This code works fine on all iPhones beside the iPhone 5S: var color1 = UIColor(red: 123/255, green: 123/255, blue: 123/255, alpha: 1) var color2 = UIColor(red: 123/255, green: 123/255, blue: 123/255, alpha: 1) var sprite = SKSpriteNode(color: color1, size: CGSizeMake(100, 100)) if(sprite.color == color2){ println("Same color") } As you see, the two colors are the absolut same. But on the iPhone 5S

Receive touch events at SKScene AND SKSpriteNode in SpriteKit

别等时光非礼了梦想. 提交于 2019-12-11 12:55:06
问题 Building a UI with buttons as SKSpriteNode's. Button sprites receive touch events to handle special effects (elastic scaling effects) But I need the SKScene to handle the touch events at the same time to handle UI navigation logic. How would be possible to both (sprite AND scene) to handle these touch events? 来源: https://stackoverflow.com/questions/34987142/receive-touch-events-at-skscene-and-skspritenode-in-spritekit

SKAction scaleXTo:-1

旧巷老猫 提交于 2019-12-11 06:46:56
问题 I am trying to mirror my SKSpriteNode using SKAction *mirrorDirection = [SKAction scaleXTo:-1 y:1 duration:0.0]; but every time I do, the sprite's physics body seems to get messed up and it drops off the screen. I have several objects (floors) beneath the sprite and it falls through all of them as if they are not there. This only happens when I mirror the sprite. Anyone know how to fix this? Update: Reseting the physics body as one answer suggested unfortunately did not fix the problem. It

How to get SKSpriteNode name?

别说谁变了你拦得住时间么 提交于 2019-12-11 04:16:00
问题 I'm working with this code I've found and trying to figure out how to get the node names for my objects? Here's part of the code: let sprite1 = SKSpriteNode(color: UIColor.redColor(), size: CGSize(width: 30, height: 30)) let sprite2 = SKSpriteNode(color: UIColor.greenColor(), size: CGSize(width: 30, height: 30)) let sprite3 = SKSpriteNode(color: UIColor.blueColor(), size: CGSize(width: 30, height: 30)) let sprite4 = SKSpriteNode(color: UIColor.yellowColor(), size: CGSize(width: 30, height: 30

Align multiple SKLabelNodes by Baseline

╄→尐↘猪︶ㄣ 提交于 2019-12-11 01:11:10
问题 I have a collection of SKLabelNodes . Each node represents a letter of a word. Each node is the child of an SKSpriteNode . The spriteNode has an explicit hight set on it (the hight returned by [text sizeWithAttributes:@{NSFontAttributeName : font}]; ), and has the same width as the labelNode . The labelNode is then centred inside the spriteNode , and has verticalAlignmentMode = SKLabelVerticalAlignmentModeBaseline . At a later stage, I will need to set a background image on each letter (which

SKSpriteNode UserInteractionEnabled Not Working

人走茶凉 提交于 2019-12-10 23:43:42
问题 I've looked everywhere but nothing works. Thought I would just ask the question myself. I'm creating a little game in iOS 9 using SpriteKit. My game is going to have left and right controller buttons to move the player sprite. I add the SKSpriteNodes for the directional pads as follows At the top of the main scene I put: private var leftDirectionalPad = SKSpriteNode(imageNamed: "left") private var rightDirectionalPad = SKSpriteNode(imageNamed: "right") Then I run a method called

Getting the filename of an SKSpriteNode in Swift 3

亡梦爱人 提交于 2019-12-10 14:59:19
问题 How can I access the image filename from an SKSpriteNode ? I have been trying to Google this, but no answer seems to be available. Here is the impotent part of my code: current_ingredient?.name = String(describing: current_ingredient?.texture) print("Filename: \(current_ingredient?.name)") The print command returns this: Filename: Optional("Optional(<SKTexture> \'ingredient14\' (110 x 148))") So, the question is, how do I get only "ingredient14"? 回答1: It is stored in the description, so here

Spawn nodes at random times combing waitForDuration:withRange and runBlock: in an SKAction sequence

只愿长相守 提交于 2019-12-10 10:29:28
问题 I am making a game with SpriteKit where I have nodes spawning at the top of the screen and falling. However, I want these nodes to spawn at a random time interval between 0.1 and 3 seconds. For example, the first node spawns in 1.3 seconds, the next in 1.8, then 2.5, then 0.8, and so forth forever. I'm not sure how to utilize the waitForDuration function to do this. The code that I currently have is: let wait = SKAction.waitForDuration(3, withRange: 2) let spawn = SKAction.runBlock { addTears

Swift SpriteKit SKSpriteNode's “Sometimes” Don't Show Up

廉价感情. 提交于 2019-12-10 08:17:56
问题 I am making an iOS using Swift and SpriteKit. However I am experiencing irregularity in the running of my app. Sometimes the ship SKSpriteNodes doesn't appear on the screen, sometimes the bullet's SKSpriteNodes don't appear, sometimes everything shows up fine (I add the bullets elsewhere in the code). In all cases I am not making changes to the code between runs. I am starting the app on this screen directly so I'm thinking maybe it has something to do with these SKSpriteNodes not having

SKTexture nearest filtering mode doesn't work (Making Pixel Art)

孤人 提交于 2019-12-10 06:10:38
问题 I used a relatively small image (44pixel tall) and scaled it up to have a pixel art look. I tried to change the filtering mode to nearest so the anti-aliasing would disappear but it didn't. It appears with blurry edges. I tried the same with a background getting the same result. let myNode = SKSpriteNode() class GameScene: SKScene { func makeNode() { myNode.position = CGPoint(x: self.frame.size.width/2, y: self.frame.size.height/2) myNode.size = CGSize(width: 200, height: 200) myNode.texture