我有一个火球动画。我可以选择使用位图(因为它使我的swf运行更平滑)或使用大量对象(10-20个不同的图形)。我使用Deco工具制作它看起来很棒!
无论如何,制作一个新的很烦人。此外,当我尝试制作一个新的时,它看起来并不像我的第一个那么好。我打算制作几种不同颜色的火球。如果我能以某种方式过滤整个符号fireball1
的颜色,那将是非常好的,但我正在努力这样做。
我尝试了以下代码,但无论出于何种原因,它只是让我的火球完全消失了。我可能会感到困惑,因为我正在将我的Fireball1
类的所有这些新子项添加到我的数组中。此外,这里是我的时间轴图片的链接,我想它可能有助于理解我的火球是什么样的http://tinypic.com/view.php?pic=fd7oyh&s=5。
private var fireball1:Fireball1;
private var gameTimer:Timer;
private var army1:Array; //included the arrays in case it effects it somehow
private var colorFilter:ColorMatrixFilter = new ColorMatrixFilter(colorMatrix);
private var colorMatrix:Array = new Array(
[[0, 0, 1, 0, 0],
[0, 1, 0, 0, 0],
[1, 0, 0, 0, 0],
[0, 0, 0, 1, 0]]);
public function PlayScreen(){
army1 = new Array();
var newFireball1 = new Fireball1( -100, 0 );
army1.push(newFireball1);
addChild(newFireball1);
gameTimer = new Timer(50);
gameTimer.start();
addEventListener(TimerEvent.TIMER, onTick)
}
public function onTick():void
{
var newFireball1:Fireball1 = new Fireball1( randomX, -15 );
newFireball1.filters = [colorFilter];
army1.push( newFireball1 );
addChild( newFireball1 );
}
答案 0 :(得分:1)
在实例化array
对象之前,需要定义矩阵ColorMatrixFilter
。此外,ColorMatrixFilter
需要一维array
。请参阅使用concat
建议语法的documentation,这似乎可以解决问题。
尝试使用以下代码更新代码:
// Matrix should be a one dimensional array
var colorMatrix:Array = new Array();
colorMatrix = colorMatrix.concat([0, 0, 1, 0, 0]),
colorMatrix = colorMatrix.concat([0, 1, 0, 0, 0]),
colorMatrix = colorMatrix.concat([1, 0, 0, 0, 0]),
colorMatrix = colorMatrix.concat([0, 0, 0, 1, 0]);
// Matrix needs to be defined before it's added to the ColorMatrixFilter
var colorFilter:ColorMatrixFilter = new ColorMatrixFilter(colorMatrix);