sprite-kit

Using unowned inside of a capture list causing a crash even the block itself isn't executed

风格不统一 提交于 2019-12-19 02:15:01
问题 Here, I was playing with leaks, so I've made a strong reference cycle intentionally to see if the Instruments will detect something, and I got unexpected results. The leak shown in Instruments certainly make sense, but the random crash is a bit mysterious (due to two facts I will mention later). What I have here is a class called SomeClass : class SomeClass{ //As you can guess, I will use this shady property to make a strong cycle :) var closure:(()->())? init(){} func method(){} deinit

SpriteKit iPhone/iPad different resolution, need same physics

允我心安 提交于 2019-12-18 20:54:23
问题 As I am porting an iPhone app that uses SpriteKit to iPad, I have been able to scale all the screen elements and font sizes using the height ratio of the iPhone 5 to iPad screen. Everything looks proportional, except for the physics since there is more area. So the question is, how do I scale the physics along with the screen using that height ratio? Perhaps changing density or mass of all the nodes? How would I do it, mathematically using the ratio so that it is perfect? 回答1: You can

Sprite Atlas and @2x images

丶灬走出姿态 提交于 2019-12-18 20:09:10
问题 When using texture atlas (iPhone5) do I have to include sprite images at both normal and normal@2x sizes (even though I am only targeting retina devices). I thought I could getaway with only adding the @2x versions but sadly when I run the application the sprites come out a lot bigger than they should be (nearly 4x), I only get the right size sprites displayed when I add the normal (@1x) images to the atlas as well. EDIT: Starting a new project file in Xcode, if you want an image to fill the

iOS Builds: This build is invalid in iTunes connect

ぐ巨炮叔叔 提交于 2019-12-18 18:41:10
问题 I recently uploaded an app to the app store and its been processing for a few days now. I went in this morning to check everything out, and on the top bar of iTunes connect, i clicked on iOS builds to see how everything was going and I got a red circle with an exclamation point in it. When I clicked on it, it says "This build is invalid". Does anyone know the cause of this? 回答1: Check your email, it tells you exactly what is wrong. In itunes connect it simply says "This build is invalid"

What is the proper way to programmatically create a SpriteKit SKTileMap?

一曲冷凌霜 提交于 2019-12-18 17:08:25
问题 I am creating a tile map for an iOS game I am working on. The map is a top down view of an island. Most of the tiles are water, but some are land. The water tile is reused to create the water, but none of the land tiles are used more than once, because all of the land tiles are unique. I have looked through the docs for SKTileDefinition, SKTileGroup, SKTileGroupRule, SKTileSet, and SKTileMap, and this is what I came up with: func createTileMap() { let waterTile = SKTileDefinition(texture:

Clamping camera around the background of a scene in SpriteKit

点点圈 提交于 2019-12-18 17:08:08
问题 so I have a base game setup that can be found at the bitbucket link below: Game link I'm currently having a hard time understanding how to translate the camera node in relation to the scene's layout. The goal is to have the camera follow the player up until hitting a corner boundary defined by the size of the scene. In this particular test scenario setup, the scene is 1000x1000 in size with a camera scale of 1. The code below is used to modify the position of the camera when a new position is

Major Bug, Sprite Atlas created in XCAssets Folder does not support batch rendering

随声附和 提交于 2019-12-18 17:03:05
问题 I started using the new Sprite Atlas in the XCAssets folder instead of having my atlases in the project folder. However I noticed that when I did this my nodes were no longer being batch rendered which resulted in a large number of inefficient draw calls. This completely defeats the purpose of using an atlas! To be clear this is the code I used to get the atlas. let atlas = SKTextureAtlas(named: "Sprites") "Sprites" is a Sprite Atlas created in the XCAssets Folder. Does anyone have a

Pause an SKAction in Spritekit with Swift

只谈情不闲聊 提交于 2019-12-18 15:55:26
问题 I have the following code to move an SKSpriteNode . let moveDown = SKAction.moveBy(CGVectorMake(0, -120), duration: 1) let moveUp = SKAction.moveBy(CGVectorMake(0, +120), duration: 1) let moveSequence = SKAction.sequence([moveDown, moveUp]) square.runAction(SKAction.repeatActionForever(moveSequence)) This moves the SKSpriteNode up and down forever. Is there a way that I could pause this SKAction ? So that the SKSpriteNode will freeze in its current position, and then later when I decide,

SKShapeNode consuming too much memory and slowing down animation -Spritekit iOS

筅森魡賤 提交于 2019-12-18 13:48:10
问题 I am using SKShapeNode to to create a mountain like object . I use CGMutablePathRef to give the points to my path SKShapeNode *shapenode = [[SKShapeNode alloc] init]; CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 0, 0); ...... for (int i = 0; i < [refData count];i++) { CGPathAddLineToPoint(path, NULL, ((float)i/[refData count])*screenWidthBoundry, [[refData objectAtIndex:i] doubleValue]); } CGPathAddLineToPoint(path, NULL, screenWidthBoundry, 0);

In SpriteKit, SKCropNode has no effect over a SKShapeNode

左心房为你撑大大i 提交于 2019-12-18 13:24:43
问题 I've been trying to apply a mask to a SKShapeNode using SKCropNode, and so far without success. Thinking that it's a SpriteKit bug - Here is the code snippet: SKNode* contentNode = [SKNode node]; // picture - use an image bigger than 50x50 SKSpriteNode *pictureNode = [SKSpriteNode spriteNodeWithImageNamed:@"tree"]; // triangle SKShapeNode* triangleNode = [SKShapeNode node]; UIBezierPath* triangleNodeBezierPath = [[UIBezierPath alloc] init]; [triangleNodeBezierPath moveToPoint:CGPointMake(0.0,