在资产目录中,我为iPhone和iPad设备设置了一个名为“panda”的图像集。适用于iPhone的3张图片和适用于iPad的2张图片
当我在iPad Air,iPad Air 2,iPad Retina,iOS 2和iOS 8.4上运行该应用程序时,图像将会显示,但iPad 2上的iOS 9没有任何反应!
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */
for touch in touches {
let location = touch.locationInNode(self)
let sprite = SKSpriteNode(imageNamed:"panda")
print(sprite)
sprite.position = location
let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)
sprite.runAction(SKAction.repeatActionForever(action))
self.addChild(sprite)
}
}
使用版本 7.0
以下是设置
//编辑1.0
显然这是一个尚未修复的错误
https://forums.developer.apple.com/thread/4268 https://forums.developer.apple.com/message/36854#36854
答案 0 :(得分:0)
尝试(Objective-C)
UIImage *img = [UIImage imageNamed:@"image"];
SKTexture *textureBg = [SKTexture textureWithImage:img];
SKSpriteNode *nodeBg = [SKSpriteNode spriteNodeWithTexture:textureBg];