0

I want to write a game with Skiko, using Swing for the UI. I assume I need to render a transparent JPanel on top of another JPanel running the Skiko renderer. I'm new to Swing in general so I'm not really sure where to even start.

I have Skiko already working like this:

val skiaLayer = SkiaLayer()
skiaLayer.skikoView = //...

val window = JFrame("Game").apply {
    defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
    preferredSize = Dimension(1920, 1080)
}

skiaLayer.attachTo(window.contentPane)
skiaLayer.needRedraw()

window.pack()
window.isVisible = true

I've tried attaching the skiaLayer to a separate JPanel, but I just get a blank white screen then.

val skiaLayer = SkiaLayer()
skiaLayer.skikoView = //...

val window = JFrame("Game").apply {
    defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
    preferredSize = Dimension(1920, 1080)
}
val game = JPanel()

window.add(game)

skiaLayer.attachTo(game)
skiaLayer.needRedraw()

window.pack()
window.isVisible = true
Abra
  • 19,142
  • 7
  • 29
  • 41
chrispytoes
  • 1,714
  • 1
  • 20
  • 53

0 Answers0