Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Interfaces and base classes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 3DModelerMan   Members   -  Reputation: 926

Like
0Likes
Like

Posted 26 July 2013 - 09:19 AM

I'm trying to register a component system with AngelScript for my engine right now I have a C++ component that wraps an AngelScript object. It basically just calls the matching methods on the AngelScript object whenever the function is called in C++, so when the C++ update() method gets called the AngelScript object instance's update() method is called as well. What I want is for all the components to derive from a base component class that contains a reference to the owner game object. On the C++ side i have an IComponent interface. If I register the IComponent interface as a reference type is there any way to register my C++ IComponent implementations as being derived from the AngelScript component base class? 



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3198

Like
1Likes
Like

Posted 26 July 2013 - 03:56 PM

No, a C++ class cannot derive from a script class, neither can a script class derive from a C++ class.

 

You can however provide a shared AngelScript component base class that implements the desired binding mechanism to tie the script class to the C++ class. This shared class can then be derived by all the custom components.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 3DModelerMan   Members   -  Reputation: 926

Like
0Likes
Like

Posted 27 July 2013 - 07:57 AM

So you can't register class heirarchies at all?



#4 SiCrane   Moderators   -  Reputation: 9338

Like
1Likes
Like

Posted 27 July 2013 - 08:21 AM

Yes and no. There's no explicit method in the registration interface to specify that two classes are specifically related by inheritance. However, you can register implicit and explicit cast behaviors. You can register an implicit cast from derived to base and an explicit cast from base to derived and that usually takes care of all your needs for the relation between base and derived classes. See the manual on class hierarchy.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS