public Animation(string sheet, float frameTime, int rows, int columns, bool loop = false) { SheetName = sheet; FrameTime = frameTime; Rows = rows; Columns = columns; Color = Color.White; FrameWidth = TextureManager.Load(sheet).Width / columns; FrameHeight = TextureManager.Load(sheet).Height / rows; _frame = 0; Loop = loop; IsPaused = false; Origin = Vector2.Zero; Size = 1.0f; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); TextureManager.Load("Player"); TextureManager.Load("Shield"); Animation a = new Animation("BasicAnimatedButton1x3", 0.6f, 1, 3, true); Texture2D t2 = TextureManager.Load("BasicButtonHover"); button = new AnimatedButton(new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2), a, t2); camera = new Camera(GraphicsDevice.Viewport, new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2)); camera.Focus = player; camera.MaxDistance = 100f; camera.Debug = true; button.OnClick += (() => button.Position += new Vector2(30, 0)); // TODO: use this.Content to load your game content here }
public virtual void Draw(SpriteBatch batch, Vector2 position, float rotation, int layer) { Rectangle segment = new Rectangle(_frame % Columns * FrameWidth, _frame % Rows * FrameHeight, FrameWidth, FrameHeight); batch.Draw(TextureManager.Load(SheetName), position, segment, Color, rotation, Origin, Size, SpriteEffects.None, layer); }