Make it possible for other kinds of sprites to know and report their tile

coordinates.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2004 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-11-28 03:42:17 +00:00
parent 26cd1188ae
commit 130d126238
3 changed files with 30 additions and 13 deletions
@@ -1,5 +1,5 @@
// //
// $Id: IsoSceneView.java,v 1.125 2002/11/20 22:16:54 mdb Exp $ // $Id: IsoSceneView.java,v 1.126 2002/11/28 03:42:17 mdb Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
@@ -385,10 +385,10 @@ public class IsoSceneView implements SceneView
// if this is a miso character sprite, we can use its cached // if this is a miso character sprite, we can use its cached
// tile coordinates // tile coordinates
int tx, ty; int tx, ty;
if (sprite instanceof MisoCharacterSprite) { if (sprite instanceof IsoSprite) {
MisoCharacterSprite mcs = (MisoCharacterSprite)sprite; IsoSprite iso = (IsoSprite)sprite;
tx = mcs.getTileX(); tx = iso.getTileX();
ty = mcs.getTileY(); ty = iso.getTileY();
} else { } else {
// otherwise we have to compute them from the screen // otherwise we have to compute them from the screen
@@ -0,0 +1,21 @@
//
// $Id: IsoSprite.java,v 1.1 2002/11/28 03:42:17 mdb Exp $
package com.threerings.miso.scene;
/**
* An interface implementable by sprites that know their tile coordinates
* in the isometric view.
*/
public interface IsoSprite
{
/**
* Returns the sprite's location on the x-axis in tile coordinates.
*/
public int getTileX ();
/**
* Returns the sprite's location on the y-axis in tile coordinates.
*/
public int getTileY ();
}
@@ -1,5 +1,5 @@
// //
// $Id: MisoCharacterSprite.java,v 1.5 2002/07/08 21:41:30 mdb Exp $ // $Id: MisoCharacterSprite.java,v 1.6 2002/11/28 03:42:17 mdb Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
@@ -17,7 +17,7 @@ import com.threerings.miso.tile.BaseTile;
* will itself keep the sprite coordinates properly up to date. * will itself keep the sprite coordinates properly up to date.
*/ */
public class MisoCharacterSprite extends CharacterSprite public class MisoCharacterSprite extends CharacterSprite
implements Traverser implements Traverser, IsoSprite
{ {
// documentation inherited // documentation inherited
public boolean canTraverse (BaseTile tile) public boolean canTraverse (BaseTile tile)
@@ -26,17 +26,13 @@ public class MisoCharacterSprite extends CharacterSprite
return tile.isPassable(); return tile.isPassable();
} }
/** // documentation inherited from interface
* Returns the sprite's location on the x-axis in tile coordinates.
*/
public int getTileX () public int getTileX ()
{ {
return _tilex; return _tilex;
} }
/** // documentation inherited from interface
* Returns the sprite's location on the y-axis in tile coordinates.
*/
public int getTileY () public int getTileY ()
{ {
return _tiley; return _tiley;