How to attach particleFX to sprite?

I am just getting started with Defold.I have created a particle system and I want to attach it to foreground/stones on my simple game.

I have tried multiple ways but could not find the solution.Could you please help me ?

Please find the code for your reference (7.3 MB)

Hello and welcome!

As you’re getting started I strongly encourage you to take a look at Getting started with Defold :smiley: Beside this, the problem you are facing is somehow misunderstanding of The building blocks of Defold, but don’t worry, here’s a quick explanation - you do not attach particles to sprites - just to game objects :wink: Particles, similarly to sprites, are components:


In your case you added a sprite and particlefx to the same game object, so you only need to adjust the position in the Editor:

(You can play particle effects in the Editor - select the particlefx and click Space to toggle it :wink: )

When you start the game, you can also see a log in the console:

This means, you are also misinterpreting or not used yet messaging in Defold, so take a look here:

And again, here’s a quick explanation - your script and particlefx are in different objects. You could either move the script to the same object or modify your current script to take an absolute path:"main:/foreground#fire")

Here’s a zip with above corrections: (7.2 MB)


Thanks you so much @Pawel .It was really helpful.

On Defold project is there any way to show joystick for games?Will Defold support it?

Yes, sure, if you mean physical gamepads - everything is described here: Gamepad input in Defold

If you meant a virtual joystick for mobile touch screen, you can check out:

The demo for above module is online here:
Defold-Input 0.1 and what you are looking is probably under ONSCREEN button :wink:

1 Like