Java Reference
In-Depth Information
Listing 9-12. WaveDot
public class WaveDot extends Circle{
var totalSteps = 6000;
var currentStep = totalSteps;
var deltaX = -0.1;
public function update():Void{
currentStep--;
if (currentStep == 0){
delete this from (parent as Group).content;
} else{
translateX += deltaX;
}
}
}
In Listing 9-12 we see a very simple particle class; it is worth looking at this because it shows that
just few lines of JavaFX code can create some really interesting animations. As we can see in the function
update , we simply check to see whether the WaveDot is ready to be removed; if not, we move it to the left.
Summary
This chapter started with an introduction to the JavaFX media classes and then explored some of the
other audio-related libraries that come with Java. We created a class that could play audio using Java
Sound as well as perform digital signal processing on the sound as it is being played. We then wrapped
this class in a JavaFX API to allow us to create animations in JavaFX driven by the music. By creating a
JavaFX-friendly API, it's simple to get to the real work of creating interesting animations in JavaFX based
on an audio stream.
Search WWH ::




Custom Search