Shorthand to transform component in base entity class

This commit is contained in:
2012-09-24 15:21:49 +02:00
parent 9d46d0ae8a
commit 6ee4611182
4 changed files with 155 additions and 155 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ namespace DepthsBelow
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
graphics.IsFullScreen = true;
graphics.IsFullScreen = false;
this.IsMouseVisible = true;
}
+4
View File
@@ -8,6 +8,7 @@ namespace DepthsBelow
public class Entity
{
List<Component> Components;
public TransformComponent transform;
public Entity()
{
@@ -28,6 +29,9 @@ namespace DepthsBelow
public void AddComponent(Component c)
{
Components.Add(c);
if (c is TransformComponent)
this.transform =(TransformComponent)c;
}
}
}
+1 -5
View File
@@ -15,9 +15,6 @@ namespace DepthsBelow
Core game;
static Texture2D Texture;
// Components
TransformComponent transform;
static public void LoadContent(Core game)
{
Texture = game.Content.Load<Texture2D>("images/soldier");
@@ -32,8 +29,7 @@ namespace DepthsBelow
rc.Texture = Texture;
this.AddComponent(rc);
transform = new TransformComponent(this);
this.AddComponent(transform);
this.AddComponent(new TransformComponent(this));
}
public void Update(GameTime gameTime)
@@ -6,7 +6,7 @@ using Microsoft.Xna.Framework;
namespace DepthsBelow
{
class TransformComponent : Component
public class TransformComponent : Component
{
public Vector2 Position;
public float Rotation;