Rollcage
Member
|
storing as derived class in Game.ObjMemx
Hi, I don't think it's currently possible but here is what I'd like to do.
Esentially to have a Game.ObjMemx<baseclass> for storing Gameobjects but then be able to store pointers to derived classes inside.
so...
class base
class derived1 : base
class derived2 : base
Then have
World.ObjCreate() be able to store a pointer to derived class in the Memx.
This way we can call virtual functions for the derived classes for a better object oriented approach.
(This post was last modified: 08-27-2012 01:32 PM by Rollcage.)
|
|
08-27-2012 01:31 PM |
|
Rollcage
Member
|
RE: storing as derived class in Game.ObjMemx
Surely this would be helpful to others.. I don't think it's currently possible in th engine
|
|
08-30-2012 02:18 PM |
|
Esenthel
Administrator
|
RE: storing as derived class in Game.ObjMemx
Hello,
Game::ObjMemx cannot store pointers, it must store objects.
One Game::ObjMemx can store only 1 type of class.
Please use
class base
class derived1 : base
class derived2 : base
Game::ObjMemx<Derived1> Derived1s;
Game::ObjMemx<Derived2> Derived2s;
for performing multiple operations on both containers, you can use auto-casting:
example 1:
Game::ObjMemx<Base> &a=Derived1s;
Game::ObjMemx<Base> &b=Derived2s;
example 2:
void func(Game::ObjMemx<Base> &objs)
{
}
func(Derived1s);
func(Derived2s);
|
|
09-01-2012 02:15 PM |
|
Rollcage
Member
|
RE: storing as derived class in Game.ObjMemx
Thanks! It sounds like for what I want I should create a new obj_type for each class of unit but ill have to think about it
|
|
09-01-2012 03:04 PM |
|