public void AssignAnimations(AnimSprite animSprite, MovementType animType, int spriteType, int animAmount, float time = 0.1f) { AnimationFrame[] animFrame = new AnimationFrame[animAmount]; for (int i = 0; i < animAmount; i++) { animFrame[i] = new AnimationFrame(i, spriteType, time); } animSprite.AddAnimation(animType, new Animation(animFrame)); }
public Player() : base() { isRectVisible = true; TimeTillNextAttack = 1; Health = PLAYER_MAX_HEALTH; spriteSheet = Content.SpritePlayer; AnimSprite = new AnimSprite(spriteSheet); //animSprite.color = Color.Red; Rect = AnimSprite.RectShape; Rect = AnimSprite.RectShape; //Rect.FillColor = Color.Red; //rect = new RectangleShape(new Vector2f(spriteSheet.SubWidth * size, spriteSheet.SubHeight * size)); // Center of rectangle //rect.Origin = new Vector2f(spriteSheet.SubWidth * size * 0.5f, spriteSheet.SubWidth * size * 0.5f); AssignAnimations(AnimSprite, MovementType.Idle, 2, 1); AssignAnimations(AnimSprite, MovementType.Horizontal, 1, 9); AssignAnimations(AnimSprite, MovementType.Up, 0, 9); AssignAnimations(AnimSprite, MovementType.Down, 2, 9); AnimSprite.Play(MovementType.Idle); }