// Walk the world and spawn objects based on tile indexes.
final float worldHeight = world.getHeight() * tileHeight;
GameObjectManager manager = sSystemRegistry.gameObjectManager;
if (manager != null) {
for (int y = 0; y < world.getHeight(); y++) {
for (int x = 0; x < world.getWidth(); x++) {
int index = world.getTile(x, y);
if (index != -1) {
GameObjectType type = GameObjectType.indexToType(index);
if (type != GameObjectType.INVALID) {
final float worldX = x * tileWidth;
final float worldY = worldHeight - ((y + 1) * tileHeight);
GameObject object = spawn(type, worldX, worldY, false);
if (object != null) {
if (object.height < tileHeight) {
// make sure small objects are vertically centered in their
// tile.
object.getPosition().y += (tileHeight - object.height) / 2.0f;
}
if (object.width < tileWidth) {
object.getPosition().x += (tileWidth - object.width) / 2.0f;
} else if (object.width > tileWidth) {
object.getPosition().x -= (object.width - tileWidth) / 2.0f;
}
manager.add(object);
if (type == GameObjectType.PLAYER) {
manager.setPlayer(object);
}}}}}
Thank you for any help I can get.
--
You received this message because you are subscribed to the Google Groups "ReplicaIsland Coding Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to replica-island-coding...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.