android - Performing Matrix.mapPoints() in both directions -


in word game use matrix define scrolling offset , scaling of image representing game board:

app screenshot

when play letter tiles game board, convert screen coordinates (the finger touch coordinates in ontouchevent) game board coordinates (to know put tile) following method:

public pointf screentoboard(pointf screenpoint) {     float[] point = new float[] {screenpoint.x, screenpoint.y};     matrix inverse = new matrix();     mmatrix.invert(inverse);     inverse.mappoints(point);     float boardx = point[0];     float boardy = point[1];     return new pointf(boardx, boardy); } 

my question is: how opposite conversion?

i.e. when move letter tiles game board blue bar @ bottom of screen (for example when cancelling turn) - how can please convert game board coordinates screen coordinates?

the android doc on mappoints method very scarce.

okay, found solution:

public pointf boardtoscreen(pointf boardpoint) {     float[] point = new float[] {boardpoint.x, boardpoint.y};     mmatrix.mappoints(point);     float screenx = point[0];     float screeny = point[1];     return new pointf(screenx, screeny); } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -