From 57d8d7a7039f35f4741e0b7e5383b3610cd29b64 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 12 Nov 2004 02:16:04 +0000 Subject: [PATCH] Sprites should not be initialized with coordinates, so I changed the constructor to reflect that rather than requiring coordinates that are then not really valid. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3214 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/media/sprite/Sprite.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/java/com/threerings/media/sprite/Sprite.java b/src/java/com/threerings/media/sprite/Sprite.java index 75ce9e5a0..9f7a655d6 100644 --- a/src/java/com/threerings/media/sprite/Sprite.java +++ b/src/java/com/threerings/media/sprite/Sprite.java @@ -1,5 +1,5 @@ // -// $Id: Sprite.java,v 1.67 2004/08/27 02:12:41 mdb Exp $ +// $Id: Sprite.java,v 1.68 2004/11/12 02:16:04 mdb Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -50,15 +50,20 @@ public abstract class Sprite extends AbstractMedia */ public Sprite () { - super(new Rectangle()); + this(0, 0); } /** - * Constructs a sprite with the supplied bounds. + * Constructs a sprite with the supplied dimensions. Because + * sprite derived classes generally want to get in on the business + * when a sprite's location is set, it is not safe to do so in the + * constructor because their derived methods will be called before + * their constructor has been called. Thus a sprite should be fully + * constructed and then its location should be set. */ - public Sprite (Rectangle bounds) + public Sprite (int width, int height) { - super(bounds); + super(new Rectangle(0, 0, width, height)); } /** @@ -363,6 +368,14 @@ public abstract class Sprite extends AbstractMedia removeObserver(obs); } + // documentation inherited + public void viewLocationDidChange (int dx, int dy) + { + if (_renderOrder >= HUD_LAYER) { + setLocation(_ox + dx, _oy + dy); + } + } + // documentation inherited public void shutdown () {