Cannot set particle texture

Hi there. I am trying to set a particle texture but it does not work.

I made my particles using the particle2dx editor.
The problem is, when I tried to add the .plist which included the PNG data, the particles wouldnt show up at all.
Now I am trying to set the particle texture manually, but it is not working.
Am I missing something obvious?

Check the signature of setTexture(), because you’re not passing the correct data to it. Also, it’s better to cut and paste code into the post next time, and use the back tick ` character to format it (3 backtick characters before and after the code segment).

You need to create the texture first, and then pass it to the particle emitter using setTexture. One way to achieve this would be:

auto* texture = Director::getInstance()->getTextureCache()->addImage("explode_particle.png");

now it is giving me this error
what should I do?

The problem is literally right there on the popup: “Expression: !textureData.empty()”

If that doesn’t mean anything to you, then perhaps you would be better off investing time in brushing up on your C++ knowledge, or programming knowledge in general.

You’re not doing yourself any favors by posting up about every single little issue you come across without actually taking the time to figure it out for yourself.

It would have taken you a few seconds to find the source of the problem with a debugger, so I’m assuming you didn’t use it. Does the file exist? Did you pass the correct path to it? You’re the only person that can find out why the texture is not being loaded correctly.

First of all, please tone down when you are talking to me. It feels very condescending and I just start feeling as if I am dumb, but in reality I am just new to C++, Cocos2d-x and I am still very young.

Anyways, I found a solution to the problem.
I had to use ParticleSystemQuad if I wanted to include a .plist file that containts the PNG texture.
Now everything is working as I wanted it to.


@R101 is being helpful. The thing is, we aren’t in front of your development environment. We don’t have the answers. Your debugger does. Learning to place breakpoints and examining the execution is the only answer.

I’m not singling you out. I’m noticing many developers aren’t using the debugger their advantage to solve problems quicker than posting about them. I wonder if computer science students aren’t being taught how to do this. If you aren’t a CS student and doing game development as a hobby if nobody has told you about the debugger you may not even know you can step over/in/out almost every single line of code you write to see how it is being dealt with.

Don’t take offense. We try and teach first so you can help yourself as your journey continues.

Sorry that you think I was being condescending with my response, but that wasn’t the intention. It was a blunt response, and I can understand why you thought that way.

You posted a screenshot that was showing you the cause of the problem, and then you asked “what should I do?”. A few things came to mind after reading that post; one is that the contents of the popup message were never read or understood, and another is that no attempts was made to resolve it. So, whether it was intended it or not, the post boils down to this: “I have a problem, give me the fix”

Working with a game engine isn’t easy as it is, and not having a solid grasp of programming in whatever language you’re using will make it much harder. Don’t be discouraged when you start having problems with your work, and it’s best to just take a step back to think about it first. The main tools you need to solve any coding problem are your brain, a debugger, and Google (in that order). If the problem is just too perplexing, then that would be a good reason to ask for help.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.