I studied the source code and only realized that the partial effect is run from the file
/game/object/snowball.script at line 28 - particlefx.play("#points")
this show 25 or 50 points after break snowball
local function hitball(self)
if self.split then data.score = data.score + 50
else data.score = data.score + 25
end
particlefx.play("#points") -- this line
explode(self)
data.hits = data.hits + 1
if data.hits >= TOKEN_FREQ then
data.hits = 0
factory.create("#token-factory")
end
end
but I don’t understand how this effect is created, etc.
Maybe there is a simpler example somewhere. I want to use it in my project. But I can’t take a ready-made (((
And it looks like there is one particle effect set to spawn the 25 image and one to spawn the 50:
The particle effects are configured to spawn a single particle (ie the 25 or 50 image). And the 25.particlefx and 50.particlefx are attached to either snowball-m.go or snowball.go with both of them using the same snowball.script:
Yes, in that case you need to create a gui node using gui.new_text_node(), set the font and text and then use gui.animate() to move it, and use the callback function to delete the node.
You can also use a game object with a label component, and animate go.animate().
Here’s an untested snippet of code. Use it as inspiration!
-- create a text node
local text = "100"
local start_pos = vmath.vector3(10, 100, 0)
local node = gui.new_text_node(pos, text)
-- set the font to use
gui.set_font(node, "NAME OF FONT")
-- move the text node 50 pixels up in 1.5 seconds
-- fade out the text node at the same time
-- delete the node when done
local duration = 1.5
local delay = 0
gui.animate(node, "color.z", 0, gui.EASING_LINEAR, duration, delay)
gui.animate(node, "position.y", start_pos.y + 50, gui.EASING_INOUTQUAD, duration, delay, function()
gui.delete(node)
end)
Edit: You may also need to set font color and text node size
I put together an example project animating gui text on mouse click position. Although @britzl 's snippet is really clean and simple and you should definitely use that as inspiration. I went with gui.clone and adding nodes to a table before deleting them more complicated but you may find it useful anyway.