wyvern.lib.event
Interface MapAddRemoveListener

All Known Implementing Classes:
SideScroller, SmallButton

public interface MapAddRemoveListener

Callback interface for objects wanting to know whenever any object is added to, or removed from, a GameMap.

Note: the methods of this interface won't be called while the map is loading. This speeds up map loading, as thousands of objects are added to the map. It also makes implementations of this interface more deterministic, since objects can be added to a map in any order - your listener may be added after an object that it's interesting in hearing about. You can use the "done-loading" map method-hook to check whether a given object is in a given position after it finishes loading.

Version:
1.0, Jul 09, 2003
Author:
Steve Yegge

Method Summary
 void objectAdded(GameMap map, int x, int y, GameObject obj)
          A reference to a GameObject was added to the map at the specified location.
 void objectRemoved(GameMap map, int x, int y, GameObject obj)
          A reference to a GameObject was removed from the map at the specified location.
 

Method Detail

objectAdded

public void objectAdded(GameMap map,
                        int x,
                        int y,
                        GameObject obj)
A reference to a GameObject was added to the map at the specified location. When an object is added to the map via obj.setMap(map, x, y) (which is the usual approach), large objects will get placed in the map at multiple locations. This method is called once for each location where the object is added.

Note that when a large object is moving in the map, any locations that it occupies both before and after the move may or may not get add() and remove() called for them, depending on the map implementation.

Parameters:
map - the map calling this method
x - the map x location where the object was added
y - the map y location where the object was added
obj - the GameObject being added.

objectRemoved

public void objectRemoved(GameMap map,
                          int x,
                          int y,
                          GameObject obj)
A reference to a GameObject was removed from the map at the specified location. This method is called *after* the reference is removed from the map cell.

Note that the object may not be entirely gone from the map when this is called - it may still have other references in other locations. To be notified when an object is completely removed from the map, get on the object's "remove" method-hook.

Parameters:
map - the map calling this method
x - the map x location where the object reference was removed
y - the map y location where the object reference was removed
obj - the GameObject reference being removed from this location