cocos2d游戏,ccarticle系统纹理混乱
我的游戏使用多个粒子系统。每次我使用第一个粒子系统(例如stars.plist)时,要显示的下一个粒子将使用stars.plist的纹理。 (所以如果下一个粒子是雨,那么将是星星雨:( 我使用 [ARCH_OPTIMAL_PARTICLE_SYSTEM 粒子WithFile: @""],例如:
CCParticleSystem* rain = [ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:@"rain.plist"];
[self addChild:rain z:-1];
在初始化雨之前,我调用了一个预加载粒子的方法,只需使用:
[ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:@"rain.plist"];
然后,如果我要播放的下一个粒子是meteor.plist,则使用的纹理仍然是雨。 plist 的纹理。
我使用相同的方式显示流星:
NSString* fn = [NSString stringWithFormat:@"meteor%i.plist", random];
CCParticleSystem* meteor = [ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:fn];
我在3gs和iPhone 4和模拟器中尝试过CCParticleQuad和CCParticlePoint,但仍然存在同样的问题。
my game use several particle systems. every time i use the first particle system, stars.plist for example, the next particle to be displayed will use the texture of stars.plist. (so if next particle is rain, then will be a rain of stars :(
I use [ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile: @""], like:
CCParticleSystem* rain = [ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:@"rain.plist"];
[self addChild:rain z:-1];
and before initializing the rain, i have a call to preload the particle simply using:
[ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:@"rain.plist"];
then if my next particle to play is meteor.plist, the texture used is still the rain.plist's texture.
i use the same way to display meteor:
NSString* fn = [NSString stringWithFormat:@"meteor%i.plist", random];
CCParticleSystem* meteor = [ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:fn];
I've tried CCParticleQuad and CCParticlePoint, in both 3gs and iPhone 4 and simulator, but still the same problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果纹理数据嵌入在
.plist
文件中,cocos2d 将提取该数据并将其在内部存储为纹理。纹理以纹理文件名作为键进行存储,因此如果您有两个在内部使用相同纹理文件名的粒子系统,则首先加载的纹理将应用于所有后续使用相同的纹理文件名!检查这一点的一个简单方法是查看您的
.plist
文件并搜索textureFileName
键。对于每个纹理,此键应该不同。由于图像数据嵌入在您的.plist
文件中,因此您可以将此值更改为您想要的任何值......例如stararticle.png
代表星星,rainarticle.png
代表雨,等等。只需为每个独特的纹理使用独特的东西即可。如果失败,您仍然可以通过从如下文件加载纹理来手动应用纹理:
If the texture data is embedded within the
.plist
file, cocos2d will extract that data and store it as a texture internally. The texture is stored with the texture filename as key, so if you have two particle-systems that use the same texture-filename internally, then the texture that was loaded first will be applied for all subsequent uses of the same texture filename!An easy way to check this is looking at your
.plist
file and search thetextureFileName
key. This key should be different for each texture. Since the image-data is embedded in your.plist
file, you can change this value to anything you want.. eg.starparticle.png
for your stars,rainparticle.png
for the rain, etc. Just use something unique for every unique texture.If that fails, you could still apply the texture manually, by loading it from a file like this: