首页 > 解决方案 > Kotlin - 超级主要构造函数?

问题描述

IntelliJ IDEA 抱怨构造函数。

转换为主构造函数

在这个例子中,人们将如何做到这一点?

class Turtle : ActorBeta {
constructor() : super()

override fun act(dt: Float) {
    super.act(dt)

    if(Gdx.input.isKeyPressed(Input.Keys.LEFT))
        this.moveBy(-1f, 0f)
    if(Gdx.input.isKeyPressed(Input.Keys.RIGHT))
        this.moveBy(1f, 0f)
    if(Gdx.input.isKeyPressed(Input.Keys.UP))
        this.moveBy(0f, 1f)
    if(Gdx.input.isKeyPressed(Input.Keys.DOWN))
        this.moveBy(0f, -1f)
    }
}

标签: kotlin

解决方案


推荐阅读