Java Reference
In-Depth Information
thus asking JavaFX to use a nicer (though more costly) algorithm when rotating the image. The Particle
is also rotated a random amount.
In the doStep function, the rotation of the Particle is incremented by four in each step, imparting a
gentle rotation to the Particle . Obviously, this is yet another feature of a particle that could be exploited
to produce specific effects.
Tip Load images just once and keep only one copy.
Listing 2-10. Emitter.fx (Partial)
public var particleScale = 1.0;
public var particleSpeed = 1.0;
public var particleDuration = 100;
public var particleOpacity = 0.5;
public var particleFadeout = true;
public var particleHue = 0.0;
public var particleHueVariation = 0.0;
function emit():Void{
insert Particle{
scaleX: particleScale;
scaleY: particleScale;
startingOpacity: particleOpacity;
speed: particleSpeed;
duration: particleDuration;
fadeout: particleFadeout;
effect: ColorAdjust{
hue: normalizeHue(particleHue +
randomFromNegToPos(particleHueVariation));
}
} into content;
}
public function normalizeHue(value:Number):Number{
var result = value;
while
(
result > 1.0){
result -= 1.0;
}
while
(
result < - 1.0){
result += 1.0;
}
Search WWH ::




Custom Search