【问题标题】:Sprite Sheet Issues?精灵表问题?
【发布时间】:2012-08-07 00:26:20
【问题描述】:

我用 Zwoptex 创建了精灵表并生成了 .plist 文件。我在将这些精灵表链接到我的 iOS 游戏时遇到问题。我将在 Zwoptex 上创建的 .plist 和 .png 文件加载到 Xcode,但无法识别更改。我不知道为什么会这样。游戏是用 cocos 制作的。

谢谢!

【问题讨论】:

  • 需要更多信息……您尝试了什么?你得到什么结果,你期待什么?任何警告/错误消息?
  • 我使用 Zwoptex 创建精灵表和 .plist 文件。我手动将 .plist 和相关的 .png 文件添加到 xcode 项目中。所有这些文件都显示在项目导航器上,所以我确实看到了它们。我继续使用以下代码更新项目上的 AppDelegate.m
  • // Removes the startup flicker [self removeStartupFlicker]; // Load the sprite files if ( [GameUtils sharedUtils].deviceType == kDeviceIPad ) { [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Images.plist"]; [CCSpriteBatchNode batchNodeWithFile:@"Images.png"]; [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Images@2x~ipad.plist"]; [CCSpriteBatchNode batchNodeWithFile:@"Images@2x~ipad.png"];
  • @2x~ipad 文件是最近添加到 xcode 项目中的。一旦我保存并运行我的项目,它就无法识别新添加的文件。我不知道发生了什么事。请帮我。谢谢!

标签: xcode cocos2d-iphone sprite sprite-sheet


【解决方案1】:

这是一个如何在 cocos2d 中使用 spriteSheet 的示例,我不确定这是否是您想要的,因为缺少细节,但是

 [[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"TreeSequance.plist"];
        CCSpriteBatchNode *treeSheet = [CCSpriteBatchNode batchNodeWithFile:@"TreeSequance.png"];

           CCSprite *smallerTree = [CCSprite spriteWithSpriteFrameName:@"Tree1.png"];

                smallerTree.position = ccp(500,500);
                [treeSheet addChild:smallerTree];
                [self addChild:treeSheet];

【讨论】:

  • 我用过这个`//去掉启动闪烁[self removeStartupFlicker]; // 加载精灵文件 if ( [GameUtils sharedUtils].deviceType == kDeviceIPad ) { [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Images.plist"]; [CCSpriteBatchNode batchNodeWithFile:@"Images.png"]; [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Images@2x~ipad.plist"]; [CCSpriteBatchNode batchNodeWithFile:@"Images@2x~ipad.png"];