otakusenpai
09/19/2018, 7:27 PMobject BasicSoldier {
fun init() {
this.meleeWeapon = BasicSword
.....
}
lateinit var meleeWeapon : MeleeWeapon
How do i instantiiate the BasicSword object ? It has a fun init() method which is used to instantiate it.
Pls helpAndreas Sinz
09/19/2018, 7:30 PMBasicSoldier.meleeWeapon = BasicWord()
somewhere in your codeShawn
09/19/2018, 7:31 PMinit { ... }
block is not the same as a fun init()
by the wayBasicSoldier
be a singleton? that’s what top-level named `object`s areotakusenpai
09/19/2018, 7:35 PMShawn
09/19/2018, 7:36 PMrobin
09/19/2018, 7:37 PMobject BasicSoldier {
var meleeWeapon: MeleeWeapon = BasicSword
}
That will initialize the weapon with BasicSword the moment the object ist first used (as that is also when the object is actually created in memory)otakusenpai
09/20/2018, 6:40 AMrobin
09/20/2018, 7:34 AMotakusenpai
09/20/2018, 7:34 AM