How to render a circular/radial progress bar in Libgdx? -


for game develop libgdx, need show user remaining time making move. how can render circular progress bar shows remaining seconds?

in following answer there javascript solution : circular / radial progress bar

thanks.

first create texture (region) full circular progress bar. next deform shape (mesh) made of 1 or more triangles fit actual area should shown.

for this, think of line center of image bounds of image. calculate intersection point (and "wall", i.e. left, right, top or bottom of image) of line @ given angle. give portion of texture (region) needs drawn.

for example, if line @ rest (angle zero) crosses bottom wall of image @ middle, image square , want rotate clockwise, between 45 , 135 degrees hits left wall, between 135 , 225 degrees hits top wall, , on.

now have shape, you'll need express in triangle. or maintain compatibility libgdx's spritebatch, number of triangles. make sure update u , v values according location of vertex.

a simple implementation of can found on here: https://github.com/xoppa/world/blob/master/src/com/xoppa/android/misc/radialsprite.java


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -