/// <summary> /// Constructs an animation from information about the spritesheet. /// </summary> /// <param name="engine">The game engine reference.</param> /// <param name="spriteSheetFilePath">The spritesheet filepath.</param> /// <param name="frameWidth">The width of a frame in the spritesheet.</param> /// <param name="frameHeight">The height of a frame in the spritesheet.</param> /// <param name="rows">The number of rows in the spritesheet.</param> /// <param name="cols">The number of columns in the spritesheet.</param> /// <param name="frameCount">The number of frames to play in the spritesheet.</param> /// <param name="framesPerSecond">The number of frames to display per second.</param> /// <param name="type">The type of animation (repeat, play once, etc.).</param> public Animation(Engine engine, string spriteSheetFilePath, int frameWidth, int frameHeight, int rows, int cols, int frameCount, int framesPerSecond, Global.Animations type) : base(engine) { this.filePath = spriteSheetFilePath; this.frameWidth = frameWidth; this.frameHeight = frameHeight; this.rows = rows; this.columns = cols; this.frameCount = frameCount; this.framesPerSecond = framesPerSecond; this.type = type; timePerFrame = 1.0f / framesPerSecond; spriteOrigin = new Vector2(frameWidth / 2, frameHeight / 2); frames = new List<Rectangle>(); this.Scale = 1.0f; this.Speed = 1.0f; SpriteEffect = SpriteEffects.None; // defaults to not playing Playing = false; engine.AddComponent(this); }
/// <summary> /// Constructs an animation from information about the spritesheet. /// </summary> /// <param name="engine">The game engine reference.</param> /// <param name="spriteSheetFilePath">The spritesheet filepath.</param> /// <param name="frameWidth">The width of a frame in the spritesheet.</param> /// <param name="frameHeight">The height of a frame in the spritesheet.</param> /// <param name="rows">The number of rows in the spritesheet.</param> /// <param name="cols">The number of columns in the spritesheet.</param> /// <param name="frameCount">The number of frames to play in the spritesheet.</param> /// <param name="framesPerSecond">The number of frames to display per second.</param> /// <param name="type">The type of animation (repeat, play once, etc.).</param> public Animation(Engine engine, string spriteSheetFilePath, int frameWidth, int frameHeight, int rows, int cols, int frameCount, int framesPerSecond, Global.Animations type) : base(engine) { this.filePath = spriteSheetFilePath; this.frameWidth = frameWidth; this.frameHeight = frameHeight; this.rows = rows; this.columns = cols; this.frameCount = frameCount; this.framesPerSecond = framesPerSecond; this.type = type; timePerFrame = 1.0f / framesPerSecond; spriteOrigin = new Vector2(frameWidth / 2, frameHeight / 2); frames = new List <Rectangle>(); this.Scale = 1.0f; this.Speed = 1.0f; SpriteEffect = SpriteEffects.None; // defaults to not playing Playing = false; engine.AddComponent(this); }