Provide the board coordinates when creating piece images so that puzzles

that care can do the right thing.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3119 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-09-15 18:48:09 +00:00
parent 8856ae43a0
commit 8397a78317
@@ -1,5 +1,5 @@
// //
// $Id: DropBoardView.java,v 1.5 2004/08/29 06:50:47 mdb Exp $ // $Id: DropBoardView.java,v 1.6 2004/09/15 18:48:09 mdb Exp $
// //
// Narya library - tools for developing networked games // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -194,9 +194,11 @@ public abstract class DropBoardView extends PuzzleBoardView
Thread.dumpStack(); Thread.dumpStack();
return; return;
} }
Sprite sprite = createPieceSprite(piece); Sprite sprite = createPieceSprite(piece, sx, sy);
addSprite(sprite); if (sprite != null) {
movePiece(sprite, sx, sy, tx, ty, duration); addSprite(sprite);
movePiece(sprite, sx, sy, tx, ty, duration);
}
} }
/** /**
@@ -333,7 +335,8 @@ public abstract class DropBoardView extends PuzzleBoardView
_pieces = new Sprite[width * height]; _pieces = new Sprite[width * height];
for (int yy = 0; yy < height; yy++) { for (int yy = 0; yy < height; yy++) {
for (int xx = 0; xx < width; xx++) { for (int xx = 0; xx < width; xx++) {
Sprite piece = createPieceSprite(_dboard.getPiece(xx, yy)); Sprite piece = createPieceSprite(
_dboard.getPiece(xx, yy), xx, yy);
if (piece != null) { if (piece != null) {
int ppos = yy * width + xx; int ppos = yy * width + xx;
getPiecePosition(xx, yy, spos); getPiecePosition(xx, yy, spos);
@@ -488,12 +491,13 @@ public abstract class DropBoardView extends PuzzleBoardView
* Creates the sprite that is used to display the specified piece. If * Creates the sprite that is used to display the specified piece. If
* the piece represents no piece, this method should return null. * the piece represents no piece, this method should return null.
*/ */
protected Sprite createPieceSprite (int piece) protected Sprite createPieceSprite (int piece, int px, int py)
{ {
if (piece == PIECE_NONE) { if (piece == PIECE_NONE) {
return null; return null;
} }
ImageSprite sprite = new ImageSprite(getPieceImage(piece)); ImageSprite sprite = new ImageSprite(
getPieceImage(piece, px, py, NORTH));
sprite.setRenderOrder(-1); sprite.setRenderOrder(-1);
return sprite; return sprite;
} }