如何根据度数设置精灵位置?

时间:2015-07-29 10:19:54

标签: java rotation libgdx

我有一个像钟针一样旋转的精灵箭头,我需要我的另一个精灵在箭头指向的地方产卵。

//arrow rotation:
int x=Gdx.input.getX();
int y=Gdx.graphics.getHeight()-Gdx.input.getY();

double radians= Math.atan2(y - launcherSpr.getY(), x - arrowSpr.getX());
float angle=(float)radians*MathUtils.radiansToDegrees-85;
arrowSpr.setRotation(angle);

//The other sprite that is spawned whenever the method is called
public void newBullet(){
        Sprite sprite=Pools.obtain(Sprite.class);
        sprite.set(bulletSpr);
        sprite.setPosition(300, 600);
        bullets.add(sprite);
}

现在,当调用newBullet()方法时,子弹精灵将会产生并且它的Y被翻译为5(每帧向上移动5个像素)。我想要的是子弹会根据箭头指向的位置产生,并根据情况向上或向下移动。

0 个答案:

没有答案
相关问题