2014-11-24 50 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