On Saturday, 23 May 2020 at 22:15:49 UTC, Ali Çehreli wrote:
Is it not already called? I tried the following and it seems to work:

import std.stdio;

GameObject[1] world;
enum layer = 0;

/// Base class of most objects in the game
class GameObject{
  this(){
    world[layer] = this;
    writeln("called");
  }

  abstract void update(){}

  void draw(){}
}

class A : GameObject {
  this(int i) {
    writeln(__FUNCTION__);
  }

  override void update() {
  }
}

void main() {
  auto a = new A(42);
}

Ali

It is but I want to make sure for other cases in the future where I create a new class that inherits from GameObject. This was I can avoid future bugs by ensure that all classes in the future that inherit from GameObject, call it's constructor

Reply via email to