jeudi 2 mars 2017

How to Center Grid?

Hey everyone So I have created a grid on stage using the code below. Everything works fine and the grid is created. Only problem is when i change the columns and rows value to a higher value the grids position changed offset to the center of the stage. I want it to be when i change the values and more columns etc are added the Grid stays dead center.

Also it seems that the grid expands to the positive x axis from the top left hand corner of the grid.

What can I do to fix this?

    private var rows:int = 2;
    private var columns:int = 2;

for (var gy:int = 0; gy < rows; gy++)
            for (var gx:int = 0; gx < columns; gx ++)
                var _grid:mcGrid = new mcGrid();
                _grid.x = (stage.stageWidth / 2) + _grid.width * gx;
                _grid.y = (stage.stageHeight / 2) + _grid.height * gy;

Aucun commentaire:

Enregistrer un commentaire