Java Reference
In-Depth Information
Listing 2-3 shows the code that actually gets the Emitter on the screen.
Listing 2-3. Main.fx
package org.lj.jfxe.chapter2.example1;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
Stage {
title: "Chapter 2 - Example 1"
width: 640
height: 480
scene: Scene {
fill: Color.BLACK
content: [
Emitter{
translateX: 320
translateY: 240
}
]
}
}
This very simple snippet of code creates a Stage and adds a single Emitter to a Scene . This is the file
that should be run to view Example 1.
Example 2: Adding Some Controls
Building on the previous example, we'll add a few UI controls to the scene that will allow for real-time
adjustments of several attributes of an Emitter . To enable these controls, the class Emitter must be
refactored to expose the attributes to be adjusted. Figure 2-3 shows the scene, including one Emitter and
a number of Sliders that can be used to control the Emitter .
Search WWH ::




Custom Search