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


Java TranslateTransition类代码示例

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


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

示例1: TranslateTransitionSample

import javafx.animation.TranslateTransition; //导入依赖的package包/类
public TranslateTransitionSample() {
    super(400,40);
    Circle circle = new Circle(20, Color.CRIMSON);
    circle.setTranslateX(20);
    circle.setTranslateY(20);
    getChildren().add(circle);
    translateTransition = new TranslateTransition(Duration.seconds(4),circle);
    translateTransition.setFromX(20);
    translateTransition.setToX(380);
    translateTransition.setCycleCount(Timeline.INDEFINITE);
    translateTransition.setAutoReverse(true);        
    translateTransition = TranslateTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .node(circle)
            .fromX(20)
            .toX(380)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:TranslateTransitionSample.java

示例2: initialize

import javafx.animation.TranslateTransition; //导入依赖的package包/类
@FXML
public void initialize(){

    Main.checkFullScreen();

    Main.getAlertWindow().setOnCloseRequest(e -> spriteImage.setImage(new Image(Gang.getCarSpriteURL())));

    // updating labels
    distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
    conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
    daysLabel.setText("Days: "+ Gang.getDays());
    statusLabel.setText("Status: Resting");

    // setting up how the animation will work
    drivingTransition = new TranslateTransition();
    drivingTransition.setDuration(Duration.seconds(animationDuration));
    drivingTransition.setToX(Main.getMainWindow().getWidth() - 850);
    drivingTransition.setNode(sprite);
    drivingTransition.setCycleCount(Animation.INDEFINITE);

    // fixes the bug with thread not ending when stage was closed
    Main.getMainWindow().setOnCloseRequest(e -> Gang.setMoving(false));
}
 
开发者ID:TheRedSpy15,项目名称:The-Trail,代码行数:24,代码来源:TravelController.java

示例3: updateGUI

import javafx.animation.TranslateTransition; //导入依赖的package包/类
@FXML
private void updateGUI(){

    spriteImage.setImage(new Image(Gang.getCarSpriteURL()));

    // updating drivingTransition
    drivingTransition = new TranslateTransition();
    drivingTransition.setDuration(Duration.seconds(animationDuration));
    drivingTransition.setToX((Main.getMainWindow().getWidth() / -1) - 400);
    drivingTransition.setNode(sprite);
    drivingTransition.setCycleCount(Animation.INDEFINITE);

    // updating labels
    distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
    conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
    daysLabel.setText("Days: "+ Gang.getDays());
    statusLabel.setText("Status: Resting");
}
 
开发者ID:TheRedSpy15,项目名称:The-Trail,代码行数:19,代码来源:TravelController.java

示例4: setPlusScoreAnimation

import javafx.animation.TranslateTransition; //导入依赖的package包/类
/**
 * Animates a label with the plus(new additional value) text.
 * @param plus 
 */
private void setPlusScoreAnimation(String plus) {
	if(plus.length() > 2 ) {
		double width = 25 * plus.length();
		PLUS_SCORE.setMinSize(width, 45);
	}
	PLUS_SCORE.setText("+" + plus);
	this.setScoreStyle();
	PLUS_SCORE.setTextFill(Color.WHITE);
	FadeTransition ft = new FadeTransition(Duration.seconds(.7), PLUS_SCORE);
	ft.setFromValue(1);
	ft.setToValue(0);
	ft.play();
	
	TranslateTransition tt = new TranslateTransition(Duration.seconds(.7), PLUS_SCORE);
	tt.setFromX(55);
	tt.setFromY(-50);
	tt.setToY(50);
	tt.play();
}
 
开发者ID:ShekkarRaee,项目名称:xpanderfx,代码行数:24,代码来源:MainFXMLDocumentController.java

示例5: animation

import javafx.animation.TranslateTransition; //导入依赖的package包/类
public void animation(int cardid){
    TranslateTransition transition = new TranslateTransition();
    transition.setDuration(Duration.millis(150));
    transition.setNode(hash_hhcard.get(cardid));
    transition.setToY(-100);
    transition.setAutoReverse(true);
    transition.setCycleCount(2);

    transition.setOnFinished(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            try {
                playCard(cardid);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    });
    transition.play();

}
 
开发者ID:ESILV-FSociety,项目名称:CardGame,代码行数:23,代码来源:GameOverviewController.java

示例6: drawerAction

import javafx.animation.TranslateTransition; //导入依赖的package包/类
@FXML //Deprecated method.
private void drawerAction() {

    TranslateTransition openNav = new TranslateTransition(
            new Duration(500), drawer);
    openNav.setToX(0);

    TranslateTransition closeNav = new TranslateTransition(
            new Duration(500), drawer);
    menu.setOnAction(
            (ActionEvent evt) -> {

                if (drawer.getTranslateX() != 0) {

                    openNav.play();
                } else {

                    closeNav.setToX(-(drawer.getWidth()));
                    closeNav.play();
                }
            });
}
 
开发者ID:karanpratapsingh,项目名称:KenzieTheBot,代码行数:23,代码来源:MainController.java

示例7: TranslateAnimation

import javafx.animation.TranslateTransition; //导入依赖的package包/类
public TranslateAnimation(Node child, Node dragged) {
    initialX = child.getLayoutX();
    initialIndex = container.getChildren().indexOf(child);
    if (child != dragged) {
        translate = new TranslateTransition(DURATION, child);

        double displacement = dragged.getLayoutBounds().getWidth() + container.getSpacing();
        if (initialIndex < container.getChildren().indexOf(dragged)) {
            translate.setFromX(0);
            translate.setToX(displacement);
        } else {
            translate.setFromX(-displacement);
            translate.setToX(0);
            translate.jumpTo(DURATION);
            forward.set(true);
        }

        forward.addListener((v, o, n) -> {
            translate.setRate(n ? 1 : -1);
            translate.play();
        });
    } else {
        translate = null;
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:26,代码来源:KeyFrameDragAnimator.java

示例8: show

import javafx.animation.TranslateTransition; //导入依赖的package包/类
public Toast show(StackPane ui, long duration){
        Platform.runLater(() -> {
            ui.getChildren().add(label);
            StackPane.setAlignment(label, Pos.BOTTOM_CENTER); // 从下方居中往中间移动
            TranslateTransition tt = new TranslateTransition(Duration.millis(200), label);
            tt.setByY(-(ui.getHeight()/2));
            tt.setCycleCount(1);
            tt.setAutoReverse(false);
            tt.setOnFinished(event -> {
//                LogUtils.d("toast animation finish.");
                Timer timer = new Timer();
                timer.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        if(label.getParent() != null){
                            Platform.runLater(() -> ui.getChildren().remove(label));
                            timer.cancel();
                        }
                    }
                },duration);
            });
            tt.play();
        });
        return this;
    }
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:26,代码来源:Toast.java

示例9: deductScoreDeath

import javafx.animation.TranslateTransition; //导入依赖的package包/类
private void deductScoreDeath() {
    inc("score", -1000);
    set("kills", 0);
    set("multiplier", 1);

    Text bonusText = getUIFactory().newText("-1000", Color.WHITE, 20);
    bonusText.setTranslateX(1100);
    bonusText.setTranslateY(70);

    getGameScene().addUINode(bonusText);

    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.5), bonusText);
    tt.setToY(0);
    tt.setOnFinished(e -> {
        getGameScene().removeUINode(bonusText);
    });
    tt.play();
}
 
开发者ID:AlmasB,项目名称:FXGLGames,代码行数:19,代码来源:GeoWarsApp.java

示例10: getAnimationLoseLife

import javafx.animation.TranslateTransition; //导入依赖的package包/类
private Animation getAnimationLoseLife(Texture texture) {
    texture.setFitWidth(64);
    texture.setFitHeight(64);

    Viewport viewport = gameScene.getViewport();

    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.66), texture);
    tt.setToX(viewport.getWidth() / 2 - texture.getFitWidth() / 2);
    tt.setToY(viewport.getHeight() / 2 - texture.getFitHeight() / 2);

    ScaleTransition st = new ScaleTransition(Duration.seconds(0.66), texture);
    st.setToX(0);
    st.setToY(0);

    return new SequentialTransition(tt, st);
}
 
开发者ID:AlmasB,项目名称:FXGLGames,代码行数:17,代码来源:GameController.java

示例11: TransitionForAll

import javafx.animation.TranslateTransition; //导入依赖的package包/类
private void TransitionForAll(Rectangle rectangle, double layoutXFrom, double layoutXTo, double layoutYFrom, double layoutYTo) {
    mainPane.getChildren().add(rectangle);
    TranslateTransition translateTransition = new TranslateTransition(Duration.millis(800), rectangle);
    translateTransition.setFromX(layoutXFrom);
    translateTransition.setToX(layoutXTo);
    translateTransition.setFromY(layoutYFrom);
    translateTransition.setToY(layoutYTo);
    translateTransition.setCycleCount(1);
    translateTransition.setAutoReverse(true);
    FadeTransition fadeTransition = new FadeTransition(Duration.millis(800), rectangle);
    fadeTransition.setFromValue(1.0f);
    fadeTransition.setToValue(0f);
    fadeTransition.setCycleCount(1);
    fadeTransition.setAutoReverse(true);
    translateTransition.play();
    fadeTransition.play();
    rectangle.setDisable(true);
    Rectangle newRectangle = new Rectangle(10, 10);
    eventExit(rectangle, newRectangle);
}
 
开发者ID:PBZ-InsightR,项目名称:Spellmonger3,代码行数:21,代码来源:ControllerPlay.java

示例12: animate

import javafx.animation.TranslateTransition; //导入依赖的package包/类
private void animate() {
    TranslateTransition tt = new TranslateTransition(Duration.millis(duration), load_image_button);
    TranslateTransition tLogo = new TranslateTransition(Duration.millis(duration), christopher);
    TranslateTransition tDesc = new TranslateTransition(Duration.millis(duration), description);

    ScaleTransition st = new ScaleTransition(Duration.millis(duration), load_image_button);
    st.setToX(3);
    st.setToY(3);

    tt.setByY(-180f);

    tLogo.setToY(50);
    tDesc.setToY(500);
    buttonParallelTransition = new ParallelTransition(load_image_button, st, tt, tLogo, tDesc);

    buttonParallelTransition.play();
    buttonParallelTransition.setOnFinished((e) -> {
        load_image_button.setOpacity(1);
    });
}
 
开发者ID:afsalashyana,项目名称:FakeImageDetection,代码行数:21,代码来源:LaunchScreeenController.java

示例13: animateBullet

import javafx.animation.TranslateTransition; //导入依赖的package包/类
/**
 * Animates the bullet to follow the path taken
 * @param tileSize
 */
private void animateBullet() {
	int tileSize = tileWidthsList.get(level - 1);
	timeline = new Timeline(new KeyFrame(Duration.millis(Settings.PUZZLE_BULLET_SPEED), e -> {
		if(bulletIndex < pathTaken.size()) {
   			TranslateTransition tt = new TranslateTransition(Duration.millis(Settings.PUZZLE_BULLET_SPEED), bulletNode);
   			tt.setToX(tileSize/2 + pathTaken.get(bulletIndex)[1]*tileSize);
   			tt.setToY(tileSize/2 + pathTaken.get(bulletIndex)[0]*tileSize);
   			tt.setCycleCount(1);
   			tt.play();
   			bulletIndex++;
   		}
		handleLevelCompletion();
    }));
    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.play();
}
 
开发者ID:adisrini,项目名称:enders_game,代码行数:21,代码来源:Puzzle.java

示例14: update

import javafx.animation.TranslateTransition; //导入依赖的package包/类
@Override
public void update (Object object) {
    ITurtleState state = (ITurtleState) object;
    
    this.penStyleIndex = state.getPenStyle();
    TranslateTransition tt = new TranslateTransition(Duration.millis(mySpeed), this);

    double currentX = this.getTranslateX(); double currentY = this.getTranslateY();
    tt.setByX(currentX); tt.setByY(currentY); tt.setToX(state.getX()); tt.setToY(state.getY());

    RotateTransition rt = new RotateTransition(Duration.millis(mySpeed), this);

    double currentHeading = this.getRotate();
    rt.setByAngle(currentHeading); rt.setToAngle(state.getHeading());

    ParallelTransition pt = new ParallelTransition();
    pt.getChildren().addAll(tt, rt);

    pt.setOnFinished(e -> {
        updateTurtleState(state);
        System.out.println("myturtle: " + this.toString());
        tooltip.setText(this.toString());
    });

    pt.play();
}
 
开发者ID:adisrini,项目名称:slogo,代码行数:27,代码来源:TurtleView.java

示例15: closeWithReason

import javafx.animation.TranslateTransition; //导入依赖的package包/类
public void closeWithReason(String reason) {
	// Store the reason
	reasonQueue.offer(reason);
	if (!closed.compareAndSet(false, true)) {
		return;
	}
	// Slide out & dispose
	Platform.runLater(() -> {
		if (webView != null) {
			ImageView imageView = new ImageView(webView.snapshot(null, null));
			animatedPane.getChildren().set(0, imageView);
			dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
		}
		TranslateTransition slideOut = new TranslateTransition(Duration.millis(TRANSLATION_MS), animatedPane);
		slideOut.setInterpolator(Interpolator.EASE_IN);
		slideOut.setByX(translationDistance);
		slideOut.setOnFinished(e -> dispose());
		slideOut.play();
	});
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:21,代码来源:BrowserPopup.java


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