public void Load() { // Set user screen position Position = new Vector2(500, 200); AnimationClass EnemyAni = new AnimationClass(); Color enemyColour = new Color(); enemyColour = Color.Red; float scale = 0.3f; // Create instances in the library for each animation EnemyAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Walking", 2, 8, EnemyAni.Copy(), enemyColour, scale); EnemyAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Fire", 3, 4, EnemyAni.Copy(), enemyColour, scale); EnemyAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Knife", 3, 4, EnemyAni.Copy(), enemyColour, scale); EnemyAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Idle", 1, 8, EnemyAni.Copy(), enemyColour, scale); // Set default user animation Animation = "Idle"; }
public AnimationClass Copy() { AnimationClass ac = new AnimationClass(); ac.Rectangles = Rectangles; ac.Color = Color; ac.Origin = Origin; ac.Rotation = Rotation; ac.Scale = Scale; ac.SpriteEffect = SpriteEffect; ac.IsLooping = IsLooping; ac.Frames = Frames; return ac; }
public void AddAnimation(string name, int row, int frames, AnimationClass animation, Color colour, float scale) { Rectangle[] recs = new Rectangle[frames]; for (int i = 0; i < frames; i++) { recs[i] = new Rectangle(i * width, (row - 1) * height, width, height); } animation.Frames = frames; animation.Rectangles = recs; Animations.Add(name, animation); animation.Color = colour; animation.Scale = scale; }
public void Load() { // Set user screen position Position = new Vector2(80, 200); AnimationClass playerAni = new AnimationClass(); Color playerColour = new Color(); playerColour = Color.Blue; float scale = 0.3f; // Create instances in the library for each animation playerAni.Rotation = 0f; AddAnimation("Climb", 1, 8, playerAni.Copy(), playerColour, scale); playerAni.Rotation = 0f; AddAnimation("Crouch", 3, 4, playerAni.Copy(), playerColour, scale); playerAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Walking", 1, 8, playerAni.Copy(), playerColour, scale); playerAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Fire", 3, 4, playerAni.Copy(), playerColour, scale); playerAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Knife", 3, 4, playerAni.Copy(), playerColour, scale); playerAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Idle", 2, 8, playerAni.Copy(), playerColour, scale); playerAni.Rotation = MathHelper.PiOver4 * 2; AddAnimation("Jump", 2, 8, playerAni.Copy(), playerColour, scale); // Set default user animation Animation = "Idle"; }