【发布时间】:2023-03-22 09:01:01
【问题描述】:
我有一个精灵需要跟随一个旋转的箭头精灵的命令,现在我只能让我的精灵向上、向下和向左、向右移动。对角线呢?我不知道该怎么做,精灵也需要始终向屏幕外移动。
编辑: 所以这就是我所做的:
Vector2 position=new Vector2();
public void update(){
//getAngle() is the return value from another class
position.set(MathUtils.cosDeg(cannonObj.getAngle()),MathUtils.sinDeg(cannonObj.getAngle()));
sprite.setPosition(position.x,position.y);
}
发生的情况是,当我旋转箭头时,主精灵就像箭头一样移动(以圆周运动移动)。
//I also tried this
position.scl(2,2);
or
position.translate(2,2);
【问题讨论】:
-
发布您的捕获按键代码。
标签: java libgdx sprite diagonal