Esempio n. 1
0
        public Sprite(SpriteDef def)
        {
            var tex = XNADevicesManager.Instance.ContentManager.Load<Texture2D>(def.TexName);

            _texture = tex;
            _effect = EffectManager.Instance.CurrentEffect;

            for (int i = 0; i < 4; i++)
            {
                _vertexPosition[i].Normal = Vector3.Backward;
            }

            for (int i = 4; i < 8; i++)
            {
                _vertexPosition[i].Normal = Vector3.Forward;
            }

            DrawRectangle = def.DrawRectangle;
            Alpha = def.Alpha;
            ScaleX = def.ScaleX;
            ScaleY = def.ScaleY;
            RotateX = def.RotateX;
            RotateY = def.RotateY;
            RotateZ = def.RotateZ;
            R = def.R;
            G = def.G;
            B = def.B;
            X = def.X;
            Y = def.Y;
            Z = def.Z;
            TransformOrigin = def.TransformOrigin;
            ZWriteEnable = def.ZWriteEnable;
        }
Esempio n. 2
0
 public SpriteDef(SpriteDef sd)
 {
     TexName = sd.TexName;
     X = sd.X;
     Y = sd.Y;
     Z = sd.Z;
     Alpha = sd.Alpha;
     ScaleX = sd.ScaleX;
     ScaleY = sd.ScaleY;
     RotateX = sd.RotateX;
     RotateY = sd.RotateY;
     RotateZ = sd.RotateZ;
     R = sd.R;
     G = sd.G;
     B = sd.B;
     RepeatX = sd.RepeatX;
     RepeatY = sd.RepeatY;
     DrawRectangle = sd.DrawRectangle;
     TransformOrigin = sd.TransformOrigin;
     ZWriteEnable = sd.ZWriteEnable;
 }
        private Sprite CreateDecoration(string texName,
            float x, float y, float z,
            float scaleX = 1.0f, float scaleY = 1.0f)
        {
            var sd = new SpriteDef();
            sd.TexName = texName;
            sd.X = x;
            sd.Y = y;
            sd.Z = z;
            sd.ScaleX = scaleX;
            sd.ScaleY = scaleY;
            sd.ZWriteEnable = true;

            Sprite sprite = sd.ToSprite();
            sprite.DrawRectangle = new Rectangle(0, 0, sprite.Texture.Width, sprite.Texture.Height);
            sd.DrawRectangle = sprite.DrawRectangle;

            Root.Add(sprite);

            return sprite;
        }
Esempio n. 4
0
 //Utilites
 public static void ExportToFile(SpriteDef def, string filename)
 {
     XmlHelper.ExportToFile(def, filename);
 }