android - Set button size as big as a fingertip in libgdx -


in libgdx game need display row 8 14 round buttons.

i'm looking best way make sure buttons @ least size of fingertip (between 0.8 , 1 mm) not larger, because want them fit screen without scrolling if possible.

i've found several possible solutions, don't know best, or if i'm missing better:

  • use extendviewport, virtual size 480x360 example, , find suitable size buttons. easiest implement, result varies depending on screen density, size , aspect ratio.

  • use stretchviewport, fix width of buttons, , calculate height @ runtime using device aspect ratio in order keep them round. depends on screen density , size, not on aspect ratio.

  • use device density , physical size calculate @ runtime size of buttons. seems better approach buttons @ right size, more complex , low-level, find strange there isn't simpler ways this.

so, think way go?

joanq, use (slightly modified) suggestion 2 cover types of screens: use stretchviewport, fix width of buttons (as percentage of gdx.graphics.getwidth()), , calculate height @ runtime using device aspect ratio in order keep them round.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -