transition works as intended but ui is not tangible

This commit is contained in:
minjaesong
2020-09-14 15:19:34 +09:00
parent 1aadde9e9f
commit bd7a66728b
2 changed files with 6 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
import com.jme3.math.FastMath
import kotlin.math.absoluteValue
import kotlin.math.roundToInt
/**
@@ -19,11 +20,7 @@ class UIItemHorizontalFadeSlide(
) : UIItemTransitionContainer(parent, initialX, initialY, width, height, 0.15f, currentPosition, uis) {
fun getOffX(index: Int) = ((currentPosition - index) * width / 2f).roundToInt()
fun getOpacity(index: Int) = 1f
/*if (currentPosition >= index)
1f - (currentPosition - index).coerceIn(0f, 1f)
else
(currentPosition - index).coerceIn(0f, 1f) - 1f*/
fun getOpacity(index: Int) = 1f - (currentPosition - index).absoluteValue.coerceIn(0f, 1f)
init {
@@ -39,7 +36,7 @@ class UIItemHorizontalFadeSlide(
override fun onTransition(currentPosition: Float, uis: Array<out UICanvas>) {
uis.forEachIndexed { index, it ->
it.posX = it.initialX - getOffX(index)
it.posX = -getOffX(index)
it.posY = it.initialY
it.opacity = getOpacity(index)
}