예를 들어 http://obviam.net/index.php/a-very-basic-the-game-loop-for-android/에서 작업했습니다.이 부분에서 몇 가지 변경을하고 싶습니다. 이 모든 방향에서의 화상의 움직임을 사용아래에서 위로 이미지를 연속적으로 이동하는 방법은 무엇입니까?
Speed.java
public class Speed {
public static final int DIRECTION_RIGHT = 1;
public static final int DIRECTION_LEFT = -1;
public static final int DIRECTION_UP = -1;
public static final int DIRECTION_DOWN = 1;
private float xv = 1; // velocity value on the X axis
private float yv = 1; // velocity value on the Y axis
private int xDirection = DIRECTION_RIGHT;
private int yDirection = DIRECTION_DOWN;
public Speed() {
this.xv = 1;
this.yv = 1;
}
public Speed(float xv, float yv) {
this.xv = xv;
this.yv = yv;
}
public float getXv() {
return xv;
}
public void setXv(float xv) {
this.xv = xv;
}
public float getYv() {
return yv;
}
public void setYv(float yv) {
this.yv = yv;
}
public int getxDirection() {
return xDirection;
}
public void setxDirection(int xDirection) {
this.xDirection = xDirection;
}
public int getyDirection() {
return yDirection;
}
public void setyDirection(int yDirection) {
this.yDirection = yDirection;
}
// changes the direction on the X axis
public void toggleXDirection() {
xDirection = xDirection * -1;
}
// changes the direction on the Y axis
public void toggleYDirection() {
yDirection = yDirection * -1;
}
}
. 이제 저는이 운동을 아래에서 위쪽으로 제한하고 싶습니다. 그리고 onclick의 기능은 이미지를 클릭하여 원하는 위치로 끌 수 있다는 것입니다. 나는 이미지를 사라지게 만들거나 다른 활동으로 옮기고 싶다. 이 코드를 변경하는 데 도움을주십시오. 미리 감사드립니다.
도 알고 싶습니다 ... 도와주세요 ... – ALi
'private float xv = 1;'을'private float xv = 0;'으로 대체 하시겠습니까? –
@SherifelKhatib는 제대로 작동하지 않았습니다. –