public Player(Game game, AnimatedSprite sprite) { gameRef = (Game1)game; camera = new Camera(gameRef.ScreenRectangle); this.sprite = sprite; camera.LockToSprite(sprite); }
public Player(Game game, AnimatedSprite sprite) { gameRef = (Game1)game; camera = new Camera(gameRef.ScreenRectangle); this.sprite = sprite; camera.LockToSprite(sprite); playerrect = new Rectangle( (int)sprite.Position.X, (int)sprite.Position.Y, sprite.Width, sprite.Height); }
public Character(Entity entity, AnimatedSprite sprite) { this.entity = entity; this.sprite = sprite; }
public void LockToSprite(AnimatedSprite sprite) { position.X = sprite.Position.X + sprite.Width / 2 - (viewportRectangle.Width / 2); position.Y = sprite.Position.Y + sprite.Height / 2 - (viewportRectangle.Height / 2); LockCamera(); }
protected void createPlayer() { Texture2D spriteSheet = Game.Content.Load<Texture2D>(@"PlayerSprites\char4"); Dictionary<AnimationKey, Animation> animations = new Dictionary<AnimationKey, Animation>(); Animation animation = new Animation(3, 50, 50, 0, 0); animations.Add(AnimationKey.Down, animation); animation = new Animation(3, 50, 50, 0, 50); animations.Add(AnimationKey.Up, animation); animation = new Animation(3, 50, 50, 0, 100); animations.Add(AnimationKey.Right, animation); animation = new Animation(3, 50, 50, 0, 150); animations.Add(AnimationKey.Left, animation); Vector2 start = new Vector2(3 * Engine.TileHeight, 3 * Engine.TileWidth); AnimatedSprite sprite = new AnimatedSprite(spriteSheet, animations,start); player = new Player(GameRef, sprite); }