public Sprite(GameObject parent, Texture2D tex) : base(parent, tex) { Width = Texture.Width; Height = Texture.Height; Size = new Vector2(Width, Height); }
public AnimatedSprite(GameObject parent, Texture2D tex, int frameCount, float frameRate) : base(parent, tex) { FrameCount = frameCount; var width = tex.Width; if (width % frameCount != 0) throw new ArgumentOutOfRangeException("The texture does not contain a whole number of frames!"); Width = width / frameCount; Height = Texture.Height; Size = new Vector2(Width, Height); FrameDelay = 1/frameRate; _HotSpots = new Vector2[FrameCount]; _CurrentFrameBounds = new Rectangle(0, 0, Width, Texture.Height); IsPlaying = true; }
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> /// Create a particle out of an asset. /// </summary> /// <param name="assetName">Asset name.</param> private static GameObject createDefaultParticle(string assetName) { var obj = new GameObject(); obj.AddAnimation(assetName).SetHotSpot(); return obj; }
protected SpriteBase(GameObject parent, Texture2D tex) { Texture = tex; Parent = parent; }
protected SpriteBase(GameObject parent) { Parent = parent; }