xml を介してゲームのレベルをロードしています。
「名前」をテストし、それに応じてスプライトを追加するループがあります。
幅と高さが 80x80 のタイルを含むマップがあります。マップの行と列は 6x10 です。
座標で特定のことをしたいので、タイルの読み込み中にレベルローダーがどの行と列にあるかを追跡する方法を見つけようとしています。
これに2次元配列を使用することを考えましたが、この状況でこれを行う方法がわかりません。
誰でもこれで私を助けてくれますか?
編集:
これが私が試したことです。
行と列の配列の作成
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;
}
col[10] に到達するまで、row[1] にとどまるようにするにはどうすればよいですか?
その後、row[2] に切り替えて、col[10] に再び到達するまでそこにとどまりますか?