private void InitialiseAnimationManager() { #if __IOS__ var scale = MonoTouch.UIKit.UIScreen.MainScreen.Scale; var characterStartPosition = new Vector2(350 * scale, 530 * scale); var characterVelocityPixelsPerSecond = 200 * (int)scale; #else var characterStartPosition = new Vector2(350, 530); var characterVelocityPixelsPerSecond = 200; #endif var turnSprites = new [] { TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0001, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0002, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0003, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0004, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0005, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0006, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0007, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0008, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0009, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0010, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0011, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0012 }; var walkSprites = new [] { TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0001, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0002, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0003, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0004, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0005, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0006, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0007, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0008, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0009, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0010, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0011, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0012, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0013, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0014, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0015, TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_walk_0016, }; var animationWalkRight = new Animation(new Vector2(characterVelocityPixelsPerSecond, 0), this.timePerFrame, SpriteEffects.None, walkSprites); var animationWalkLeft = new Animation(new Vector2(-characterVelocityPixelsPerSecond, 0), this.timePerFrame, SpriteEffects.FlipHorizontally, walkSprites); var animationTurnRightToLeft = new Animation(Vector2.Zero, this.timePerFrame, SpriteEffects.None, turnSprites); var animationTurnLeftToRight = new Animation(Vector2.Zero, this.timePerFrame, SpriteEffects.FlipHorizontally, turnSprites); var animations = new[] { animationWalkRight, animationWalkRight, animationWalkRight, animationWalkRight, animationWalkRight, animationWalkRight, animationTurnRightToLeft, animationWalkLeft, animationWalkLeft, animationWalkLeft, animationWalkLeft, animationWalkLeft, animationWalkLeft, animationTurnLeftToRight }; this.characterAnimationManager = new AnimationManager (this.spriteSheet, characterStartPosition, animations); }
public AnimationManager(SpriteSheet spriteSheet, Vector2 initialPosition, Animation[] animations) { this.spriteSheet = spriteSheet; this.animations = animations; this.currentPosition = initialPosition; }