2D螢幕上的一些型別

2021-08-09 07:43:39 字數 1388 閱讀 6770

point:描述的是2d平面上的點(x座標,y座標)

if(null == lastpoint)

// 記錄起始點的座標

int x = (int) event.getx();

int y = (int) event.gety();

lastpoint.set(x,y);

rect: 描述 2d 平面上的乙個矩形區域 (left 左, top 上, right 右, bottom 下 )
rect rect = new rect(left, top, right, bottom);

// 獲取矩形區域的中心

int centerx = rect.centerx(); // 得到矩形區域中心的 x 座標

int centery = rect.centery(); // 得到矩形區域中心的 x 座標

// 獲取寬度 高度

int width = rect.width();

int height = rect.height();

// 檢測是否包含該座標

public

boolean

contains(int x, int y)

view的觸控監聽

可以在view中重寫ontouchevent方法監聽觸控

//上乙個點

private point lastpoint;

@override

public boolean ontouchevent(motionevent event)

//記錄起始點的座標

int x = (int) event.getx();

int y = (int) event.gety();

lastpoint.set(x, y);

break;

case motionevent.action_move:

//按下之後離開之前的整個過程

int x1 = (int) event.getx();

int y1 = (int) event.gety();

//獲取跟上乙個點之間的偏移量

int xdis = x1 - lastpoint.x;

int ydis = y1 - lastpoint.y;

//改變矩形的位置

left += xdis;

top += ydis;

invalidate();

lastpoint.set(x1, y1);

break;

case motionevent.action_up:

//手指離開的瞬間

break;

}return

true;

}

在螢幕上顯示2D文字

西昌.何雨鋒 2d文字的兩種寫法 2d文字有兩種寫的方法 第一種是用scene場景直接就在螢幕上寫了,可以支援中文,但是大小和字型是不能定的。第二種是用tvscreen2dtext類在螢幕上寫,大小,字型可定,但是好象不支援中文.第一種在渲染迴圈中加 scene1 drawtext 文字 x,y,顏...

開始做一些2D工具

開始做一些工具,研究了一下xna和winform結合的問題,研究了幾個實現以後winform就熟悉了,然後發現網上的實現都不好。於是我做了乙個改 形部分最少的實現。因為xna預設模板已經有乙個game.run.在windows 平台上毫無疑問是有視窗訊息處理的主迴圈。所以任何建立乙個應用把game往...

關於把世界座標投射到螢幕上轉換為螢幕2D座標

如果使用使用project world to screen 在一些解析度一下就出現座標錯誤.比如我設定的umg解析度為1280 720,但是他的 1280,720 的座標並不在umg的右下角的邊緣上,也就是這個umg的設計框並不是1280 720。這個因為ue4的解析度縮放機制,你可以在umg的設計...