Split Sprite into Sprite and ImageSprite. Added LabelSprite. Cleaned up
directional constant usage. Added ability to render sprites in two distinct layers. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1132 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: CharacterManager.java,v 1.15 2002/03/08 07:50:32 mdb Exp $
|
||||
// $Id: CharacterManager.java,v 1.16 2002/03/16 03:15:04 shaper Exp $
|
||||
|
||||
package com.threerings.cast;
|
||||
|
||||
@@ -10,7 +10,8 @@ import java.util.HashMap;
|
||||
import com.samskivert.util.Tuple;
|
||||
|
||||
import com.threerings.media.sprite.MultiFrameImage;
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
|
||||
import com.threerings.util.DirectionCodes;
|
||||
|
||||
import com.threerings.cast.Log;
|
||||
import com.threerings.cast.util.TileUtil;
|
||||
@@ -21,6 +22,7 @@ import com.threerings.cast.util.TileUtil;
|
||||
* compositing and caching of composited character animations.
|
||||
*/
|
||||
public class CharacterManager
|
||||
implements DirectionCodes
|
||||
{
|
||||
/**
|
||||
* Constructs the character manager.
|
||||
@@ -176,7 +178,7 @@ public class CharacterManager
|
||||
CharacterDescriptor descrip, String action)
|
||||
throws NoSuchComponentException
|
||||
{
|
||||
MultiFrameImage[] frames = new MultiFrameImage[Sprite.DIRECTION_COUNT];
|
||||
MultiFrameImage[] frames = new MultiFrameImage[DIRECTION_COUNT];
|
||||
|
||||
int[] cids = descrip.getComponentIds();
|
||||
int ccount = cids.length;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
//
|
||||
// $Id: CharacterSprite.java,v 1.24 2002/03/15 01:10:25 mdb Exp $
|
||||
// $Id: CharacterSprite.java,v 1.25 2002/03/16 03:15:04 shaper Exp $
|
||||
|
||||
package com.threerings.cast;
|
||||
|
||||
import com.threerings.media.sprite.MultiFrameImage;
|
||||
import com.threerings.media.sprite.Path;
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.sprite.ImageSprite;
|
||||
|
||||
/**
|
||||
* A character sprite is a sprite that animates itself while walking
|
||||
* about in a scene.
|
||||
*/
|
||||
public class CharacterSprite
|
||||
extends Sprite implements StandardActions
|
||||
public class CharacterSprite extends ImageSprite
|
||||
implements StandardActions
|
||||
{
|
||||
/**
|
||||
* Initializes this character sprite with the specified character
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SpritePanel.java,v 1.11 2002/03/08 07:50:32 mdb Exp $
|
||||
// $Id: SpritePanel.java,v 1.12 2002/03/16 03:15:04 shaper Exp $
|
||||
|
||||
package com.threerings.cast.builder;
|
||||
|
||||
@@ -9,11 +9,14 @@ import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.threerings.media.animation.AnimatedPanel;
|
||||
import com.threerings.media.animation.AnimationManager;
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
|
||||
import com.threerings.util.DirectionCodes;
|
||||
|
||||
import com.threerings.cast.Log;
|
||||
import com.threerings.cast.CharacterDescriptor;
|
||||
import com.threerings.cast.CharacterManager;
|
||||
@@ -24,9 +27,8 @@ import com.threerings.cast.StandardActions;
|
||||
* The sprite panel displays a character sprite centered in the panel
|
||||
* suitable for user perusal.
|
||||
*/
|
||||
public class SpritePanel
|
||||
extends AnimatedPanel
|
||||
implements BuilderModelListener
|
||||
public class SpritePanel extends AnimatedPanel
|
||||
implements DirectionCodes, BuilderModelListener
|
||||
{
|
||||
/**
|
||||
* Constructs the sprite panel.
|
||||
@@ -47,10 +49,8 @@ public class SpritePanel
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void render (Graphics g)
|
||||
protected void render (Graphics2D gfx, List invalidRects)
|
||||
{
|
||||
Graphics2D gfx = (Graphics2D)g;
|
||||
|
||||
// clear the background
|
||||
gfx.setColor(Color.lightGray);
|
||||
Dimension d = getSize();
|
||||
@@ -63,7 +63,7 @@ public class SpritePanel
|
||||
|
||||
if (_sprite != null) {
|
||||
// render the sprite
|
||||
_sprite.paint((Graphics2D)g);
|
||||
_sprite.paint(gfx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class SpritePanel
|
||||
protected void setSprite (CharacterSprite sprite)
|
||||
{
|
||||
sprite.setActionSequence(StandardActions.STANDING);
|
||||
sprite.setOrientation(Sprite.WEST);
|
||||
sprite.setOrientation(WEST);
|
||||
_sprite = sprite;
|
||||
centerSprite();
|
||||
repaint();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: BundledComponentRepository.java,v 1.8 2002/03/08 09:35:14 mdb Exp $
|
||||
// $Id: BundledComponentRepository.java,v 1.9 2002/03/16 03:15:04 shaper Exp $
|
||||
|
||||
package com.threerings.cast.bundle;
|
||||
|
||||
@@ -27,12 +27,13 @@ import com.threerings.resource.ResourceManager;
|
||||
import com.threerings.media.ImageManager;
|
||||
|
||||
import com.threerings.media.sprite.MultiFrameImage;
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
|
||||
import com.threerings.media.tile.ImageProvider;
|
||||
import com.threerings.media.tile.TileSet;
|
||||
import com.threerings.media.tile.NoSuchTileException;
|
||||
|
||||
import com.threerings.util.DirectionCodes;
|
||||
|
||||
import com.threerings.cast.CharacterComponent;
|
||||
import com.threerings.cast.ComponentClass;
|
||||
import com.threerings.cast.ComponentRepository;
|
||||
@@ -47,7 +48,7 @@ import com.threerings.cast.NoSuchComponentException;
|
||||
* @see ResourceManager
|
||||
*/
|
||||
public class BundledComponentRepository
|
||||
implements ComponentRepository
|
||||
implements DirectionCodes, ComponentRepository
|
||||
{
|
||||
/**
|
||||
* Constructs a repository which will obtain its resource set from the
|
||||
@@ -271,8 +272,7 @@ public class BundledComponentRepository
|
||||
fset.setImageProvider(this);
|
||||
|
||||
// and create the necessary multiframe image instances
|
||||
MultiFrameImage[] frames =
|
||||
new MultiFrameImage[Sprite.DIRECTION_COUNT];
|
||||
MultiFrameImage[] frames = new MultiFrameImage[DIRECTION_COUNT];
|
||||
for (int i = 0; i < frames.length; i++) {
|
||||
frames[i] = new TileSetFrameImage(fset, i);
|
||||
}
|
||||
@@ -310,7 +310,7 @@ public class BundledComponentRepository
|
||||
// documentation inherited
|
||||
public int getFrameCount ()
|
||||
{
|
||||
return _set.getTileCount() / Sprite.DIRECTION_COUNT;
|
||||
return _set.getTileCount() / DIRECTION_COUNT;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TileUtil.java,v 1.11 2002/03/10 22:31:21 mdb Exp $
|
||||
// $Id: TileUtil.java,v 1.12 2002/03/16 03:15:05 shaper Exp $
|
||||
|
||||
package com.threerings.cast.util;
|
||||
|
||||
@@ -8,9 +8,10 @@ import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import com.threerings.media.sprite.MultiFrameImage;
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.util.ImageUtil;
|
||||
|
||||
import com.threerings.util.DirectionCodes;
|
||||
|
||||
import com.threerings.cast.Log;
|
||||
import com.threerings.cast.Colorization;
|
||||
|
||||
@@ -18,6 +19,7 @@ import com.threerings.cast.Colorization;
|
||||
* Miscellaneous tile-related utility functions.
|
||||
*/
|
||||
public class TileUtil
|
||||
implements DirectionCodes
|
||||
{
|
||||
/**
|
||||
* Renders each of the given <code>src</code> component frames into
|
||||
@@ -33,7 +35,7 @@ public class TileUtil
|
||||
MultiFrameImage[] dest, MultiFrameImage[] src,
|
||||
Colorization[] zations)
|
||||
{
|
||||
for (int orient = 0; orient < Sprite.DIRECTION_COUNT; orient++) {
|
||||
for (int orient = 0; orient < DIRECTION_COUNT; orient++) {
|
||||
MultiFrameImage sframes = src[orient];
|
||||
MultiFrameImage dframes = dest[orient];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user