I recently asked this question on how to draw a hexagon in Android. After finding in the accepted answer that I would have to use umpteen lines of [repetitive] code (compared to the eleven when using regular Java Graphics
and Polygon
objects) I began to search for solutions. I found that libGdx has a Polygon
class. I began trying to implement the code in the linked question (the code my question started out with) with slight modification, including replacing the graphics class.
I stumbled into this without originally checking the API and found that unlike the Java Polygon
class the libGdx Polygon
class only has one constructor. It is a float array to hold vertices. Unfortunately the code did not work after I placed the float vertices[6]
in the constructor. No errors, just not my desired result.
Next I began the laborious task of searching through the API. I found several classes that I suspect can be used to achieve my desired effect (drawing hex map for my first strategy game). The Polygon class also has several methods that I suspect can be implemented.
I, like many other amateur programmers tend to learn best by example, however. I have always been able to reproduce my desired results after studying someone else's implementation. This problem is stumping me, so can someone give an example of how to do this with a detailed explanation. I have also done several Google searches to try and find an example. The hexagon math is simple enough, but drawing the hexagons seems to be a task.
(I would have added my code to the question had I not forgotten to back it up to Dropbox. I am currently, like most days, stuck using an iPad, not my trusty RCA Android tablet which I store my code on)
EDIT:
My actual question is the title. If it is not possible to do this in a straightforward or simple manner please explain why.
if I understand your question, mixing these links may help you create what you want:
1- http://www.alcove-games.com/advanced-tutorials/isometric-tile-picking/
2- http://www.gdreflections.com/2011/02/hexagonal-grid-math.html
3- look other link, code this repo: http://code.google.com/p/libgdx-tiled/source/browse/#svn%2Ftrunk%2Flibgdx-tiled-hex-desktop%2Fsrc%2Fgame%2Fhex
http://code.google.com/p/libgdx-tiled/source/browse/#svn%2Ftrunk%2Flibgdx-tiled-hex-desktop%2Fsrc%2Fapp%253Fstate%253Dclosed
http://code.google.com/p/libgdx-tiled/source/browse/releases/gdx-tests/TiledMapTest.java
http://code.google.com/p/libgdx-tiled/source/browse/trunk/libgdx-tiled-hex-desktop/src/game/Game.java
hope it will help, I do not put coments, because there were too many coments, I Thinks, if this information is not valid for you, notify me and delete