2

나는 SWIFT3/SpriteKit 스크린 세이버에서 일하고 있어요 그리고 내가 할 때 다음과 같은 때문에 나는 내 질감로드 할 수 없습니다 I를 제외하고 작동하는 화면 보호기를했다 :SKTextureAtlas는 "호스트"번들 대신 "my"번들에서 번들을로드 할 수 있습니까?

// load texture atlas 
let textureAtlas = SKTextureAtlas(named: "Flyers") 

을 SKTextureAtlas는 "전단지"를 찾고에 screensaverengine.app의 내부에서 실행될 때 텍스처가 사는 번들이 아닌 기본 번들.

내 옛날 OBJ-C 기반의 화면 보호기에서

, 나는 번들에서 이미지를로드하기 위해 다음을 수행했다 :

thisBundle = [NSBundle bundleForClass:[self class]]; 
fileName=[[NSString alloc ] initWithFormat:@"flyer%d", flyNum]; 
picturePath = [thisBundle pathForResource:fileName ofType:@"png"]; 
flyerImage= [[NSImage alloc ] initWithContentsOfFile:picturePath]; 

나는 이미지를로드하고 런타임에 텍스처를 만드는 경로를 이동하기 전에, 나는 어떤 도움을 받기 위해 Stackoverflow 패밀리를 탭하고 싶었던가?

답변

0

나는 SpriteKit을 사용한 적이 없습니다.

, 당신은 다음 쉽게 그 이미지의 사전와 아틀라스의 인스턴스를, 어떤 번들에서 이미지를 얻을 수 UIImage(named: imageName, in: bundle, compatibleWith: nil)를 사용할 수있는 아이폰 OS 8 부터 시작하여 문서를보고 :

let bundle = Bundle(for: type(of: self)) 
var dictionary = [String:Any]() 
["textureName": "imageName"].forEach { textureName, imageName in 
    dictionary[textureName] = UIImage(named: imageName, in: bundle, compatibleWith: nil) 
} 
let atlas = SKTextureAtlas(dictionary: dictionary)