public override void Draw(CanvasSpriteBatch spriteBatch) { var wall = this as Wall; switch (wall.wallSide) { case WallSide.Top: spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X + GameSprite.WallTopCapSize.Width, bounds.Y, bounds.Width - GameSprite.WallTopCapSize.Width, bounds.Height), spriteSource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X, bounds.Y, GameSprite.WallTopCapSize.Width, GameSprite.WallTopCapSize.Height), wallCapASource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X + (bounds.Width - GameSprite.WallTopCapSize.Width), bounds.Y, GameSprite.WallTopCapSize.Width, GameSprite.WallTopCapSize.Height), wallCapBSource); break; case WallSide.Left: case WallSide.Right: spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X, bounds.Y, bounds.Width, bounds.Height - GameSprite.WallSideCapSize.Height), spriteSource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X, bounds.Y + (bounds.Height - GameSprite.WallSideCapSize.Height), GameSprite.WallSideCapSize.Width, GameSprite.WallSideCapSize.Height), wallCapASource); break; default: break; } }
public override void Draw(CanvasSpriteBatch spriteBatch) { spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X + GameSprite.PaddleCapSize.Width, bounds.Y, bounds.Width - (GameSprite.PaddleCapSize.Width * 2), bounds.Height), spriteSource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X, bounds.Y, GameSprite.PaddleCapSize.Width, GameSprite.PaddleCapSize.Height), paddleCapASource); spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(bounds.X + (bounds.Width - GameSprite.PaddleCapSize.Width), bounds.Y, GameSprite.PaddleCapSize.Width, GameSprite.PaddleCapSize.Height), paddleCapBSource); }
public void DrawSprite(CanvasSpriteBatch spriteBatch, Vector2 pos, Vector2 imagePos) { spriteBatch.DrawFromSpriteSheet( bitmap, new Rect(pos.X, pos.Y, SpriteSize.X, SpriteSize.Y), new Rect(imagePos.X * SpriteSize.X, imagePos.Y * SpriteSize.Y, SpriteSize.X, SpriteSize.Y)); }
public void Draw(CanvasSpriteBatch spriteBatch, int sprite, Vector2 position, Vector4 tint) { if (sprite < 0) return; spriteBatch.DrawFromSpriteSheet(bitmap, position, GetSourceRect(sprite), tint, origin, 0, Vector2.One, CanvasSpriteFlip.None); }
private void DrawClearTiles(CanvasEventArgs args, CanvasSpriteBatch spriteBatch) { var tile = args.Engine.TextureManager.GetTextureFromPath(ClearTextureKey); var cs = args.Engine.CoordinateSystem; var minTileX = cs.ScreenCoordinatesToTileCoordinates(new Vector2(0, 0)).X - 1; var maxTileX = cs.ScreenCoordinatesToTileCoordinates(new Vector2((float)args.Sender.Size.Width, (float)args.Sender.Size.Height)).X + 1; var minTileY = cs.ScreenCoordinatesToTileCoordinates(new Vector2((float)args.Sender.Size.Width, 0)).Y - 1; var maxTileY = cs.ScreenCoordinatesToTileCoordinates(new Vector2(0, (float)args.Sender.Size.Height)).Y + 1; for (var x = minTileX; x <= maxTileX; x++) { for (var y = minTileY; y <= maxTileY; y++) { var thisTileHeight = (float)tile.SourceRect.Height; var thisTileHeightFactor = thisTileHeight / cs.TileHeight; var position = cs.TileCoordinatesToScreenCoordinates(new TileCoordinate(x, y), thisTileHeightFactor); spriteBatch.DrawFromSpriteSheet( tile.Bitmap, new Rect( position.X, position.Y, cs.EffectiveTileWidth, cs.EffectiveTileHeight * thisTileHeightFactor), tile.SourceRect); } } }
public void Draw(CanvasSpriteBatch spriteBatch, int sprite, Vector2 position, Vector4 tint) { if (sprite < 0) { return; } spriteBatch.DrawFromSpriteSheet(bitmap, position, GetSourceRect(sprite), tint, origin, 0, Vector2.One, CanvasSpriteFlip.None); }
public override void Draw(CanvasSpriteBatch spriteBatch) { if (hasExploded) { spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect( location.X - (BLOW_RADIUS / 2), location.Y - (BLOW_RADIUS / 2), size.Width + BLOW_RADIUS, size.Height + BLOW_RADIUS), spriteSource); hasExploded = false; } else { spriteBatch.DrawFromSpriteSheet(gameManager.SpriteSheet, new Rect(location.X, location.Y, size.Width, size.Height), spriteSource); } }
public void DrawSpriteExt(CanvasSpriteBatch spriteBatch, Vector2 pos, Vector2 imagePos, Vector4 rgba, float rotation, Vector2 scale, CanvasSpriteFlip flip) { // Draw Sprite Extended spriteBatch.DrawFromSpriteSheet( bitmap, pos, new Rect(imagePos.X * SpriteSize.X, imagePos.Y * SpriteSize.Y, SpriteSize.X, SpriteSize.Y), rgba, // Tint -> rgba [0 to 1] new Vector2(SpriteSize.X / 2, SpriteSize.Y / 2), // Origin, now centered in the middle rotation, // Rotation in radians scale, // Scale (default: 1, 1) flip); // CanvasSpriteFlip -> 0, 1, 2 or 3 }
private void DrawSpriteBatched(CanvasSpriteBatch g, object o, Vector2 position) { var visualHint = o as IVisualHint; var orientation = visualHint?.VisualOrientation ?? Point.Zero; var m = _coords.GameToCanvasMatrix(position, orientation.IsDirection ? _radiansForDirection[orientation] : 0); g.DrawFromSpriteSheet(_spriteSheet.Image, m, _spriteSheet[visualHint?.VisualKey]); }