sprite-kit

Parallax background does not repeat

别来无恙 提交于 2019-12-11 18:14:15
问题 My code is for a repeating moving background, and it's meant to repeat forever. But when I simulate it, it goes once and then the background just goes grey. This is my code: SKTexture* bgTexture = [SKTexture textureWithImageNamed:@"nightbackground"]; bgTexture.filteringMode = SKTextureFilteringNearest; SKAction* movebgSprite = [SKAction moveByX:-bgTexture.size.width*2 y:0 duration:0.1 * bgTexture.size.width*2]; SKAction* resetbgSprite = [SKAction moveByX:bgTexture.size.width*2 y:0 duration:0]

Swift and SpriteKit: how to implement non-fuzzy circle timer with SKShapeNode

旧城冷巷雨未停 提交于 2019-12-11 17:49:22
问题 The code below implements a circle timer with SKShapeNode where one slice of the circle vanishes as time ticks off. Unfortunately, the timer is fuzzy because of limitations with SKShapeNode. Answers like this did not address the issue, and also were old and may no longer apply. 1) Is there a way to use SKShapeNode without such fuzzy lines? 2) If there is no way to fix SKShapdeNode, what are the alternatives for implementing a similar circle timer? let timer = SKShapeNode(circleOfRadius:

Animate rotation of SKSpriteNode

烈酒焚心 提交于 2019-12-11 16:37:08
问题 I am attempting to rotate an SKSpriteNode to face the direction of a CGPoint . I have managed to do this like so: CGPoint direction = rwNormalize(offset); self.player.zRotation = atan2f(direction.y, direction.x); How would I call this so that the SKSpriteNode will animate its rotation rather than it being instantaneous. Would it also be possible to keep the same speed of rotation in the animation no matter where the sprite should turn? Thanks in advance! 回答1: Use SKAction : CGPoint direction

Removing SKSpiteNode from parent

两盒软妹~` 提交于 2019-12-11 14:43:46
问题 Im trying to remove SKSpriteNodes from the parent, "self". I create the nodes via a for loop inside a function I call every time I need to update the number of nodes. This nodes represent the number of lives a player has inside the game. func starsSpwan() { self.starNode.removeFromParent() var spaceInX:CGFloat = 0 for var i = 0; i<gameLife; i=i+1 { starsTexture = SKTexture(imageNamed: "star") starsTexture.filteringMode = SKTextureFilteringMode.Nearest starNode = SKSpriteNode(texture:

Swift Cannot construct string with argument type Int64

江枫思渺然 提交于 2019-12-11 14:05:58
问题 I am making a game that involves a Game Center leaderboard. I want to make a custom leaderboard UI rather than using the default interface. I am trying to convert the values stored in a Game Center leaderboard into a string so that I may display them using an SKLabelNode. However, I get an error saying that: Cannot invoke initializer for type 'String' with an argument list of type '(Int64?)' I am accessing the Game Center scores using leaderboard.scores[i].value When I use the String

Hardware specific atlas with Sprite Kit is blown up on iPad

拜拜、爱过 提交于 2019-12-11 13:48:35
问题 Watching talk 503 "Designing Games with Sprite Kit" from WWDC 2013, they say that one of the benefits of texture atlases is that you only need to drop a folder to XCode and it generate hardware specific atlases for different devices (OSX, iPhone, iPhone Retina, iPad...) Is that correct? I'm dropping a folder with a frames for a sprite animation and though it appears the same size on iPad 2 and iPad retina, its size is twice the correct size, and, of course, in the iPad retina the image is

Why does setting frameInterval on a SKView not work?

眉间皱痕 提交于 2019-12-11 13:43:56
问题 I'm trying to reduce the framerate to a maximum of 30 FPS. The official documentation says to use: skView.frameInterval = 2; I read through all the available documentations as well as every similar question asked here on stackoverflow or in other pages/blogs/etc. I tried it in so many ways but where ever I tried to set the property it did not affect the FPS. I am not using any other timing mechanisms than those from SpriteKit. I am setting it up accordingly to the documentation and to the

SpriteKit Crashing On Entering Background with [Flurry startSession:FlurryAPPKey];

扶醉桌前 提交于 2019-12-11 13:38:06
问题 I have googled this, and I found many debates over this, what i understand is this problem is related to rendering of OpenGl of Spritekit, Some people were facing this problem when they were playing AUdio with Spritekit. While My case is different i am facing this when i integerate Flurry publisher Api using the Function In [Flurry startSession:FlurryAPPKey]; in APPDelegete File Commenting out the above code removed the problem. I think there are a couple of things that when you integerate

SpriteKit: Using SKTextureAtlas causes incorrect Physics Body

核能气质少年 提交于 2019-12-11 13:23:41
问题 I am building my first sprite kit game, and recently read an article that said to use SKTextureAtlas to improve performance. So I migrated all my sprite images into organized .atlas folders and updated the code accordingly. However, now my sprites have weird physics bodies (mainly over-enlarged) . For instance, my player sprite has three states: Flying (flat), Flying Up and Flying Down. The three images are pretty similar, with slight variations (arms pointing flat, up, down) . Before

Is there a way to program games without depending on fram rate?

白昼怎懂夜的黑 提交于 2019-12-11 13:22:06
问题 Im programming an iOS game and I use the method update for a lot of things, which is called at the game speed refresh (for the moment 60 times per second) but the problem is if the frame rate drops down (for example a notification, or any behavior in the game that, when called, it makes drop down a little bit the fps...) then the bugs comes.... A fast example is if I have an animation of 80 pictures, 40 for jump up and 40 for fall, I would need 1,2 second to run the animation, so if the jump