Cuicatalog: Invalid Request: Requesting Subtype Without Specifying Idiom (Where Is It Coming from and How to Fix It)

CUICatalog: Invalid Request: requesting subtype without specifying idiom (Where is it coming from and how to fix it?)

I have this error too. In my opinion, it's the Xcode 7.2 bug and not your fault. I've updated Xcode in the middle of making an app and this message starts to show up constantly in the console. According to this and that links, you have nothing to fear here.

Custom framework using SpriteKit - asset files not loaded

Well since you can get the desired asset from the framework as a UIImage, couldn't you just

let image = UIImage(named: "image", in: type(of: self), compatibleWith: nil) 
let texture = SKTexture(image: image)
let sprite = SKSpriteNode(texture: texture)

Swift 2: Crash when using SKAction

I don't think this is the problem, however in SpriteKit if you want to invoke a method forever you should not use NSTimer but SKAction.

Replace your didMoveToView with this.

override func didMoveToView(view: SKView) {
let addEnemy = SKAction.runBlock { [weak self] in self?.makeEnemiesTowards() }
let wait = SKAction.waitForDuration(1)
let sequence = SKAction.sequence([addEnemy, wait])
SKAction.repeatActionForever(sequence)
}

UImage loads entire SKTextureAtlas instead of just SKTexture

I reconciled image.CGImage() does not support textures from SKTextureAtlas, after reading a similar post SKTextures from SKTextureAtlas does not support mipmapping.

One approach is to form a SKTexture from SKView.textureFromNode(_ node: SKNode)

let textureToRender = myOffscreenView.textureFromNode(nodeToRender)

let newImage = UIImage(CGImage: textureToRender.CGImage())

SkSpritenode normal texture not restoring even with restore on?

Suggested Solutions

Try setting your sprite to the last texture in the atlas like this: theSprite.texture = atlas[atlas.count-1]. Then run your code again. You should see that it restores to back to atlas[atlas.count-1].

If your animation stops at a texture other than your last atlas texture, then you could try this. Set theSprite.texture = atlas[atlas.count-1] within your animation's completion block. You would also set restore to false in this case. This will animate your sprite then set the final texture to whatever you want, in this case it will be set to the last atlas texture.

Explanation

Restore will return your sprite back to the texture that it had before the animation began. So in your case with your current code, it should end the animation with the texture atlas[0]. It is not meant to end on the last frame of the array as you stated.

According to the Apple dev reference, if restore is true:

When the action completes, the sprite’s texture is restored to the
texture it had before the action completed.
https://developer.apple.com/reference/spritekit/skaction/1417810-animate

how to set duration for individual SKTextures in animation

You can use SKAction sequence and it's waitForDuration:withRange: method, like this:

//By default, the sprite is initialized with downTexture
let sprite = SKSpriteNode(texture: downTexture)
sprite.position = CGPoint(x: 200, y: 200)
addChild(sprite)
let sequence = SKAction.sequence([

SKAction.runBlock({NSLog("Up texture set")}), //Added just for debugging to print a current time
SKAction.setTexture(upTexture),
SKAction.waitForDuration(2.5, withRange: 3.0), //Wait between 1.0 and 4.0 seconds
SKAction.runBlock({NSLog("Down texture set")}),
SKAction.setTexture(downTexture),
SKAction.waitForDuration(0.65, withRange: 0.7),//Wait between 0.3 and 1.0 seconds
])

let action = SKAction.repeatActionForever(sequence)

sprite.runAction(action, withKey: "aKey")

What this code does, is that it creates a sprite, initialize it with downTexture by default and:

  • swap texture to upTexture immediately
  • waits between 1 and 4 seconds
  • swap texture to downTexture
  • waits between 0.3 and 1 seconds
  • repeats all this forever

If you want to stop this action, you can access it like this:

if sprite.actionForKey("aKey") != nil {
removeActionForKey("aKey")
}


Related Topics



Leave a reply



Submit