Created
June 21, 2012 03:51
-
-
Save ksky/2963721 to your computer and use it in GitHub Desktop.
GroovyFX transition sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.codehaus.groovyfx:groovyfx:0.2') | |
import static groovyx.javafx.GroovyFX.start | |
start { | |
stage(visible: true) { | |
scene(width: 640, height: 480, fill: lightskyblue) { | |
// 緑の鳥:回転(周期2秒)しながらpathに沿って飛ぶ(周期4秒) | |
imageView { | |
image("file:green_bird.png", width: 80, height: 80) | |
greenAnim = parallelTransition { | |
pathTransition(4.s, | |
path: quadCurve(startX: 0, startY: 200, | |
controlX: 320, controlY: 0, | |
endX: 640, endY: 200), | |
interpolator: linear, cycleCount: indefinite) | |
rotateTransition(2.s, from: 0, to: 360, | |
interpolator: linear, cycleCount: indefinite) | |
} | |
} | |
// 豚:拡大・縮小(周期2秒)を繰り返しながらpathに沿って飛ぶ(周期3秒) | |
imageView { | |
image("file:pig.png", width: 120, height: 120) | |
pigAnim = parallelTransition { | |
pathTransition(3.s, | |
path: quadCurve(startX: 0, startY: 300, | |
controlX: 320, controlY: 100, | |
endX: 640, endY: 300), | |
interpolator: linear, cycleCount: indefinite) | |
scaleTransition(1.s, from: 1.0, to: 0.5, | |
autoReverse: true, cycleCount: indefinite) | |
} | |
} | |
// 赤い鳥:pathに沿って飛ぶ(周期2秒) | |
imageView { | |
image("file:red_bird.png", width: 160, height: 160) | |
redAnim = pathTransition(2.s, | |
path: quadCurve(startX: 0, startY: 400, | |
controlX: 320, controlY: 200, | |
endX: 640, endY: 400), | |
interpolator: linear, cycleCount: indefinite) | |
} | |
} | |
} | |
// 各トランジションを再生 | |
redAnim.play() | |
pigAnim.play() | |
greenAnim.play() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can get the images used in this sample from: https://dl.dropbox.com/u/132573/birds_images.zip