'接收器类型“CCParticleBatchNode”对于类消息是一个前向声明

发布于 2024-12-13 05:41:48 字数 934 浏览 0 评论 0原文

标题不言而喻。我通过从github下载文件,删除项目中的cocos2d项目并重新添加它来安装cocos2d 1.1。

我的头文件中有一个“@class CCParticleBatchNode”,前缀和相关实现文件中都有#import“cocos2d.h”。当我浏览到 CCParticleBatchNode 应该所在的位置时,它就在那里。

那么,有人知道问题可能是什么吗? :)

编辑:这是一些代码。

#import "PrecipicationLayer.h"
#import "cocos2d.h"

@implementation PrecipicationLayer
@synthesize cloudLayer;
- (id)init
{
    self = [super init];
    if (self)
    {
        rain = [CCParticleRain node];
        rainBatch = [CCParticleBatchNode particleBatchNodeWithFile:@"Raindrop48px.png" capacity:400 useQuad:YES additiveBlending:NO];
        [self addChild:rainBatch];

        [self schedule:@selector(tick:)];
    }
return self;
}

和头文件:

#import <Foundation/Foundation.h>
#import "cocos2d.h"
@class CCParticleBatchNode;

@interface PrecipicationLayer : CCLayer {
    CCParticleBatchNode *rainBatch;
}

@end

所有不相关的部分已被删除。

The title speaks for itself. I installed cocos2d 1.1 by downloading the files from github, removing the cocos2d project inside my project and re-adding it.

I have a '@class CCParticleBatchNode' in my header file and #import "cocos2d.h" both in my prefix and in the relevant implementation file. When i browse to the location CCParticleBatchNode should be, it is there.

So, does someone know what the problem might be? :)

Edit: Here's some code.

#import "PrecipicationLayer.h"
#import "cocos2d.h"

@implementation PrecipicationLayer
@synthesize cloudLayer;
- (id)init
{
    self = [super init];
    if (self)
    {
        rain = [CCParticleRain node];
        rainBatch = [CCParticleBatchNode particleBatchNodeWithFile:@"Raindrop48px.png" capacity:400 useQuad:YES additiveBlending:NO];
        [self addChild:rainBatch];

        [self schedule:@selector(tick:)];
    }
return self;
}

and the header file:

#import <Foundation/Foundation.h>
#import "cocos2d.h"
@class CCParticleBatchNode;

@interface PrecipicationLayer : CCLayer {
    CCParticleBatchNode *rainBatch;
}

@end

All irrelevant parts have been removed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

云醉月微眠 2024-12-20 05:41:48

哦好吧……常见的cocos2d升级麻烦。

就我个人而言,我会简单地安装 cocos2d 1.1 模板(假设它们是最新的)并基于 cocos2d 模板之一创建一个项目。然后将源代码和资源添加到这个新创建的项目中。这通常比尝试替换和更新现有项目中的 cocos2d 代码要好得多。

我猜你的问题可能是因为删除了 cocos2d 项目而不是硬盘上的文件。这意味着旧版本中仍然可能存在一些遗留文件,这些文件仍然包含在项目中并构建。在将新的 cocos2d 文件移动到位之前,您肯定要删除所有现有的 cocos2d 文件。

最后,不排除你从github下载的版本有损坏的可能性。这不是第一次了。尝试使用网站上的可下载版本,并记住 1.1 目前只是测试版。

提示:将来您可能想使用 Kobold2D 创建 cocos2d 项目,它有一个 升级工具消除了所有这些麻烦。

Oh well … the usual cocos2d upgrade troubles.

Personally I would simply install the cocos2d 1.1 templates (assuming they're up to date) and create a project based on one of the cocos2d templates. Then add your source code and resources to this newly created project. This usually works a lot better than trying to replace and update the cocos2d code in an existing project.

I guess that your problem may be coming from removing the cocos2d project but not the files from your hard drive. That means there can still be some left-over files from the old version that are still included in the project and built. You definitely want to delete all existing cocos2d files before moving the new cocos2d files in place.

Finally, don't rule out the possibility that the version you downloaded from github is broken. It wouldn't be the first time. Try using the downloadable version from the website instead, and keep in mind that 1.1 is just a beta at this point in time.

Tip: in future you may want to create cocos2d projects with Kobold2D, it has an upgrade tool that does away with all those troubles.

路弥 2024-12-20 05:41:48

如果您已在 .h 文件中导入了 cocos2d.h,则无需在 .m 文件中导入它。不过,我认为这不是问题。

有两种可能性:

  • CCParticleBatchNode 在 cocos2d.h 中定义,在这种情况下,您不需要前向声明,这可能会使编译器感到困惑。
  • CCParticleBatchNode 未在 cocos2d.h 中定义,在这种情况下,您需要在实现文件中导入 CCParticleBatchNode.h,因为您拥有的只是前向声明。

There is no need to import cocos2d.h in your .m file if you have imported it in your .h file. I don't think that's the problem, though.

There are two possibilities:

  • CCParticleBatchNode is defined in cocos2d.h, in which case you don't need a forward declaration and this may be confusing the compiler.
  • CCParticleBatchNode is not defined in cocos2d.h, in which case you need to import CCParticleBatchNode.h in your implementation file as all you have is the forward declaration.
羞稚 2024-12-20 05:41:48

“删除我的项目中的 cocos2d 项目并重新添加它。”

检查这些文件是否是构建过程的一部分。在 XCode 4 中,单击项目导航器顶部的项目名称,选择“构建阶段”,确保目标名称下显示“cocos2d 库”。如果是,则展开“目标依赖项”,并确保它也列在那里。然后展开“链接二进制文件与库”并确保它也添加到那里。

"removing the cocos2d project inside my project and re-adding it."

Check that the files are part of the build process. In XCode 4, click the project name in the top of the Project Navigator, select "Build Phases," make sure "cocos2d libraries" is shown under the target name. If it is, then expand "Target Dependencies," and make sure it's also listed there. Then expand "Link binary with Libraries" and make sure it's also added there.

⊕婉儿 2024-12-20 05:41:48

我在下载最新模板时遇到了同样的问题。问题在于,尽管文件 CCParticleBatchNode.h 和 CCParticleBatchNode.m 实际存在,但它们尚未添加到 Xcode 项目模板中。我只需要将它们添加到项目中,然后就可以编译了。

I had the same problem when downloading the newest templates. The problem was that even though the files CCParticleBatchNode.h and CCParticleBatchNode.m were present physically, they had not been added to the Xcode project template. I just had to add them to the project and then it compiled.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文