|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MHObjectFactory
This interface is to be implemented by the class in your game that is responsible for taking a tile ID and returning a special non-static object.
The code in such a class might look something like this:
if (layer == MHMapCell.FLOOR_LAYER) { switch(tileID) { case FLOOR_SWITCH: return new MyGameFloorSwitch(); break; case HAZARD_SPIKES: return new MyGameSpikeHazard(); break; default: return null; } } else if (layer == MHMapCell.WALL_LAYER) { switch(tileID) { case DOOR_1: case DOOR_2: case DOOR_3: return new MyGameDoor(tileID); break; case COMPUTER_CONSOLE: return new MyGameComputerConsole(); break; case ALIEN_0: return new MyGameAlien0(); break; default: return null; } } else if (layer == MHMapCell.ITEM_LAYER) { switch(tileID) { case WEAPON_1: return new MyGameLaserPistol(); break; case WEAPON_2: return new MyGameLaserRifle(); break; case POWERUP: return new MyGamePowerUp(); break; case KEY: return new MyGameKey(); break; default: return null; } } else { return null; }
Method Summary | |
---|---|
MHActor |
getObject(int layer,
int tileID)
Accepts layer and tile identifiers, instantiates a special object indicated by them, and returns a reference to it. |
Method Detail |
---|
MHActor getObject(int layer, int tileID)
layer
- The layer of the map for which this tile is
intended.tileID
- A tile identifier, usually read from a map
data file.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |