Game Development Community

Can't add components?

by Kyle Keene · in Torque X 2D · 07/02/2009 (9:31 am) · 12 replies

For some odd reason, every time I make a component and build the solution, it doesn't appear in Torque X 2D. I can't exactly figure out what I'm doing wrong. The only thing I've done different this time from the other times is that this is in the Platformer Starter Kit. I don't know if this has anything to do with it, but I am building my game using the PlatformerStarter template, not the PlatformerDemo template. If anyone has any suggestions on how I can get my component to show up in Torque X 2D, please reply.

#1
07/02/2009 (10:35 am)
It does have the correct namespace, right?
#2
07/02/2009 (10:41 am)
I'm assuming you're using VS 2008? I have that and XNA 3.1, but not Torque 3, and I can see the "Platformer Starter Kit" in the project templates.

In other words, it would appear that template is strictly from XNA, and is not a Torque template.

It's unfortunate that the Torque templates are listed on the same list as XNA templates. They really should be seperate.

Though it does appear that when you click on a template, there is a description just above where you enter the name which says if it is Torque.
#3
07/02/2009 (11:23 am)
@David: I'm not even sure. I'm VERY new to TX2D, C#, and XNA. But I think it's the right namespace. Just to be sure though, what should the namespace be?

@Scott: I think I know what you're talking about. The Platformer Starter Kit that comes with XNA right? I've looked around in that and I'm pretty sure I'm not using that right now. But thanks for the suggestion.
#4
07/02/2009 (12:01 pm)
Then you're using the PlatformerDemo template now?
#5
07/02/2009 (12:25 pm)
No I'm using the Platformer Starter. I have two Platformer Starter Kits. One of them is strictly for XNA and the other works with TX2D. I'm using the one that works with TX2D.
#6
07/02/2009 (1:25 pm)
Doh! Thought I was on to something. Let's see... you're adding a component--is it the right component? That is, you selected Add New Item -> T2DComponent. I know that there is another thing called a Component that I believe comes from VS. On the Item templates, that one is listed as Component Class, but is not the one you want.

Then in TXB, be sure you have the right txproj file loaded and, if already loaded, use Project -> Reload Component Schema.

...The component you added, does it have the line
[TorqueXmlSchemaType]
just above the class start, aka "public class ..."?

If still stuck, please post your code for the Component in question.
#7
07/02/2009 (2:11 pm)
Tried and checked all of that; still not working. I don't think it's somthing to do with the component itself. I've tried making other components after I noticed this one wasn't adding and those didn't add either.
#8
07/02/2009 (2:24 pm)
Are the components being listed in myschema.txschema?

When I created a game from the StarterGame2D template and added a T2DComponent, in the txschema file it listed it as
<Type name="T2DComponent1" fullName="StarterGame2D.T2DComponent1">
  <IsComponent>true</IsComponent>
  <Element name="Components">
    <IsList>true</IsList>
    <Type>GarageGames.Torque.Core.TorqueComponent</Type>
  </Element>
  <Element name="Name">
    <Type>System.String</Type>
  </Element>
</Type>
#9
07/02/2009 (2:31 pm)
Interesting... I don't see it. Do I need to manually type it in? Or is there some setting that I don't have set up right?
#10
07/02/2009 (2:44 pm)
Well, when you build the solution, it is supposed to also export that schema automatically...

take a look at the the Build Events tab on the project properties page. It should have a command in the Post-Build event box.

This is what was there for the sample project:
IF NOT "$(Platform)" == "x86" GOTO end
call "$(TargetPath)" -exportschema "$(ProjectDir)myschema.txschema"
echo Torque X Component Schema Generated.
:end
#11
07/02/2009 (2:54 pm)
That's all there. Is there somthing else I'm missing?

EDIT: Ok I got it all figured out. It turns out that it said "PlatformName" instead of "Platform" for some reason. Anyway, that fixed it. Thanks for all the suggestions.
#12
07/02/2009 (3:12 pm)
Glad it worked out.