0
私は弾丸を一点に移動させ、さらに移動させます。その唯一の演技は本当に本当に奇妙です。その0,0の場所が左下ではなく左上にあると思うように。ピクセルで位置をエンティティに移動する - libgdx - ベクトル計算
これはコードです:
float speed = 100;
Vector2 direction;
Vector2 thisPos = new Vector2(getX(), getY());
Vector2 mousePos;
public Bullet(){
super();
setSprite(sprite);
setX(0); setY(0);
float dx = Gdx.input.getX() - getX();
float dy = Gdx.input.getY() - getY();
mousePos = new Vector2(Gdx.input.getX(), Gdx.input.getY());
direction = new Vector2(dx, dy);
//sprite.setRotation(direction.angle(thisPos));
direction.nor();
}
public void update(){
Vector2 dirAd = new Vector2(direction);
thisPos.x += dirAd.x * speed * Gdx.graphics.getDeltaTime();
thisPos.y += dirAd.y * speed * Gdx.graphics.getDeltaTime();
setPosition(thisPos.x, thisPos.y);
super.update();
}
私は誰かが私はこれで間違っていたものを私に役立つことを願って。
ええ、それはマウスの座標です。スプライトは左下が0,0だと考えます。それはなぜその奇妙な演技でなければならないのだろうか。編集:修正されました。ちょうど720 - (残りの)dyのでした。 – Martacus