0

I am having an issue where a CCParticleExplosion works perfectly on the Simulator and fails on my iPhone 4S. In the simulator, the particles look fine. When the explosion happens on my iPhone, there is a dark shadow of the explosion and broken, flickering fragments of the texture used. Here is my code:

bombExplosion = [[CCParticleExplosion alloc] initWithTotalParticles:3];
//bombExplosion = [[CCParticleExplosion alloc] init];

//bombExplosion.autoRemoveOnFinish = YES;
bombExplosion.texture = [[CCTextureCache sharedTextureCache] addImage: @"newnhamm_MultiColored_Sparkle_edit.png"];
bombExplosion.speed=100;
bombExplosion.duration = 1.3;
bombExplosion.life = 0.3;
bombExplosion.position = ccp(835,85);

ccColor4F startColor, startColorVar, endColor, endColorVar;
startColor.r = 1.0f;
startColor.g = 1.0f;
startColor.b = 1.0f;
startColor.a = 1.0f;

startColorVar.r = 0.0f;
startColorVar.g = 0.0f;
startColorVar.b = 0.0f;
startColorVar.a = 0.0f;

endColor.r = 1.0f;
endColor.g = 1.0f;
endColor.b = 1.0f;
endColor.a = 1.0f;

endColorVar.r = 0.0f;
endColorVar.g = 0.0f;
endColorVar.b = 0.0f;
endColorVar.a = 0.0f;

bombExplosion.startColor = startColor;
bombExplosion.startColorVar = startColorVar;
bombExplosion.endColor = endColor;
bombExplosion.endColorVar = endColorVar;

[self addChild:bombExplosion];
  • What's the dimensions of your PNG. I seem to recall there are rules around the sizing of particle images in Cocos2D. Can't remember what the sizing rules are but I would try different sizes to see the result. Also what version of Cocos2D are you using? – Rob Segal Aug 09 '13 at 22:09
  • My version of cocos2d is: cocos2d-iphone v2.1-rc0a. The dimensions don't seem to matter. I tried other images with different dimensions and the same issue happened. Someone told me that it may be the fact that I said initWithTotalParticles as opposed to simply init. Does this sound as though it might be a problem? – user2643829 Aug 09 '13 at 23:53
  • Don't think using initWithTotalParticles as opposed to init would be an issue but easiest way to know for sure would be to try it out. I have a few projects which use initWithTotalParticles so this should be fine. Have you tried a few different devices? Maybe this is something particular to the 4S you are making use of? – Rob Segal Aug 12 '13 at 02:20
  • Hi Rob Segal, I tested it out now on an iPhone 4, iPhone 4S, and iPhone 5. All devices had the same issue. – user2643829 Aug 24 '13 at 06:08
  • Do you have a screenshot of what the issue looks like? Maybe I'm just not understanding what the core problem is. – Rob Segal Aug 26 '13 at 15:54
  • Here you go: [Image of Issue](http://www.mediafire.com/view/xu4z5mmqm0531vy/Screen_Shot_2013-08-26_at_10.56.20_PM.png) – user2643829 Aug 27 '13 at 05:58
  • Here's how it's supposed to look: [Correct explosion in simulator](http://www.mediafire.com/view/qd4yx6i0caedwbv/Screen_Shot_2013-08-26_at_11.01.13_PM.png) – user2643829 Aug 27 '13 at 06:04
  • This is a bit of a long shot but do you get any errors when adding the texture in your console log? [[CCTextureCache sharedTextureCache] addImage: @"newnhamm_MultiColored_Sparkle_edit.png"]; – Rob Segal Aug 27 '13 at 13:58
  • I get this: -[CCFileUtils fullPathForFilename:resolutionType:] : cocos2d: Warning: File not found: fire.png. – user2643829 Aug 28 '13 at 07:41
  • However, I get that error every single time with another animation that I programmed and that animation works fine in both the simulator and the iPhone – user2643829 Aug 28 '13 at 07:43
  • I'm running out of ideas here. If you can host the png somewhere I'd be happy to try it out in a project myself. – Rob Segal Aug 28 '13 at 14:41
  • Okay, I think I might try going all the way back to CCParticleSystem. As for the png, it's open clipart. Here's the link for the [star](http://openclipart.org/detail/27914/multicolored-sparkle-by-newnhamm) – user2643829 Aug 29 '13 at 00:19
  • That particle texture is massive! 566 × 800 is way to big for an individual particle. There's a good chance the issue might be that you are running out of memory. Try resizing it down to 64x64 and see if that works. I think that might be the source of your problem. – Rob Segal Aug 29 '13 at 00:43
  • Nope :( Now there are just smaller shadows and random streaks of yellow. – user2643829 Aug 29 '13 at 04:38
  • I'm wondering if this might be a path discovery issue. The name for the image you have varies quite a bit in terms of case sensitivity. Try changing "newnhamm_MultiColored_Sparkle_edit.png" to something like "sparkle.png" and see if that corrects the issue. The simulator is quite forgiving in terms of case sensitivity but when running on device the rules are very strict and would explain the situation you're encountering. I've tried this image on simulator and on device (iPod4) and it looks fine. – Rob Segal Aug 30 '13 at 15:00

0 Answers0