2014-11-24 51 views
0

到目前爲止,我只是做一個新的形狀來「移動」它。但是有沒有更好的方法來改變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); 
} 

回答

1

查看RectangulerShapesetFrame()方法。例如:

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

這工作完美謝謝。 :) – 2014-11-24 22:59:36