Java Reference
In-Depth Information
var anim = Timeline{
repeatCount: Timeline.INDEFINITE
keyFrames: KeyFrame{
time: 1/30*1s
action: function(){
for (node in content){
(node as Flare).update();
}
}
}
}
init{
anim.play();
blendMode = BlendMode.ADD;
}
function addFlare():Void{
var flare = Flare{}
insert flare into content;
}
}
In Listing 9-9 we can see again that the class DiscoStar extends AudioVisualization . The variable
showFlare is bound to the variable hiChannel of the soundPlayer . The variable hiChannel is simply the
sum of the higher-frequency values found in soundPlayer.levels . The idea here is that when the value of
hiChannel changes, we check to see whether it is greater than 3. If it is, we check to make we have not
added one within the last tenth of a second, and if we have not, then we call addFlare . The time check is
just to make sure we don't add too many too fast, because that would cause performance problems as
well as saturate the scene with flares.
The function addFlare simply adds a new Flare to the content of the DiscoStar . A Flare is basically a
very simple particle that is animated by the Timeline anim . Listing 9-10 shows the source code for Flare .
Listing 9-10. Flare.fx
def flareImage = Image{
url: "{__DIR__}media/flare.png"
}
def random = new Random();
public class Flare extends ImageView{
public var totalSteps:Number = 1000;
public var delteRotation:Number;
var currentStep = totalSteps;
init{
image = flareImage;
translateX = flareImage.width/-2.0;
translateY = flareImage.height/-2.0;
effect = ColorAdjust{
hue: -1 + random.nextFloat()*2
Search WWH ::




Custom Search