Resolved #3424 - Added blink on event location

This commit is contained in:
Yair Morgenstern 2020-12-27 13:29:34 +02:00
parent 44af4869d4
commit 78535252c2
2 changed files with 17 additions and 8 deletions

View File

@ -100,7 +100,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
touchable = Touchable.childrenOnly; setOrigin(Align.center) }
val circleCrosshairFogLayerGroup = ActionlessGroup().apply { isTransform = false; setSize(groupSize, groupSize) }
private val circleImage = ImageGetter.getCircle() // for blue and red circles on the tile
val circleImage = ImageGetter.getCircle() // for blue and red circles on the tile
private val crosshairImage = ImageGetter.getImage("OtherIcons/Crosshair") // for when a unit is targete
protected val fogImage = ImageGetter.getImage(tileSetStrings.crosshatchHexagon)

View File

@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.math.Interpolation
import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.scenes.scene2d.*
import com.badlogic.gdx.scenes.scene2d.actions.Actions
import com.badlogic.gdx.scenes.scene2d.actions.FloatAction
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
@ -423,11 +424,11 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
}
}
var blinkAction:Action? = null
fun setCenterPosition(vector: Vector2, immediately: Boolean = false, selectUnit: Boolean = true) {
val tileGroup = tileGroups.values.firstOrNull { it.tileInfo.position == vector } ?: return
selectedTile = tileGroup.tileInfo
if(selectUnit)
if (selectUnit)
worldScreen.bottomUnitTable.tileSelected(selectedTile!!)
val originalScrollX = scrollX
@ -440,12 +441,11 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
// Here it's the same, only the Y axis is inverted - when at 0 we're at the top, not bottom - so we invert it back.
val finalScrollY = maxY - (tileGroup.y + tileGroup.width / 2 - height / 2)
if(immediately){
if (immediately) {
scrollX = finalScrollX
scrollY = finalScrollY
updateVisualScroll()
}
else {
} else {
val action = object : FloatAction(0f, 1f, 0.4f) {
override fun update(percent: Float) {
scrollX = finalScrollX * percent + originalScrollX * (1 - percent)
@ -457,7 +457,16 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
addAction(action)
}
worldScreen.shouldUpdate=true
removeAction(blinkAction) // so we don't have multiple blinks at once
blinkAction = Actions.repeat(3, Actions.sequence(
Actions.run { tileGroup.circleImage.isVisible = false },
Actions.delay(.3f),
Actions.run { tileGroup.circleImage.isVisible = true },
Actions.delay(.3f)
))
addAction(blinkAction) // Don't set it on the group because it's an actionlss group
worldScreen.shouldUpdate = true
}
override fun zoom(zoomScale:Float) {