Board game for Android: 'px' vs. 'dp' & which tile was pressed
<p>In the process of making a board game for Android I bumped into an issue whether to use 'px' or 'dp' for the graphics. The use of 'px' is bad in general. However, when creating a board game and you can acquire the screen size using 'getSize()' (which returns the size in pixels), is it still wrong/bad to use 'px'?</p>

<p>My first thought is that it'll be easy to draw the board as you can calculate the width by dividing the width of the screen size by the number of tiles you need (applies to the height as well). Any thoughts on the manner? If using 'sp', how would you go about calculating the size of the tiles?</p>

<hr>

<p>Also, how to figure out which tile was pressed? I've seen an approach used several places, but not sure if it's the right way of doing it. Let's say we have a 1x4-grid and the tiles are given one number each like this:</p>

<pre><code>1 | 2 | 3 | 4
</code></pre>

<p>The approach I've seen does the following:</p>

<ol>
<li><p>Keep a list of all tiles in a string or array. The example above could be </p>

<pre><code>[1, 2, 3, 4]
</code></pre></li>
<li><p>Get the coordinates from a touch-event</p></li>
<li><p>Given that the four tiles fills the entire width of the screen: divide the screen size by number of tiles and check which interval the coordinates from the touch-event lies.</p></li>
</ol>

<p>Is this the best/right way to do it?</p>

<p>In advance, thank you for your time!</p>
