Game Development Community

Extending the game engine

by Myles Blasonato · in iTorque 2D · 03/25/2011 (9:27 pm) · 9 replies

Hi guys,
I can't find anywhere to do this properly.
I opened up the engine using the 2008 compiler.
I extended the t2dSceneObject class and compiled.
I then tried to instatiate it and got the following error:
game/scripts/game.cs (39): Unable to instantiate non-conobject class Entity.

Why?

Cheers,
Myles Blasonato.

About the author

A passionate game designer that has worked on some great games such as Lost Monsters.


#1
03/25/2011 (10:51 pm)
We don't have enough information about your code to help Myles. What extension did you make to t2dScenObject?
#2
03/26/2011 (12:43 am)
Sorry let me be say that again. I created my own class that extends t2dSceneObject.

Cheers,
Myles Blasonato.
PS: my code looks like -
class Entity : t2dSceneObject
{

};
#3
03/26/2011 (7:08 am)
Myles - Is that all your class is? If not, can you paste the entire thing...

There is a resource that explains how to derive a new t2dstaticsprite. I believe Matt Fairfax wrote it... I just can't find it right now.
#4
03/26/2011 (7:16 am)
We really need to get these handy forum posts onto a wiki.

Having never extended the object I'd initially suspect there might be some passing along of information to a parent constructor/setting of some fields to be done?
#5
03/26/2011 (9:00 am)
William Lee Sims' recent shadow/lighting hack is a good starting point, but I agree we need some better information on initialisation of custom objects. I've managed to figure out how to have custom variables and custom rendering, but had to investigate several source files carefully.
#6
03/27/2011 (4:02 am)
Ok so I copied the t2dstaticsprite class into my own entity class. I changed the name from t2dstaticsprite to entity where it needed to be. I compiled and everything then went to create a new instance in torsion but it said the conobject which I searched for in the solution and it came up as being a null console object. It's saying that it can't make my class a console object even though I call the IMPLEMENT_CONOBJECT(Entity)
macro.

Cheers,
Myles Blasonato.
#7
03/28/2011 (7:48 am)
@Myles - There are several reasons why you are getting this error. So I think I still need to see the full class. If you do not want to post it publicly, you can send it to me using michaelp@garagegames.com.
#8
03/29/2011 (11:25 am)
http://tdn.garagegames.com/wiki/Torque_2D/Getting_Started/C_Tutorial
#9
03/29/2011 (4:44 pm)
Thanks a bunch guys :)
Very helpful stuff. I would put mine up but it was just test and it seems like the above tutorial is gonna take me through the exact process so I'll wait till after that before I send my code across.

Cheers,
Myles Blasonato.