tags:

views:

40

answers:

1

I just started with JavaFX and as usual when learning a new language I started with a little project.

As far as I understand

at(0ms) {
    //change values
}, 

is only a shortcut for

    KeyFrame {
        time : 0ms
        values : //change values
    }

so why does my code to move pacman does two completly different things depending on which method I use? The first version works as expected (moves in the correct direction and opens/closes his mouth), while the second messes up (the startAngle doesn't change, he stays at his position, but the length variable changes)

               at(0ms) {
                    startAngle => angle + 45;
                    length => 360 - 90;
                }, 
                at(150ms) {
                    startAngle => angle;
                    length => 360;
                }
                at(300ms) {
                    startAngle => angle + 45;
                    length => 360 - 90;
                    row => newRow;
                    column => newColumn;
                }


                KeyFrame {
                        time : 0ms
                        values : {
                            startAngle => angle + 45;
                            length => 360 - 90;
                        }
                },
                KeyFrame {
                        time : 150ms
                        values : {
                            startAngle => angle;
                            length => 360;
                        }
                },
                KeyFrame {
                        time : 300ms
                        values : {
                            startAngle => angle + 45;
                            length => 360 - 90;
                            row => newRow;
                            column => newColumn;
                        }
                },

And if we're at it, how can I create a timeline with variable time values? I tried using a Duration variable, but that doesn't work the way it should. E.g. time: 1000ms does something completly different than time: timePerMove with var timePerMove : Duration = valueOf(1000);

+1  A: 

Ok, found out myself: You cannot write something like

                    values : {
                        startAngle => angle;
                        length => 360;
                    }

it does compile but it doesn't work the way it should.

Voo