sprite-kit

SKShapeNode - Animate color change

你说的曾经没有我的故事 提交于 2019-12-18 12:49:12
问题 I'm working on a game with SpriteKit. I'm drawing a shape with SKShapeNode. Now I want to animate its colour change but the SKActions is not working for SKShapeNode. Is there any way to do this or I have to use a different approach? Thank you. EDIT: Thanks to LearnCocos2D I was able to come up with this quick (and totally not perfect) solution. int groundChangeInterval = 5; SKColor *originalColor = [SKColor colorWithRed:0.92 green:0.87 blue:0.38 alpha:1.0]; SKColor *finalColor = [SKColor

iAd in sprite kit game

耗尽温柔 提交于 2019-12-18 12:38:12
问题 I know there is at least one question asking how to integrate iAd into a sprite kit game, but that is not what I am looking for. I am looking for a portrait version of how to do it. There seem to be absolutely 0 tutorials online as to how to do this, so I came here. Can someone please tell me how to simply enable iAd in a Sprite Kit game? I have enabled canDisplayBannerAds and have used the originalContentView property for my UIView, but I keep getting a crash that says * Terminating app due

Xcode 9 Crashing while setting a Texture in SKScene in Spritekit

醉酒当歌 提交于 2019-12-18 12:22:42
问题 I am building a game in Spritekit with Xcode currently. After updating to Xcode 9 I've found that every time I set a texture through the .sks file, Xcode crashes instantly. I've restarted my computer, updated the app, reloaded the textures and nothing changed. I have the 2017 Macbook Prof 13" w/ touch bar. Here are the diagnostics: Process: Xcode [577] Path: /Applications/Xcode.app/Contents/MacOS/Xcode Identifier: com.apple.dt.Xcode Version: 9.0.1 (13249) Build Info: IDEFrameworks

How to access the object of Navigation graph in SpriteKit scene editor

喜夏-厌秋 提交于 2019-12-18 12:05:52
问题 I am working with SpriteKit and draw a scene by the help of the scene editor in xcode. According to SpriteKit, we can use Navigation graph to draw the paths and I am able to draw a path using navigation graph but i am not able to access this object in swift back-end. How to access this Navigation graph object from the scene. 回答1: In the default SpriteKit template the GameViewController has a section in the viewDidLoad function that copies over the Scene Editors Entities and Graphs. class

What is UnsafeMutablePointer<Void>? How to modify the underlying memory?

為{幸葍}努か 提交于 2019-12-18 11:57:27
问题 I am trying to work with SpriteKit's SKMutableTexture class but I don't know how to work with UnsafeMutablePointer< Void > . I have a vague idea that it is a pointer to a succession of byte data in memory. But how can I update it? What would this actually look like in code? Edit Here is a basic code sample to work with. How would I get this to do something as simple as create a red square on the screen? let tex = SKMutableTexture(size: CGSize(width: 10, height: 10)) tex

How to create progress bar in sprite kit?

泪湿孤枕 提交于 2019-12-18 11:36:11
问题 I want to create my own progress bar in Sprite Kit. I figured I will need to images - one fully empty progress bar and filled progress bar. I have those images, I put filled one on top of empty one, they are regular SKSPriteNodes now I can't figure out how do I cut my filled image where I need? How do I cut SKSpriteNode image at certain point? Maybe texture? 回答1: I would recommend looking into SKCropNode. For a visual aid how SKCropNode works, look it up in the Apple Programming Guide. I have

Simulate water/ make sprite “float” on water in spritekit

浪子不回头ぞ 提交于 2019-12-18 11:36:04
问题 I'm trying to add water to my game. Except for a different background color, there isn't much to it. However, I'd like the player-sprite to float on top of it (or halfway in it). If the player just walks into the water from below, I'd like him to float to the top. If he falls down, I'd like him to slowly change direction and float back up. I tried making the gravity negative when he's in the water, but this gives me some slightly unwanted effects. For example as he (the player) surfaces, the

Building a SpriteKit/GameKit leaderboard within a specific scene

这一生的挚爱 提交于 2019-12-18 11:33:55
问题 I'm pretty new to Swift and I'm having some trouble implementing a leaderboard into my game. I just watched a tutorial: 'Game Center Leaderboards! (Swift 2 in Xcode)' in which the GameCenter information all went through the one view of the app. In my game, I want the user to be able to play the game and then only when they are on a specific SKScene will they have access to GameCenter. So for example, on the GameOverScene will they be user authenticated and also will be able to upload their

Making a particle follow a path in spriteKit

心不动则不痛 提交于 2019-12-18 10:44:17
问题 I have created a particle and when I test it moving on Xcode's property window, it looks like this: I have added this particle to a scene, made a circle and forced the particle to run that circle using this: NSString *myParticlePath = [[NSBundle mainBundle] pathForResource:@"particle" ofType:@"sks"]; SKEmitterNode *myParticle = [NSKeyedUnarchiver unarchiveObjectWithFile:myParticlePath]; [self addChild:myParticle]; CGPathRef circle = CGPathCreateWithEllipseInRect(CGRectMake(0,0,400,400), NULL)

Scrolling background - Sprite Kit

南笙酒味 提交于 2019-12-18 10:24:49
问题 So I tried to create an infinite scrolling background by using this post's solution (Sprite kit side scrolling). However, I would want to make the image repeatable. As you can see in the video below, after the image has finished it's horizontal way, there is some empty gap.. I would like to make the image fill that gap, so repeat it endlessly. http://www.youtube.com/watch?v=kyLTGz7Irrc or https://vimeo.com/79555900 (password: spritekit) What I did : for (int i = 0; i < 2; i++) { SKSpriteNode