Compare commits
No commits in common. "2474879831af2013baa9bbe73cd42ef7f463814f" and "a9fc91ddde6c2678d317119f64f93753af6cd10a" have entirely different histories.
2474879831
...
a9fc91ddde
@ -10,7 +10,6 @@ import scalafx.util.Duration
|
||||
class SpriteAnimation(val view: ImageView, val image: Drawable, val duration: Duration) extends JTransition {
|
||||
setCycleDuration(duration)
|
||||
setInterpolator(Interpolator.Linear)
|
||||
setAutoReverse(false)
|
||||
|
||||
def interpolate(t: Double): Unit = {
|
||||
image.draw(view, t)
|
||||
|
@ -1,52 +0,0 @@
|
||||
package fmon.draw
|
||||
|
||||
import java.io._
|
||||
|
||||
object CharSet {
|
||||
final val FramesPerPose = 3
|
||||
final val Poses = IndexedSeq("South", "West", "East", "North")
|
||||
final val NumAcross = 4
|
||||
final val NumDown = 2
|
||||
|
||||
def apply(file: File, index: Int): Sprite = {
|
||||
val na = NumAcross * FramesPerPose
|
||||
val nd = NumDown * Poses.size
|
||||
val palette = new Palette(new FileInputStream(file), na, nd)
|
||||
val x = index % NumAcross
|
||||
val y = index / NumAcross
|
||||
val xx = x * NumAcross
|
||||
def pose(i: Int): AnimatedImage = {
|
||||
val yy = y * NumDown + i
|
||||
val images = IndexedSeq(palette(xx, yy), palette(xx - 1, yy), palette(xx, yy), palette(xx + 1, yy))
|
||||
new AnimatedImage(images)
|
||||
}
|
||||
val poses = Poses.zipWithIndex.map{case (p, i) => (p, pose(i))}.toMap
|
||||
new Sprite("South", poses)
|
||||
}
|
||||
}
|
||||
|
||||
import scalafx.application.JFXApp
|
||||
import scalafx.scene._
|
||||
import scalafx.scene.control._
|
||||
import scalafx.scene.image._
|
||||
import scalafx.scene.paint.Color._
|
||||
import scalafx.util.Duration
|
||||
|
||||
object CharSetDemo extends JFXApp {
|
||||
val view = new ImageView
|
||||
stage = new JFXApp.PrimaryStage {
|
||||
title.value = "Hello Stage"
|
||||
width = 600
|
||||
height = 450
|
||||
scene = new Scene {
|
||||
fill = LightGreen
|
||||
content = view
|
||||
}
|
||||
}
|
||||
val filename = raw"C:\Users\dalyj\Documents\Design\Images\CharSets\remakertp01.png"
|
||||
val walker = CharSet(new File(filename), 1)
|
||||
val animation = new SpriteAnimation(view, walker, new Duration(600)) {
|
||||
setCycleCount(scalafx.animation.Transition.Indefinite)
|
||||
}
|
||||
animation.play()
|
||||
}
|
@ -86,10 +86,6 @@ object YamlHelper {
|
||||
mapper.readValue[Map[String, T]](source)
|
||||
}
|
||||
|
||||
def write[T](source: OutputStream, item: T) = {
|
||||
mapper.writeValue(source, item)
|
||||
}
|
||||
|
||||
def writeMap[T](source: OutputStream, items: Map[String, T])(implicit m: Manifest[T]) = {
|
||||
mapper.writeValue(source, items)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user