![](/img/trans.png)
[英]how to access the rows and able to move back and forth in spark dataframes using scala
[英]How can I get my sprite to move up and down the screen in FANG? Right now it's just moving back and forth across the screen
現在,它只是在屏幕上來回跳動
def moveTriangleTwo {
triTwo.translateX(triTwoDX)
if (triTwo.getX < 0.0) {
// It hit the left wall - go other direction
triTwo.setX(0.0) // Place it on left wall
triTwoDX = -triTwoDX // Move in opposite direction
} else if (triTwo.getX > -1) {
// It hit the right wall - go other direction
triTwo.setX(-1.0) // Place it on right wall
triTwoDX = -triTwoDX // Move in opposite directinectin
}
}
也許您應該閱讀有關矢量和坐標系的信息 。
簡短的答案是,在計算機屏幕上,坐標Y是垂直軸,從頂部開始為0。 X坐標是水平的,從左側的0開始,向右遞增。
對於水平移動,您需要更改X,對於垂直移動,您需要更改Y,對於任何對角線,您都需要一次更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.