Rishav Sharan
06/03/2020, 4:37 AMclass PlayScene(val myDependency: MyDependency) : Scene() {
suspend override fun Container.sceneInit() {
text("Play Scene: ${myDependency.value}") {
filtering = false
position(10, 10)
}
2. In my sceneInit, i have added multiple game objects and want to be able to refer to one object from within the addupdater code of the other object
class PlayScene(val myDependency: MyDependency) : Scene() {
suspend override fun Container.sceneInit() {
var ball = circle (....
var paddle = SolidRect(....
For example, I want to add a check in the add updater for ball object that gets the position and dimensions of the paddle object every tick, so I can do simple bound checking. However, I am not able to call one objects from within another. WHat would be the way to go about it?Nico
06/03/2020, 4:46 AMcircle
, text
, ... are actually extension functions of Container
(which is a View.
And the Stage
you are working on is a Container
) so you call text
as a member of the Stage. This will create an object (using the uppercase class Text
then chains an .addTo
call to add it to the parent Container
(The stage in most cases) and even applies a callback.
So you can freely choose between the uppercaste + addChild
and lowercase as long as each method is suited for you caseNico
06/03/2020, 4:48 AMball
object inside the paddle
's updater. Can you show more code to reproduce it`?Rishav Sharan
06/03/2020, 6:45 AMDeactivated User
06/03/2020, 8:07 AMRishav Sharan
06/03/2020, 8:11 AMDeactivated User
06/03/2020, 8:12 AMRishav Sharan
06/03/2020, 8:18 AMRezMike
06/03/2020, 8:23 AMDeactivated User
06/03/2020, 8:27 AMRishav Sharan
06/03/2020, 8:30 AMDeactivated User
06/03/2020, 8:31 AMDeactivated User
06/03/2020, 8:32 AMRezMike
06/03/2020, 8:33 AMRishav Sharan
06/03/2020, 7:19 PMlateinit
is a great friend to have ^_^Deactivated User
06/03/2020, 7:20 PMRishav Sharan
06/03/2020, 7:25 PMNico
06/03/2020, 7:38 PM