【发布时间】:2015-10-09 04:30:53
【问题描述】:
由于某些奇怪的原因,我的纹理图集中的纹理没有加载。我不知道为什么。
以下是我通常如何声明/编码纹理
-(SKSpriteNode *)background {
SKSpriteNode *background;
NSArray *backgroundIpad;
background = [SKSpriteNode spriteNodeWithImageNamed:@"dodgR - main background"];
background.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
background.size = CGSizeMake(1136, 640);
NSArray *backgroundIphone = @[[SKTexture textureWithImageNamed:@"dodgR - animation 1.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 2.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 3.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 4.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 5.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 6.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 7.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 8.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 9.jpg"],
[SKTexture textureWithImageNamed:@"dodgR - animation 10.jpg"]];
SKAction *backgroundIphoneAnimation = [SKAction animateWithTextures:backgroundIphone timePerFrame:0.05];
SKAction *backgroundIphoneRepeat = [SKAction repeatActionForever:backgroundIphoneAnimation];
[background runAction:backgroundIphoneRepeat];
background.name = @"background";
return background;
}
我的纹理图集的名称是 sprites.atlas 任何帮助将不胜感激,谢谢
【问题讨论】:
-
尝试从图像名称中删除 .jpg 。如果这没有帮助,请删除模拟器的内容和设置/从设备中删除应用程序,然后再次构建并运行。而且,您如何看待“不加载”?您是否看到缺少资源图像(带有红色 X 的白色图像)或发生了其他事情?另外,您的背景节点是否正确添加到场景中?
-
所有节点都包含一个红色 X。删除 .jpg 没有帮助
-
纹理出现在屏幕上的唯一时间是它们不在图集中时
-
我并没有过多关注您的代码,而是关注您遇到的问题......因此,正如 Beau Young 所说,您必须在代码中正确使用地图集才能从他们。
标签: ios objective-c sprite-kit sktexture texture-atlas