【发布时间】:2019-10-13 04:07:49
【问题描述】:
@Override
public void create()
{
batch = new SpriteBatch();
shape = new ShapeRenderer();
velocity = new Vector2(100, 0);
position = new Rectangle(0, 5, 100, 100);
font = new BitmapFont();
font.setColor(Color.BLACK);
font.getData().scale(3f);
camera = new OrthographicCamera();
confCamera();
}
@Override
public void render()
{
if(Gdx.input.isTouched())
position.x = Gdx.input.getX() - position.width/2;
position.y = (Gdx.input.getY() - position.height/2);
shape.begin(ShapeRenderer.ShapeType.Filled);
shape.setColor(Color.BLACK);
shape.rect(position.x, position.y, position.width, position.height);
shape.end();
}
这是一个简单的代码,但我并没有理解 Y 轴,我的形状像镜子一样移动。如果我触摸顶部,我的形状就会下降。如果我触摸底部,我的形状就会向上。如何解决?
【问题讨论】: