public BlendableSprite(GameObject parent, SpriteBase sprite, Color color) : base(parent) { _Sprite = sprite; Width = _Sprite.Width; Height = _Sprite.Height; Size = _Sprite.Size; _BlendTexture = new Texture2D(GameCore.GraphicsDevice, 1, 1); _BlendTexture.SetData(new[] { color }); _AlphaTestEffect = new AlphaTestEffect(GameCore.GraphicsDevice) { DiffuseColor = Color.White.ToVector3(), AlphaFunction = CompareFunction.Greater, ReferenceAlpha = 0, World = Matrix.Identity, View = Matrix.Identity, Projection = Matrix.CreateTranslation(-0.5f, -0.5f, 0) * Matrix.CreateOrthographicOffCenter(0, GameCore.GraphicsDevice.Viewport.Width, GameCore.GraphicsDevice.Viewport.Height, 0, 0, 1) }; }
/// <summary> /// Set the current animation and play it. /// </summary> /// <param name="sprite">Animation.</param> public void SetAnimation(SpriteBase sprite) { var idx = Animations.IndexOf(sprite); if(idx == -1) throw new ArgumentException("Sprite does not exist in the list of animations!"); _CurrentAnimation = idx; sprite.Reset(); }