【发布时间】:2013-12-17 16:37:31
【问题描述】:
我正在关注 Ray Wenderlich 网站上的 SpriteKit 教程。我用 SpriteKit 模板创建了一个项目。问题是我的图像显示为一个大的白色矩形,里面有一个大的红色 X。日志中没有错误。我还在阅读 SpriteKit Programming Guide 和 Texture Atlas 帮助。我假设这是项目设置问题或文件夹结构问题。我对 Xcode 很陌生。这是我的项目在 Xcode 中的样子:
MyGameProj (the top level, with the little blue xcode icon)
-->MyGameProj (yellow folder)
-->Assets (yellow folder)
-->Atlases (yellow folder)
-->dungeon.atlas (blue folder)
dungeon_1.jpg
dungeon_2.jpg
dungeon_3.jpg
hero_trans.gif
various .h and .m files
起初,Assets 文件夹位于 MyGameProj 文件夹之外。都没有用
这是代码。这是在MyScene、initWithSize() 内:
SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"dungeon"];
SKTexture *texture = [atlas textureNamed:@"hero_trans.gif"];
self.player = [SKSpriteNode spriteNodeWithTexture:texture];
self.player.position = CGPointMake(100, 100);
[self addChild:self.player];
我已经进入构建设置并打开了图集生成。
【问题讨论】:
-
在下面查看我的答案。但也只是想 - 为什么是 gif?如果您想要运动等外观,最好使用一系列动画图像
-
我不知道为什么它是一个 gif;没有动画;只是我从某个地方得到的一个精灵
标签: xcode sprite-kit