Skip to content
Discussion options

You must be logged in to vote

this extension always returns objects of class Actor, not of the inheriting class. Any ideas?

You can use generics

fun <T : Actor> T.lSetSize(width: Float, height: Float): T {
    this.setSize(width, height)
    return this
}

However, I would personnally not create such extensions, and use apply instead:

var myActor = Group().apply {
  setPosition(5f,4f)
  setSize(5f,4f)
}

Or, alternatively, would it be possible to have more Actor-inheriting classes to be defined at top level like tables?

I may be wrong, but I have the impression that it is already provided by the ktx-scene2d module.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by czyzby
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #177 on December 11, 2020 14:26.