Hello, a friend helped me code a function which loops through an empty game object where all my game objects (that move) are stored. It seems that these game objects are stored in the transform of empty game object container.
private function handleButtonClick(columnIncrementer:int, rowIncrementer:int) { for (var child:Transform in container.transform) { var currentColumn:int = Mathf.Floor(child.position.z / cellSize); var currentRow:int = Mathf.Floor(child.position.x / cellSize); var openColumnIndex:int = currentColumn + columnIncrementer; var openRowIndex:int = currentRow + rowIncrementer; while (checkIfBlockOccupied(openColumnIndex, openRowIndex) == true && openColumnIndex > -1 && openRowIndex > -1 && openColumnIndex < columns && openRowIndex < rows) { openColumnIndex += columnIncrementer; openRowIndex += rowIncrementer; } if (openColumnIndex > -1 && openRowIndex > -1 && openColumnIndex < columns && openRowIndex < rows) { setBlockPosition(child, currentColumn + columnIncrementer, currentRow + rowIncrementer); } ......
Now I would like to use iTween’s MoveTo function to animate my cubes in the setBlockPosition function:
private function setBlockPosition(child:Transform, column:int, row:int) : void { iTween.MoveTo(child, Vector3(row * cellSize, 0, column * cellSize), 2.0); }
The error:
. This function requires a reference to a game object but it seems that my cube game objects are seen as a transform component. Is this thinking correct? I have tried using child.GameObject but this does not work either. Thoughts?No appropriate version of iTween.MoveBy for the argument list…