I'm creating a basic game where certain sprites disappear when clicked. Id like to add some simple visual effect to the action of the object disappearing. I want some particles to trail the mouse click as its pressed on the screen. Similar to the light emitted when slashing a fruit in fruit ninja.
Does anyone know of an efficient way of doing this?
here is what my script looks like right now in case that helps.
I have a rigid body 2d node with a sprite and collision shape 2d as children. When the sprite is clicked on during the game, it disappears from the screen
var w = 80
var mousePos = Vector2()
var jump = randi()%50+250
var dir = randi()%200-50
var tex_ref_array = Global.tex_ref_array
var target_objects = Global.target_objects
# make objects bounce
$Sprite1.texture = tex_ref_array[target_objects[randi()%target_objects.size()]]
apply_impulse(Vector2(0,0) , Vector2(dir, -jump))
# make objects disappear when clicked
mousePos = get_global_mouse_position()
pos = global_position
pos.x -= w/2
pos.y -= w/2
if mousePos.x >= pos.x and mousePos.x <= pos.x + w and mousePos.y >= pos.y \
and mousePos.y <= pos.y + w:
get_parent().targetObjectsPoints += 1
if global_position.y > 500:
queue_free() #clear cache