【问题标题】:cocos2d - how to add a particle system to a scenecocos2d - 如何在场景中添加粒子系统
【发布时间】:2011-03-07 19:03:00
【问题描述】:

我找不到任何有关如何将使用粒子设计器创建的粒子系统添加到场景的文档。

所有编程指南都是这样说的:

id particleSystem = [CCParticleSystemQuad particleWithFile:@"MyParticle.plist"];

好的。然后呢? [self addChild:particleSystem];?

还有这个问题:

#import "cocos2d.h"
#import "CCParticleSystemQuad.h"
error: CCParticleSystemQuad.h: No such file or directory

【问题讨论】:

  • 如果我这样做,CCParticleSystemQuad *particleSystem;抛出这个错误:error: ISO C++ forbids declaration of 'CCParticleSystemQuad' with no type

标签: iphone cocos2d-iphone particles


【解决方案1】:

您可能想尝试使用CCParticleSystem* 指针,看看它是否对您有任何不同。这是我正在开发的一款游戏的示例……

CCParticleSystem* particle_system = [CCParticleSystemQuad particleWithFile:@"myEffect.plist"];
[my_node addChild:particle_system];

particle_system.position = ccp(xpos, ypos);
[particle_system resetSystem];  

这对我使用 0.99.5 非常有用。如果您使用的是 0.99.5,那么您在使用的 Cocos2D 实现中肯定应该有 particleWithFile 函数。

【讨论】:

    【解决方案2】:

    partacle 系统 .h 在您加载时应该已经在您的项目中。

    我正在使用的书将partacle系统初始化为

    CCParticleSystemQuad* system = [CCParticleSystemQuad particleWithFile:"blah.png"];
    [self addChild:system z:1 tag:1];
    

    除了初始化粒子系统四边形之外没有其他细节。

    【讨论】:

    • .h 文件中有哪些导入?当我尝试你的代码时,我得到了这个:错误:'CCParticleSystemQuad'没有在这个范围内声明
    • 你是用cocos2d 0.99.5还是用cocos2d 0.99.4?
    • 将其更改为 CCQuadParticleSystem* 并告诉我是否遇到错误。
    • 我没有得到编译错误,但在运行时我得到这个:+[CCQuadParticleSystemparticleWithFile:]: unrecognized selector sent to class 0xe9268
    • 事实上,在整个项目中搜索“particleWithFile”是空的。 Cocos2d 是不是就决定放弃这个未经宣布的?
    【解决方案3】:

    如果你使用 cocos2d-iphone-0.99.5

    你必须导入“CCParticleSystemPoint.h”

    并检查下面的 linezs。

    在你的 cocos2d 库“ccparticleexamples.h”中引用这个词“ARCH_OPTIMAL_PARTICLE_SYSTEM”

    希望这对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多