Java - How to move a shape

172 views Asked by At

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?

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

There are 1 answers

0
martinez314 On BEST ANSWER

See the setFrame() methods of RectangulerShape. For example:

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