libGDX无法执行操作

我有一个像这样的Letter类:

class Letter : Label { val char: Char var interactable = true constructor(char: Char) : super(""+char, H.letterStyle()) { this.char = char } fun animateSelect() { addAction(Actions.scaleTo(3.0f, 3.0f, 0.5f)) } fun animateUnselect() { addAction(Actions.scaleTo(3.0f, 3.0f, 0.5f)) } } 

在我的触摸监听器中,我有这样的:

 override fun touchDown(event: InputEvent?, x: Float, y: Float, pointer: Int, button: Int): Boolean { var currentInteractingLetter: Letter? = null for (letter in letterList) { if (letter.bound.contains(x, y)) { currentInteractingLetter = letter break } } if (currentInteractingLetter == null) { } else { selectedLetters.add(currentInteractingLetter) currentInteractingLetter.animateSelect() currentInteractingLetter.interactable = false } return true } 

逻辑非常简单。 当用户触摸letter s中的任何一个时,我将调用animateSelect()函数。 当我运行它, animateSelect确实被调用,但没有scaleUp效果。 我试图清除addAction之前的所有操作,但仍然是相同的。

标签不直接支持缩放。

解决这个问题的简单方法是将标签放在容器中 ,在容器上放置setTransform(true) ,然后将缩放操作添加到Container

 val container= Container<Label>().apply { isTransform=true actor=label // Set your Label to container } container.addAction(Actions.scaleTo(3.0f, 3.0f, 0.5f))