我试图通过使用 CCFollow 的 CCParticleSystem 的一些实例来跟随一些 Sprite 。我不想让 CCParticleSystem 的实例成为 sprite 的子对象,因为我希望它在 sprite 移除后显示一段时间。 将 Sprite 从左下角移动到右上角时,我的 ParticleSystem 从中心移动到左下角。我不明白为什么会这样。
示例代码如下:
-(id) init
{
if( (self=[super init]) ) {
CCSprite *someSprite = [CCSprite spriteWithFile:@"Icon.png"];
[self addChild:someSprite];
id action = [CCMoveTo actionWithDuration:5 position:ccp(480,320)];
[someSprite runAction:action];
CCParticleSystemQuad *effect = [CCParticleMeteor node];
// effect.positionType = kCCPositionTypeFree;
// effect.positionType = kCCPositionTypeRelative;
// effect.positionType = kCCPositionTypeGrouped; changing of positionType to any of this options does not make any sense
[effect runAction:[CCFollow actionWithTarget:someSprite]];
[self addChild:effect];
}
return self;
}
最佳答案
这是一个糟糕的文文件例。
我自己试了一下,结果一样。通过查看现有的代码和文档片段,CCFollow 操作旨在仅在 CCLayer、CCScene 和可能的 CCNode 等全屏节点上使用。我会将其记录如下:
CCFollow is an action for scrolling the entire screen by allowing the layer or scene follow another node, such as a player object. It's an alternative for moving the Camera object or updating the position manually.
关于iphone - CCFollow 与 CCParticleSystem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12489013/