我正在尝试在 ActionScript 3 中制作俄罗斯方块游戏。我正在使用 movieClip 和 colorTransform 数组来创建彩色、随机、独特的片段。随机化影片剪辑中的帧效果很好,但是当我尝试使用剪辑的 colorTransform 属性应用随机颜色时,我得到了:
Tetris.as, Line 342 1067: Implicit coercion of a value of type Number to an unrelated type flash.geom:ColorTransform.
这是一些示例代码:
private function LandTetromino():void
{
var cT:int = currentTetromino;
var landed:Tetris_Shapes;
for (var i:int=0; i<shapeBuilder[cT][currentRotation].length; i++)
{
for (var j:int=0; j<shapeBuilder[cT][currentRotation][i].length; j++)
{
if (shapeBuilder[cT][currentRotation][i][j]==1)
{
landed = new Tetris_Shapes();
landed.transform.colorTransform = Math.floor(Math.random()*allcolorTransforms.length);
landed.gotoAndStop(Math.floor(Math.random()*12));
addChild(landed);
landed.name="r"+(startingRow+i)+"c"+(startingCol+j);
boardArray[startingRow+i][startingCol+j]=1;
}
}
}
removeChild(tetrisShape);
dropTime.removeEventListener(TimerEvent.TIMER, OnTimeTick);
dropTime.stop();
CheckForCompleteLines();
}