sprite-kit

Keep relative positions of SKSpriteNode from SKShapeNode from CGPath

混江龙づ霸主 提交于 2019-12-24 00:46:44
问题 I have an array of array of coordinates (from a shapefile), which I'm trying to make into a series of SKSpriteNodes. My problem is that I need to keep the relative positions of each of the shapes in the array. If I use SKShapeNodes, it works, as they are just created directly from the path I trace, but their resources consumption is quite high, and, in particular I cannot use lighting effects on them. If I use SKSpriteNodes with a texture created from the shape node, then I lose their

iOS 8 Game Center Error

半城伤御伤魂 提交于 2019-12-24 00:46:43
问题 I updated my XCode and iOS. My codes worked well before update. Now I can't login game center. Console gives this error GameKitHelper ERROR: { NSLocalizedDescription = "The requested operation could not be completed because this application is not recognized by Game Center."; } 回答1: I found the answer. Sandbox is not enable in iOS 8. Need to enable Sandbox in Settings -> Game Center -> Sandbox. 来源: https://stackoverflow.com/questions/25945420/ios-8-game-center-error

How to draw a hollow circle with two different colors?

我们两清 提交于 2019-12-24 00:30:55
问题 Im very familiar with drawing a filled createEllipseInRect shape node, but I was wondering if there's a way to do this programmatically. I want a circle thats split through the center with two separate colors on either side. I don't have code since I have no idea where to start with this. something like this Help much appreciated. 回答1: You can try using SKCropNode, this allows you to show only half of each circle. See below code for example of this. class GameScene: SKScene { override func

Custom ttf font makes Spritekit's transition slow in SWIFT

孤街醉人 提交于 2019-12-23 23:40:53
问题 I am having trouble with transition when using custom ttf fonts for spritekit in swift. I realized that when I use the code below my app gets laggy and slow for only the first time. Are there any way to fix this issue? Are there any examples or tips? let loadLabel = SKLabelNode(fontNamed:"Silom") loadLabel.text = "Loading ....." loadLabel.fontSize = 30 loadLabel.fontColor = SKColor.whiteColor() //loadLabel.position = CGPoint(x:self.size.width/2, y: self.size.height/2 ) loadLabel.zPosition=2

Does a SKTexture from a SKTextureAtlas support the mipmap feature?

不想你离开。 提交于 2019-12-23 21:32:40
问题 From apples documentation: "You can only request mipmaps if both of the texture’s dimensions are a power of two." However, it's unclear whether the SKTextures from SKTextureAtlas's also support this feature (since they're essentially a bit different in nature). I ask the question because it's actually hard to see if anything is getting mipmapped from the results. 回答1: First off a SKTexture from a SKTextureAtlas does not support mipmapping. Secondly sometimes mipmapping doesn't even work with

UIVisualEffectView creates a grey box instead of blurring

匆匆过客 提交于 2019-12-23 19:41:17
问题 I'm using a UIVisualEffectView to blur a section of the screen in SpriteKit like so: let blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark) let UIEffectView:UIVisualEffectView = UIVisualEffectView(effect: blur) UIEffectView.frame = CGRectMake(0, 0, frame.width, frame.height * 0.15) self.view?.addSubview(UIEffectView) But it appears as a grey shaded area instead of a blur. Strangely, it blurs whilst the GameCenter notification shows at the start, saying "Welcome back, (player)" -

GameplayKit > Scene Editor Navigation Graph > How to use it for pathfinding?

对着背影说爱祢 提交于 2019-12-23 19:25:15
问题 Not long ago, Apple introduced GameplayKit elements to Xcode's Scene Editor, which is great. However, I seem to have issues with the Navigation Graph element: What I try to achieve is to draw a GKGraph from the Scene Editor, retrieve it in code, and use it as a base for pathfinding. So I draw a GKGraph first: Then I retrieve it in GameScene.swift like this: graph = self.graphs.values.first where graphs is a predefined array by Apple to store the GKGraphs from the Scene Editor. So far so good.

Swift error: “Cannot find interface declaration for 'SKScene', superclass of”

China☆狼群 提交于 2019-12-23 17:26:52
问题 Disclaimer: I read through similar questions on SO, couldn't find a solution to my problem. I want to add an subclass of SKScene to a project that did not previously use SpriteKit. The project is a mixture of ObjC and Swift. The subclass is written in Swift. What I did: Added SpriteKit.Framework by going to the project -> Build Phases -> Link Binary with Libraries . I created a swift class and had it inherit from SKScene. Here is the new class: import SpriteKit class SnowScene: SKScene { }

How do I move a SKSpriteNode up and down around its starting value in Swift?

倾然丶 夕夏残阳落幕 提交于 2019-12-23 16:53:43
问题 I'm currently working on a game, where there's a SKSpriteNode. I want, that this node's location moves up and down all the time. At the beginning, it should have the y value e.g. 500 . Then it should move 200 px down (500+200=700) and then it should move 400 up (700-400=300) so it creates like a up and down, which travels between 500+200 and 500-200 all the time. I hope I explained it understandable. First, how do I get this effect and second, where do I enter it? Should I use a custom func?

Does SpriteKit support dense tessellation of a sprite / texture / shape so it can be warped freely?

烈酒焚心 提交于 2019-12-23 16:11:00
问题 For example if you have an image of a trampoline, and a character jumping on it. Then you want to animate how the trampoline bends down in the center. To do this I would have to take a bitmap and apply it to a densely tessellated OpenGL ES mesh. Then apply texture to it. Then deform the mesh. Does SpriteKit support this or can it only display textures as-is? 回答1: With iOS 10, SKWarpGeometry has been added that allows you to deform sprites. Warps are defined using a source and destination grid