Skip to content

Instantly share code, notes, and snippets.

@ksky
Created December 3, 2011 14:31
Show Gist options
  • Save ksky/1427262 to your computer and use it in GitHub Desktop.
Save ksky/1427262 to your computer and use it in GitHub Desktop.
GroovyFXでルパン風タイトル表示
import groovyx.javafx.*
import javafx.scene.text.Font
import javafx.scene.media.*
def sound1 = new AudioClip("ルパン風タイプ音.aif")
def sound2 = new AudioClip("ルパン風BGM音.aif")
String message = "プログラミングGROOVY"
int len = message.size()
GroovyFX.start({
def sgb = new SceneGraphBuilder()
def stage = sgb.stage {
scene(fill: black, width: 1024, height: 768) {
borderPane {
center {
txt = text(text:' ', fill: white, font: new Font(600)) {
transition = scaleTransition(300.ms, from: 5.0, to: 1.6/len)
}
}
}
}
}
def tlb = new TimelineBuilder()
def timeline = tlb.timeline(
onFinished: {
txt.text = message
transition.play()
sound2.play()
}
) {
message.eachWithIndex { ch, i ->
if (ch != ' ') {
at ((i*300).ms, onFinished: {sound1.play()}) {
change (txt, 'text') { to ch }
}
}
}
at ((len*300).ms) { change (txt, 'text') { to ' ' } }
}
stage.show()
timeline.play()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment