2012-11-26 22 views
0

hy 我正在開發一款Android遊戲,即LUDO遊戲。 我使用了四種不同的陣列來獲得LUDO板在擊中和跟蹤方法上的位置。從LUDO遊戲的png圖像獲取位置

四個不同的陣列如下。

int[] t_LM = { 60, -44, 17, -46, 155, -44, 17, -46, -201, -44, 17, -46, 
     155, -44, 17, -46 }; 
int[] t_TM = { 42, 63, 63, 85, 42, 63, 63, 85, 233, 254, 254, 275, 233, 
     254, 254, 275 }; 
int[] t_o_LM = { 38, -57, -57, -57, -57, -57, 3, -27, -27, -27, -27, -27, 
     3, -27, -27, -27, -27, -27, 3, 3, 3, 3, 3, 3, -27, -57, -207, 3, 3, 
     3, 3, 3, -57, -27, -27, -27, -27, -27, -57, -27, -27, -27, -27, 
     -27, -57, -57, -57, -57, -57, -57, -27, 3 }; 
int[] t_o_TM = { 200, 275, 275, 275, 275, 275, 305, 337, 369, 401, 432, 
     464, 464, 464, 432, 401, 369, 337, 305, 275, 275, 275, 275, 275, 
     275, 242, 209, 209, 209, 209, 209, 209, 177, 146, 115, 83, 51, 20, 
     20, 20, 51, 83, 115, 146, 177, 209, 209, 209, 209, 209, 209, 242 }; 

的LUDO板都一樣遵循 Actual board of the game

但是當我在模擬器的屏幕座標和地圖顯示這樣的..

enter image description here

的圖像

圖片中顯示的粉紅色,黃色和綠色框是我在Hit和trail方法後獲得的座標。

任何軟件或鏈接,有助於解決這個問題,高度讚賞。

在此先感謝

+0

至少對我來說,完全不可能理解你的問題...... – WarrenFaith

+1

你需要照顧每個移動屏幕密度。 –

+0

矩形形狀的公式。本地圖片座標到手機座標 其中pVertices [0] = px; pVertices [1] = py; public void transformLocalToScene(final float [] pVertices){ \t \t int count = pVertices.length/2; \t \t int i = 0; \t \t int j = 0; ( - count> = 0){ \t \t { \t \t \t final float x = pVertices [i ++]; \t \t \t final float y = pVertices [i ++]; \t \t \t pVertices [j ++] = x * this.a + y * this.c + this.tx; \t \t \t pVertices [j ++] = x * this.b + y * this.d + this。TY; \t \t} \t} –

回答

0

我假設你想對white squares其頂部是一個background image的部分移動pink, yellow and green tiles

我不確定在運行時是否可以獲取圖像的特定座標(belonging to white boxes)(Please comment, if it is possible. I would love to learn)

我的替代方案是,當您滾動dice時,讓用戶觸摸特定的white box並在其上繪製colored tile

否則,你可以得出你自己的董事會programmatically或通過xmlwhite box的顏色改變的user tile

+0

我不知道在運行時設置座標,但我靜靜地做着。我想在白色的盒子上設置這些彩色的瓷磚,但我需要得到的盒子的位置,以便ican相應地設置它們。請提出任何想法,我該如何實現它 –

0

你可以用縱橫比來解決此問題的顏色。手動測量原始圖像的尺寸,測量原始圖像的一些初始位置,獲取運行時圖像的尺寸,計算原始圖像和屏幕圖像的縱橫比,並在運行時使用該比例放置圖像。