Spawning from a template and components
by Wes Winham · in Torque X 2D · 05/13/2007 (7:40 pm) · 1 replies
I'm having trouble attaching some components to a T2dStaticSprite through XML serialization. The objects are being created as templates, and I can spawn off of them fine, but they don't have the components attached to them that I list in the XML. I'm not sure if I'm doing something wrong in the XML, or in the schema definition or both. When I manually add the components and set their properties, they work great.
The XML for one of my templates:
And my schema definition has the following for the movement and unit components:
Does anything there look out of place, or is there perhaps something else I need to do in order for the components to come attached to my objects?
The XML for one of my templates:
<StaticSprite name="InfantryTemplate">
<CreateWithPhysics>false</CreateWithPhysics>
<CreateWithCollision>false</CreateWithCollision>
<Components inPlace="false">
<UnitComponent>
<UnitHealth>5</UnitHealth>
<MinAngleOfFire>0</MinAngleOfFire>
<MaxAngleOfFire>180</MaxAngleOfFire>
<WeaponType>Standard</WeaponType>
</UnitComponent>
<SelectableComponent></SelectableComponent>
<Movementcomponent>
<MovementSpeed>1</MovementSpeed>
<MovementDelay>1</MovementDelay>
</Movementcomponent>
</Components>
<ObjectType>
<object objTypeRef="t2dSpriteType" />
</ObjectType>
<Pool>false</Pool>
<PoolWithComponents>false</PoolWithComponents>
<IsTemplate>true</IsTemplate>
<IsPersistent>false</IsPersistent>
<Layer>0</Layer>
<Size>
<X>5.000</X>
<Y>5.109</Y>
</Size>
<Position>
<X>12.500</X>
<Y>-5.083</Y>
</Position>
<Rotation>0</Rotation>
<CollisionsEnabled>true</CollisionsEnabled>
<Visible>true</Visible>
<VisibilityLevel>1</VisibilityLevel>
<FlipX>false</FlipX>
<FlipY>false</FlipY>
<SortPoint>
<X>0.000000</X>
<Y>0.000000</Y>
</SortPoint>
<Material nameRef="infantryMaterial" />
</StaticSprite>And my schema definition has the following for the movement and unit components:
<Type name="UnitComponent" fullname="Artillery_Wars.Components.UnitComponent"> <IsComponent>true</IsComponent> <Element name="Components"> <IsList>true</IsList> <Type>GarageGames.Torque.Core.TorqueComponent</Type> </Element> <Element name="PlayerNumber"> <Type>System.Integer</Type> </Element> <Element name="UnitHealth"> <Type>System.Integer</Type> </Element> <Element name="UnitMovement"> <Type>System.Integer</Type> </Element> <Element name="UnitSpeed"> <Type>System.Integer</Type> </Element> <Element name="MinAngleOfFire"> <Type>System.Integer</Type> </Element> <Element name="MaxAngleOfFire"> <Type>System.Integer</Type> </Element> <Element name="WeaponType"> <Type>System.String</Type> </Element> </Type> <Type name="MovementComponent" fullname="Artillery_Wars.Components.MovementComponent"> <IsComponent>true</IsComponent> <Element name="Components"> <IsList>true</IsList> <Type>GarageGames.Torque.Core.TorqueComponent</Type> </Element> <Element name="MovementSpeed"> <Type>System.Integer</Type> </Element> <Element name="MovementDelay"> <Type>System.Integer</Type> </Element> </Type>
Does anything there look out of place, or is there perhaps something else I need to do in order for the components to come attached to my objects?
About the author
Torque 3D Owner Will O-Reagan
Modern Intrigues