Files
Terrarum/src/net/torvald/terrarum/gameactors/TapestryObject.kt
Song Minjae 3b7e88b0af no memory leak on ImageBuffer rendering
Turns out, <ImageBuffer>.image creates new Image instance which will NEVER be reclaimed (which causes OutOfMemoryError) unless manually destroy()ed.


Former-commit-id: 34840cf63e52e5635ec8acd5fb1bb78923c61063
Former-commit-id: aca4388320fae022a4744f75c1b0f66b544bdafb
2017-02-25 02:39:02 +09:00

33 lines
970 B
Kotlin

package net.torvald.terrarum.gameactors
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gamecontroller.mouseX
import net.torvald.terrarum.gamecontroller.mouseY
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
import org.newdawn.slick.Image
/**
* Created by minjaesong on 2017-01-07.
*/
class TapestryObject(image: Image, val artName: String, val artAuthor: String) : FixtureBase(physics = false) {
// physics = false only speeds up for ~2 frames with 50 tapestries
init {
image.filter = Image.FILTER_NEAREST
makeNewSprite(image.width, image.height, image)
setHitboxDimension(image.width, image.height, 0, 0)
setPosition(Terrarum.appgc.mouseX, Terrarum.appgc.mouseY)
// you CAN'T destroy the image
}
override fun update(gc: GameContainer, delta: Int) {
super.update(gc, delta)
}
override fun drawBody(g: Graphics) {
super.drawBody(g)
}
}