Java Reference
In-Depth Information
function emit():Void{
insert Particle{
speed: particleSpeed;
duration: particleDuration;
radius: particleRadius;
} into content;
The code in Listing 2-4 shows four new attributes of the class Emitter . The attributes
particleRadius , particleSpeed and particleDuration are used when creating a new Particle in the emit
function. The attribute frequency describes how often the Emitter emits a Particle . Note the on replace
function that resets emitTimeline ; this avoids some unpredictable behavior in the Timeline class. These
exposed attributes are then bound to controls defined in the expanded Main.fx in Listing 2-5.
Note The attribute radius in the class Particle is inherited from Circle, so there's no reference to radius in the
class Particle.
Listing 2-5. Main.fx
var particleCountLabel = Label{
translateX: 480
translateY: 26
text: bind "Number of Particles: {sizeof emitter.content}"
textFill: Color.WHITESMOKE
width: 200
var frequencySlider = Slider{
vertical: false;
translateX: 20
translateY: 40
min: 0.01
max: 0.5
value: 0.05
width: 200
var frequencyLabel = Label{
translateX: 22
translateY: 26
text: bind "Emit Fequency: {frequencySlider.value} seconds";
width: 200
textFill: Color.WHITESMOKE
font: Font{
size: 10;
Search WWH ::

Custom Search