Skip to content

Instantly share code, notes, and snippets.

@ksky
Created June 21, 2012 03:51
Show Gist options
  • Save ksky/2963721 to your computer and use it in GitHub Desktop.
Save ksky/2963721 to your computer and use it in GitHub Desktop.
GroovyFX transition sample
@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()
}
@ksky
Copy link
Author

ksky commented Jun 21, 2012

You can get the images used in this sample from: https://dl.dropbox.com/u/132573/birds_images.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment