当前位置: 首页>>代码示例>>Java>>正文


Java AnimationTimer.start方法代码示例

本文整理汇总了Java中javafx.animation.AnimationTimer.start方法的典型用法代码示例。如果您正苦于以下问题:Java AnimationTimer.start方法的具体用法?Java AnimationTimer.start怎么用?Java AnimationTimer.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.animation.AnimationTimer的用法示例。


在下文中一共展示了AnimationTimer.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
	// store the primary stage reference.
	this.primaryStage = primaryStage;

	// construct the context for the game.
	context = new PongContext();

	// set definitions for the primary stage.
	primaryStage.setTitle("JavaFX - Pong");
	primaryStage.setResizable(false);
	primaryStage.show();
	primaryStage.setScene(new WelcomeScene(this));

	// construct and start a trivial main loop for 60fps simulation.
	mainLoop = new AnimationTimer() {

		@Override
		public void handle(long now) {
			Scene scene = primaryStage.getScene();
			if (scene instanceof AbstractScene) {
				((AbstractScene) scene).tick();
			}
		}

	};
	mainLoop.start();

}
 
开发者ID:toivjon,项目名称:javafx-pong,代码行数:30,代码来源:PongApplication.java

示例2: startMainLoop

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
private void startMainLoop() {
    log.debug("Starting main loop");

    mainLoop = new AnimationTimer() {
        @Override
        public void handle(long now) {
            tpf = tpfCompute(now);

            // if we are not in play state run as normal
            if (!(getStateMachine().isInPlay() && getSettings().isSingleStep())) {
                stepLoop();
            }
        }
    };
    mainLoop.start();
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:17,代码来源:GameApplication.java

示例3: startTimer

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
private void startTimer()
{
    timer = new AnimationTimer()
    {

        @Override
        public void handle(long now)
        {
            WritableImage image = dash.snapshot(new SnapshotParameters(), null);
            WritableImage imageCrop = new WritableImage(image.getPixelReader(), (int) getLayoutX(), (int) getLayoutY(), (int) getPrefWidth(), (int) getPrefHeight());
            view.setImage(imageCrop);
        }
    };

    timer.start();
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:17,代码来源:FrostedPanel.java

示例4: createPerformanceTracker

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
public void createPerformanceTracker(Scene scene)
{
    tracker = PerformanceTracker.getSceneTracker(scene);
    AnimationTimer frameRateMeter = new AnimationTimer()
    {

        @Override
        public void handle(long now)
        {

            float fps = getFPS();
            fpsLabel.setText(String.format("Current frame rate: %.0f fps", fps));

        }
    };

    frameRateMeter.start();
}
 
开发者ID:amoAHCP,项目名称:JavaOne2015JavaFXPitfalls,代码行数:19,代码来源:AdvancedScatterChartSample.java

示例5: createContent

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
private Parent createContent() {
    root = new Pane();
    root.setPrefSize(800, 600);

    frog = initFrog();

    root.getChildren().add(frog);

    timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            onUpdate();
        }
    };
    timer.start();

    return root;
}
 
开发者ID:AlmasB,项目名称:FXTutorials,代码行数:19,代码来源:FroggerApp.java

示例6: createContent

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
private Parent createContent() {

        Pane root = new Pane();
        root.setPrefSize(800, 600);

        Canvas canvas = new Canvas(800, 600);
        g = canvas.getGraphicsContext2D();
        g.setFill(Color.BLUE);

        root.getChildren().add(canvas);

        populateDigits();
        populateParticles();

        AnimationTimer timer = new AnimationTimer() {
            @Override
            public void handle(long now) {
                onUpdate();
            }
        };
        timer.start();

        return root;
    }
 
开发者ID:AlmasB,项目名称:FXTutorials,代码行数:25,代码来源:ParticlesClockApp.java

示例7: start

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(createContent());
    scene.setOnMouseClicked(event -> {
        bullet.setTarget(event.getSceneX(), event.getSceneY());
    });

    primaryStage.setTitle("Tutorial");
    primaryStage.setScene(scene);
    primaryStage.show();
    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            bullet.move();
        }
    };
    timer.start();
}
 
开发者ID:AlmasB,项目名称:FXTutorials,代码行数:19,代码来源:Main.java

示例8: createContent

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
private Parent createContent() {
    Pane root = new Pane();

    Canvas canvas = new Canvas(W, H);
    g = canvas.getGraphicsContext2D();
    root.getChildren().add(canvas);

    for (int y = 0; y < grid[0].length; y++) {
        for (int x = 0; x < grid.length; x++) {
            grid[x][y] = new Tile(x, y);
        }
    }

    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            update();
        }
    };
    timer.start();

    algorithm = AlgorithmFactory.breadthFirst();
    algorithmThread.scheduleAtFixedRate(this::algorithmUpdate, 0, 1, TimeUnit.MILLISECONDS);

    return root;
}
 
开发者ID:AlmasB,项目名称:FXTutorials,代码行数:27,代码来源:AlgorithmApp.java

示例9: createContent

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(800, 600);

    Canvas canvas = new Canvas(800, 600);
    g = canvas.getGraphicsContext2D();

    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            t += 0.017;
            draw();
        }
    };
    timer.start();

    root.getChildren().add(canvas);
    return root;
}
 
开发者ID:AlmasB,项目名称:FXTutorials,代码行数:20,代码来源:DrawingApp.java

示例10: start

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(appRoot);
    scene.setOnKeyPressed(event -> keys.put(event.getCode(), true));
    scene.setOnKeyReleased(event -> keys.put(event.getCode(), false));
    primaryStage.setTitle("Tutorial 14 Platformer");
    primaryStage.setScene(scene);
    primaryStage.show();

    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            update();
        }
    };
    timer.start();
}
 
开发者ID:AlmasB,项目名称:FXTutorials,代码行数:18,代码来源:Main.java

示例11: createContent

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
private Parent createContent() {
    root = new Pane();
    root.setPrefSize(600, 600);

    player = new Player();
    player.setVelocity(new Point2D(1, 0));
    addGameObject(player, 300, 300);

    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            onUpdate();
        }
    };
    timer.start();

    return root;
}
 
开发者ID:AlmasB,项目名称:FXTutorials,代码行数:19,代码来源:AsteroidsApp.java

示例12: captureScreen

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
@Override
public void captureScreen(OutputStream os) {
    final AnimationTimer timer = new AnimationTimer() {

        private int pulseCounter;

        @Override
        public void handle(long now) {
            pulseCounter += 1;
            if (pulseCounter > 2) {
                stop();
                WebView view = (WebView) getView();
                WritableImage snapshot = view.snapshot(new SnapshotParameters(), null);
                BufferedImage image = fromFXImage(snapshot, null);
                try (OutputStream stream = os) {
                    ImageIO.write(image, "png", stream);
                } catch (IOException e) {
                    throw new Ui4jException(e);
                }
            }
        }
    };

    timer.start();
}
 
开发者ID:webfolderio,项目名称:ui4j,代码行数:26,代码来源:WebKitPage.java

示例13: FXCanvasComposite

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
public FXCanvasComposite(Composite container, int style) {
  super(container, style);
  this.setLayout(new GridLayout(1, false));
  fxCanvas = new OldFXCanvas(this, SWT.NONE);
  fxCanvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
  VBox root = getRoot();
  AnimationTimer frameRateMeter = createAnimationTimer(label);
  label.textProperty().addListener(e -> {
    Recorder.log(FXCanvasComposite.this.getShell().getSize().x, FXCanvasComposite.this.getShell().getSize().y,
        label.textProperty().getValue());
  });
  frameRateMeter.start();
  Scene scene = new Scene(root);
  fxCanvas.setScene(scene);

  ListViewTextUpdateThread listViewTextUpdateThread = new ListViewTextUpdateThread(textArea);
  listViewTextUpdateThread.start();

  nameCol.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue()));
  TableViewUpdateThread tableViewUpdateThread = new TableViewUpdateThread(tableView);
  tableViewUpdateThread.start();

  fxCanvas.addDisposeListener(e -> {
    tableViewUpdateThread.setStop(true);
    listViewTextUpdateThread.setStop(true);
    Recorder.setStop(true);
  });
}
 
开发者ID:TRUEJASONFANS,项目名称:JavaFX-FrameRateMeter,代码行数:29,代码来源:FXCanvasComposite.java

示例14: start

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
@Override
public void start(final Stage primaryStage) throws Exception {
    m_primaryStage = primaryStage;
    createScene();

    showDrawingSelectionScene();

    m_root.autosize();

    primaryStage.show();

    AnimationTimer at = new AnimationTimer() {
        private int m_runs = 0;
        private long m_lastRun = -1;

        @Override
        public void handle(long arg0) {
            //System.out.println("now=" + arg0 + ":" + m_lastRun);
            if ((arg0 - m_lastRun) < 100000000) return;
            m_lastRun = arg0;
            try {
                m_runs++;
                m_root.autosize();
                m_root.layout();
                //m_mainDrawing.DrawRelationships();
                //System.out.println("RRR");
                if (m_runs > 3) {

                    this.stop();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };

    at.start();
}
 
开发者ID:quiram,项目名称:build-hotspots,代码行数:39,代码来源:BuildHotspotsApplicationBase.java

示例15: Led

import javafx.animation.AnimationTimer; //导入方法依赖的package包/类
public Led(final Color LED_COLOR, final boolean FRAME_VISIBLE, final long INTERVAL, final boolean BLINKING) {
    getStylesheets().add(Led.class.getResource("led.css").toExternalForm());
    getStyleClass().add("led");
    _ledColor     = LED_COLOR;
    _frameVisible = FRAME_VISIBLE;
    _interval     = INTERVAL;
    _blinking     = BLINKING;
    toggle        = false;
    lastTimerCall = System.nanoTime();
    timer = new AnimationTimer() {
        @Override public void handle(final long NOW) {
            if (NOW > lastTimerCall + getInterval()) {
                toggle ^= true;
                setOn(toggle);
                lastTimerCall = NOW;
            }
        }
    };
    init();
    initGraphics();
    registerListeners();
    if (_blinking) {
        timer.start();
    } else {
        timer.stop();
    }
}
 
开发者ID:Simego,项目名称:FXImgurUploader,代码行数:28,代码来源:Led.java


注:本文中的javafx.animation.AnimationTimer.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。