gpt4 book ai didi

Java - 如何移动形状

转载 作者:行者123 更新时间:2023-12-01 12:13:59 24 4
gpt4 key购买 nike

到目前为止,我只是制作一个新的形状来“移动”它。但是在 Java 中是否有更好的方法来改变 Shape 的位置呢?

// Collision Shape
protected RectangularShape col;

public GameObject() {
col = new Ellipse2D.Double(x, y, ObjectSpriteManager.SIZE, ObjectSpriteManager.SIZE);
}

public void tick() {
x += velX;
y += velY;
col = new Ellipse2D.Double(x, y, ObjectSpriteManager.SIZE, ObjectSpriteManager.SIZE);
}

最佳答案

请参阅 RectanglerShapesetFrame() 方法。例如:

col.setFrame(x, y, width, height);

关于Java - 如何移动形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27114409/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com