M
MegaSkeleton
Guest
Basically when I initialize my game board, I create a ds_grid and create an object for each grid in that cell:
Later when I do checks of what boardCell the mouse is over when it releases a click,
I get a var not set error:
Mouse Event Glob Left Released for objGameBoard
Variable objGameBoard.gameCell not set before reading it.
When I hardcode if ((!gameCell[# i, j].occupied) || to an object ID like (100003).occupied it works fine, it's clearly by the error trying to reference a variable in the objGameBoard instead of using the gameCells I initialize. How can I programatically refer to it?
Code:
gameCell = ds_grid_create(10,10);
//other stuff
var xx, yy, i, j;
xx = boardLayout.x;
for (i = 0; i < 10; i += 1)
{
yy = boardLayout.y;
for (j = 0; j < 10; j += 1)
{
// Create the instance, accounting for the disparity in cell width/height and the size of the O/X sprites
gameCell[# i,j] = instance_create(xx + widthOffset, yy + heightOffset, objBoardCell);
yy += boardLayout.cellHeight;
}
xx += boardLayout.cellWidth;
}
Code:
var xx, yy, i, j;
xx = objGameBoard.boardLayout.x;
for (i = 0; i < 10; i += 1)
{
yy = objGameBoard.boardLayout.y;
for (j = 0; j < 10; j += 1)
{
// Check to see if the mouse is within this location
if ((mouse_x >= xx) && (mouse_x < (xx + objGameBoard.boardLayout.cellWidth)) &&
(mouse_y >= yy) && (mouse_y < (yy + objGameBoard.boardLayout.cellHeight)))
{
// Check the cell at this location
if ((!gameCell[# i, j].occupied) ||
I get a var not set error:
Mouse Event Glob Left Released for objGameBoard
Variable objGameBoard.gameCell not set before reading it.
When I hardcode if ((!gameCell[# i, j].occupied) || to an object ID like (100003).occupied it works fine, it's clearly by the error trying to reference a variable in the objGameBoard instead of using the gameCells I initialize. How can I programatically refer to it?