SFML community forums
Help => Graphics => Topic started by: paul.mihaita on November 07, 2014, 07:53:07 pm
-
Hey guys. I am making an Space invaders type of game, and i want to make some power-ups.I want to make an animation for that, like an loading circle so that user can know how much time left he has to take the power-up.I know how to do that by sprites(5-6 sprites with 1/5-1/6 of circle and just display the images after a time) but i want to do it smoothly, and by that i mean to calculate the % of circle to fill based on the time i want.I guess it can be done with texture updating...but i don't know
-
Updating the texture directly is probably not the best idea. I believe the "best" way of implementing this (in terms of performance and flexibility) is to draw the circle using a shader that takes a number like 1/5 as input and then only "lets through" those pixels that are in the first 1/5 of the circle.
-
and how i can do that shader? i'm new into this kind of program, i've heard about but never did it
-
The basics are in the tutorials: http://sfml-dev.org/tutorials/2.1/graphics-shader.php
-
so i have to learn GLSL?
-
If you want to use shaders, then yes.
There should also be ways to achieve such an effect with triangle fans or a special implementation of circle shape.
Also this question has been asked before, search the forum a bit or even google for it, you're not the only one who wanted that. :D
-
The triangle fan will be the easiest and most efficient solution, yes. More details are given in the other topic, if you can find it.