Skip to content
Advertisement

How Do I Convert This Java Code to Kotlin libGDX

actor.addListener(new ChangeListener() {
    public void changed (ChangeEvent event, Actor actor) {
        System.out.println("Changed!");
    }
});

I can’t figure out how to convert the ChangeEvent handler code from Java to Kotlin

Answer

actor.addListener(object : ChangeListener() {
        fun changed(event: ChangeEvent?, actor: Actor?) {
            println("Changed!")
        }
    })
Advertisement