我正在通过xml加载我的游戏级别。使用Array来记录行和列
我有一个循环,测试“名称”,并相应地添加精灵。
我有一张80by80宽度和高度的地图。地图行和列是6x10。
我试图找到一种方法来跟踪哪些行和列的水平加载器正在加载瓷砖,因为我想用坐标做具体的事情。
我曾想过为此使用2d数组,但我不确定在这种情况下如何去做这件事。
谁能帮我这个?
编辑:
这是我都试过了。
创建行和列的阵列
int row[] = new int[6];
int col[] = new int[10];
现在,这里是我在哪里卡住了,林不知道我怎么能告诉代码何时切换,并使用不同的行。例如..
if (name.equals(TAG_ENTITY_ATTRIBUTE_TYPE_unwalkable)) {
tile = new Tile(x, y, this.tUnwalkable_tile,
activity.getVertexBufferObjectManager());
tileList.add(tile);
tile.setTag(1);
/*
* Body groundBody = PhysicsFactory.createBoxBody(this.mPhysicsWorld,
* tile, BodyType.StaticBody, wallFixtureDef);
*/
gameScene.getChildByIndex(SECOND_LAYER).attachChild(tile);
Log.e("Tile", "Unwalkable_Tile");
return;
} else if (name.equals(TAG_ENTITY_ATTRIBUTE_TYPE_Blue_Tile)) {
tile = new Tile(x, y, this.blue,
activity.getVertexBufferObjectManager());
tile.setTag(0);
this.tileList.add(tile);
gameScene.getChildByIndex(SECOND_LAYER).attachChild(tile);
return;
} else if (name.equals(TAG_ENTITY_ATTRIBUTE_TYPE_Red_Tile)) {
tile = new Tile(x, y, this.red, activity.getVertexBufferObjectManager());
tileList.add(tile);
tile.setTag(0);
gameScene.getChildByIndex(SECOND_LAYER).attachChild(tile);
return;
} else if (name.equals(TAG_ENTITY_ATTRIBUTE_TYPE_Pink_Tile)) {
tile = new Tile(x, y, this.pink,
activity.getVertexBufferObjectManager());
tileList.add(tile);
tile.setTag(0);
gameScene.getChildByIndex(SECOND_LAYER).attachChild(tile);
return;
} else if (name.equals(TAG_ENTITY_ATTRIBUTE_TYPE_Yello_Tile)) {
tile = new Tile(x, y, this.yellow,
activity.getVertexBufferObjectManager());
tileList.add(tile);
tile.setTag(0);
gameScene.getChildByIndex(SECOND_LAYER).attachChild(tile);
return;
}
如何告诉它保持行[1],直到col [10]到达?
然后切换到第[2]行并留在那里,直到col [10]再次到达?
是否有任何理由水平加载器本身不能跟踪它加载哪个行和列?它肯定知道它在哪里加载数据。 – Mike
是的,我创建了水平加载器它读取一个XML文件。如果需要,我会发布加载器代码。 –