简体   繁体   English

Java-如何移动形状

[英]Java - How to move a shape

So far I am just making a new Shape to "move" it. 到目前为止,我只是在制作一个新的形状来“移动”它。 But is there a better way to change the position of a Shape in Java? 但是,有没有更好的方法来更改Shape在Java中的位置?

// 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);
}

See the setFrame() methods of RectangulerShape . 请参见RectangulerShapesetFrame()方法。 For example: 例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM