Inheritance in AngelScript
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Just too make shure, I will be able to register classes and their base classes with angelscript and cast instances of those in a script? Can't wait for it.
This has actually been available since version 2.13.0, which was released in June last year. :)
What I'm implementing now is inheritance for classes declared in the scripts.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
class A { void print_me() { print("A\n"); }}class B : A { void print_me() { print("B\n"); }}void foo(A & in a) { a.print_me();}void main() { A a; B b; foo(a); foo(b); // generates a "No matching signatures to 'foo(B&)'"}
It's been a few weeks since our very long discussion about persistent script objects, and I have been grinding away at other parts of my project that needed attention.
With them done I came back to revisit my scripting implementation, and low and behold, you implemented the one thing I've been needing!
I will check out the latest SVN when I get home and begin messing with this :) :)
Quote: Original post by SiCrane
It's a bit surprising that you can't use a derived object with a base reference. Ex:
That is indeed surprising. :)
I'll look into this. Thanks for letting me know.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
regards.
http://nightlight2d.de/
I've fixed the problem that SiCrane mentioned, and I've implemented the call of the base class' constructor and destructor.
The base class' constructor is called from within a constructor via the keyword super, like this:
class Derived : Base{ Derived(int param) { if( param > 0 ) super(4); else super(); }}
As you can see the call to the base class' constructor can be made in if-statements, allowing you more flexibility in how you initialize the classes.
If the base class' constructor is not manually called, the compiler will automatically insert a call to the base class' default constructor at the beginning of the constructor.
The last major thing that I need to implement before releasing 2.15.2 is the scoping operator, so that base classes methods can be called from overloaded methods in the derived class.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
class Derived : Base{ Derived(int param) { if( param > 0 ) super(4); }}
would the base constructor just not be called if param is 0?
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game