Started refactoring code to allow derived classes to expand the bounds of
the sprite to contain more than just the image. I didn't go all the way though because I started looking at the stuff to handle render origin and render offset and couldn't bring myself to add another offset into the mix so it'll have to wait until I can give it some more serious thought and perhaps simplify what we've got. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1264 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ImageSprite.java,v 1.2 2002/03/27 21:51:15 mdb Exp $
|
// $Id: ImageSprite.java,v 1.3 2002/04/17 15:52:49 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.sprite;
|
package com.threerings.media.sprite;
|
||||||
|
|
||||||
@@ -167,23 +167,37 @@ public class ImageSprite extends Sprite
|
|||||||
_frame = _frames.getFrame(_frameIdx);
|
_frame = _frames.getFrame(_frameIdx);
|
||||||
|
|
||||||
// determine our drawing offsets and rendered rectangle size
|
// determine our drawing offsets and rendered rectangle size
|
||||||
if (_frame == null) {
|
accomodateFrame(_frame);
|
||||||
_bounds.width = 0;
|
|
||||||
_bounds.height = 0;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
_bounds.width = _frame.getWidth(null);
|
|
||||||
_bounds.height = _frame.getHeight(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add our new bounds
|
// add our new bounds
|
||||||
dirty.add(_bounds);
|
dirty.add(_bounds);
|
||||||
|
|
||||||
updateRenderOffset();
|
updateRenderOffset();
|
||||||
updateRenderOrigin();
|
updateRenderOrigin();
|
||||||
|
|
||||||
|
// now invalidate the dirtied region
|
||||||
invalidate(dirty);
|
invalidate(dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must adjust the bounds to accomodate the new image. Called when a
|
||||||
|
* new image has been set for this image sprite. If a derived class is
|
||||||
|
* going to expand the bounds beyond the bounds of the image frame, it
|
||||||
|
* will need to override this method and adjust bounds accordingly for
|
||||||
|
* the new frame (which can be null).
|
||||||
|
*/
|
||||||
|
protected void accomodateFrame (Image frame)
|
||||||
|
{
|
||||||
|
if (frame == null) {
|
||||||
|
_bounds.width = 0;
|
||||||
|
_bounds.height = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_bounds.width = frame.getWidth(null);
|
||||||
|
_bounds.height = frame.getHeight(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void paint (Graphics2D gfx)
|
public void paint (Graphics2D gfx)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user