sprite-kit

SpriteKit shader crash iOS 9: SKDefaultShading, gl_FragCoord

ⅰ亾dé卋堺 提交于 2019-12-05 15:13:11
问题 Just installed the iOS 9 open beta (version 3) and now I'm having loads of problems with SpriteKit shaders. On iOS 8 the following code worked just fine: _fontShader = [SKShader shaderWithFileNamed:@"TheShader"]; // TODO: iOS9 compatibility issues here _fontUniform = [SKUniform uniformWithName:@"labelBase" float:0]; [self.fontShader addUniform:self.fontUniform]; // TODO: iOS9 compatibility issues here _fontEffects = [SKEffectNode node]; self.fontEffects.shader = self.fontShader; // TODO: iOS9

How to set the background image for a SKScene?

久未见 提交于 2019-12-05 14:56:12
Since currently it is not possible to set the color to of a SKScene to clearColor , by doing -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { self.backgroundColor = [SKColor clearColor]; } return self; } As seen here: LINK Then how can one set the background image for a SKScene ? Please be as specific as possible, sample code would be great! Use an SKSpriteNode centered in the scene: -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { // Replace @"Spaceship" with your background image: SKSpriteNode *sn = [SKSpriteNode spriteNodeWithImageNamed:@

Create water(fluid) surface with Sprite Kit [closed]

你。 提交于 2019-12-05 14:46:05
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 5 years ago . How can i create water surface with Sprite Kit ? I have searched and found help for Cocos2d which uses box2d to create physics effects for water like object floating over water and some part of it in water and other outside of water. Objects going down the water with as force as applied to throw it into the water and similar effects. So how can i achieve the same water effect

Render/Snapshot SpriteKit Scene to NSImage

萝らか妹 提交于 2019-12-05 14:37:44
问题 Does anyone know how to "snapshot" a complete SKView or SKScene into an NSImage ? We have been able to use the textureFromNode API to create an SKTexture from a node and all its children. But so far we can't figure out a way to extract the image data into say an NSImage . We are building a mixed Cocoa / SpriteKit app where we need to extract small thumbnails of scenes. Again, this seems possible on iOS (to get a UIImage ) using drawViewHierarchyInRect : UIGraphicsBeginImageContextWithOptions

What is the method unarchiveFromFile in GameViewController for?

≡放荡痞女 提交于 2019-12-05 13:45:51
When I tried to add different scenes to my game in Swift, I encountered the method unarchiveFromFile. The problem with this method is that it only works with the GameScene class. If you call it from extension SKNode { class func unarchiveFromFile(file : NSString) -> SKNode? { if let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") { var sceneData = NSData.dataWithContentsOfFile(path, options: .DataReadingMappedIfSafe, error: nil) var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData) archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene") let scene

What is the maximum number of categoryBitMask's allowed in Sprite Kit?

拥有回忆 提交于 2019-12-05 12:57:41
I heard only 32 different categorybitmask's are allowed to be used per Sprite Kit game. Is there any way around this? I absolutely need more then that (roughly 3-4 times more since the game is an open world one). I set up my categorybitmask's as following: static const uint64_t boundaryCategory = 0x1 << 0; static const uint64_t mainCharCategory = 0x1 << 1; ... static const uint64_t someOtherCategory = 0x1 << 31; I even changed uint32_t to uint64_t hoping that would double the amount of categorybitmask's I could use. Unfortunately, it doesn't. If anyone knows any techniques to by-pass this

Changing SKSpriteNode Frame? Isometric challenges

徘徊边缘 提交于 2019-12-05 12:46:00
I hope we can figure out how to get around this interesting challenge with a game we are designing in an isometric style. Any help would be so awesome! QUESTION Is there a way to change the bounding box frame from a square to another shape? Maybe using a mask? PROBLEM Our problem is that we need our node's tappable area NOT to be square. Since we are tiling the nodes, their bounding boxes overlap each other, and we cannot accurately tap on the tile that we want. Hopefully our graphic below will show you what we are designing, our problem, and what our tappable area needs to be. Is there a way

How to create a timer in Spritekit?

六眼飞鱼酱① 提交于 2019-12-05 12:35:22
Ive figured out how to make a timer in a single-view application, but not Spritekit. When I use the following code, I get 2 errors(listed below). Can anyone help me out with this? Thanks, Jack. The timer. if(!_scorelabel) { _scorelabel = [SKLabelNode labelNodeWithFontNamed:@"Courier-Bold"]; _scorelabel.fontSize = 200; _scorelabel.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)); _scorelabel.fontColor = [SKColor colorWithHue: 0 saturation: 0 brightness: 1 alpha: .5]; [self addChild:_scorelabel]; } _scorelabel = [NSTimer scheduledTimerWithTimeInterval: 1 target:self

In Xcode 6 Beta 4 stroking with SKShapeNode doesn't work anymore

会有一股神秘感。 提交于 2019-12-05 12:19:38
In Xcode 6 beta 2 it worked fine, but in beta 4 it doesn't work anymore. Does anyone know what's behind this mystery? let circle = SKShapeNode(circleOfRadius: 125); circle.strokeColor = UIColor(red: 255, green: 255, blue: 255, alpha: 1.0); circle.lineWidth = 4 self.addChild(circle); In beta 4 nothing can be seen. Thanks for your help in advance. Santa Claus This is a common issue with Xcode 6 Beta 4 when using the simulator. It renders fine when using an actual device . See this developer forums thread . It is worth noting that the issue is exclusive to stroking in that setting circle

SpriteKit Particle Emitter Not Appearing in Xcode Editor

浪尽此生 提交于 2019-12-05 11:26:50
I'm having a constant issue of particle effects not appearing in the editor. Everything works fine when I first create them, but after some time they stop appearing. I just see the black background, but the particles aren't there. The only way I'm able to deal with this problem is to delete the node and create a new particle node with the same attributes, which is time consuming and annoying. And then, after a while, the same thing happens to the new particle nodes. Anyone else experience this? This happens to me all of time after editing a value and switching to code view of another page.