public Player(SpriteAnimation spriteAnimation, Vector2 location, float speed, int collisionRadius) : base(spriteAnimation, location, speed, collisionRadius) { }
/// <summary> /// Copy Constructer /// </summary> /// <param name="anim"></param> public SpriteAnimation(SpriteAnimation anim) { texture = anim.texture; currentAnimation = anim.currentAnimation; location = anim.location; animating = true; foreach (KeyValuePair<string, FrameAnimation> s in anim.animations) animations.Add(s.Key, s.Value.Clone()); }
/// <summary> /// Pass a SpriteAnimation Object , vector2 Location , vector2 Speed , int CollisionRadius /// </summary> /// <param name="spriteAnimation"></param> /// <param name="location"></param> /// <param name="speed"></param> /// <param name="collisionRadius"></param> public DrawAble(SpriteAnimation spriteAnimation, Vector2 location, float speed, int collisionRadius) { this.spriteAnimation = spriteAnimation; this.Location = location; this.speed = speed; this.collisionRadius = collisionRadius; }
/// <summary> /// OverLoad Constructor with spriteAnimation , vector2 speed , vector2 speed , int collisionRadius , int collisionXOffset , int collsionsYOffset /// </summary> /// <param name="spriteAnimation"></param> /// <param name="location"></param> /// <param name="speed"></param> /// <param name="collisionRadius"></param> /// <param name="collisionXoffset"></param> /// <param name="collisionYoffset"></param> public DrawAble(SpriteAnimation spriteAnimation, Vector2 location, float speed, int collisionRadius, int collisionXoffset, int collisionYoffset) { this.spriteAnimation = spriteAnimation; this.location = location; this.speed = speed; this.collisionRadius = collisionRadius; this.CollisonXoffset = collisionXoffset; this.CollisonYoffset = collisionYoffset; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Dictionary<int, string> Textures; Map = TileMap.ReadInMap(Content.RootDirectory + "/Map1.map", out Textures); string[] Strings = new string[Textures.Values.Count]; Textures.Values.CopyTo(Strings, 0); foreach (TileLayer layer in Map.Layers) { layer.AddTextures(Content, Strings); } nakedplayer = Content.Load<Texture2D>("Sprites/8_way_large"); SpriteAnimation animation = new SpriteAnimation(nakedplayer); FrameAnimation Down = new FrameAnimation(10, nakedplayer.Width / 4, nakedplayer.Height / 2, 1, (nakedplayer.Width / 4)*0, 0, new Point(0, 0)); FrameAnimation DownLeft = new FrameAnimation(10, nakedplayer.Width / 4, nakedplayer.Height / 2, 1, (nakedplayer.Width / 4) * 1, 0, new Point(0, 0)); FrameAnimation Left = new FrameAnimation(10, nakedplayer.Width / 4, nakedplayer.Height / 2, 1, (nakedplayer.Width / 4) * 2, 0, new Point(0, 0)); FrameAnimation UpLeft = new FrameAnimation(10, nakedplayer.Width / 4, nakedplayer.Height / 2, 1, (nakedplayer.Width / 4) * 3, 0, new Point(0, 0)); FrameAnimation Up = new FrameAnimation(10, nakedplayer.Width / 4, nakedplayer.Height / 2, 1, (nakedplayer.Width / 4) * 0, (nakedplayer.Height / 2), new Point(0, 0)); FrameAnimation UpRight = new FrameAnimation(10, nakedplayer.Width / 4, nakedplayer.Height / 2, 1, (nakedplayer.Width / 4 )* 1, (nakedplayer.Height / 2), new Point(0, 0)); FrameAnimation Right = new FrameAnimation(10, nakedplayer.Width / 4, nakedplayer.Height / 2, 1, (nakedplayer.Width / 4) * 2, (nakedplayer.Height / 2), new Point(0, 0)); FrameAnimation DownRight = new FrameAnimation(10, nakedplayer.Width / 4, nakedplayer.Height / 2, 1, (nakedplayer.Width / 4) * 3, (nakedplayer.Height / 2), new Point(0, 0)); animation.AddAnimations("Down", Down); animation.AddAnimations("DownRight", DownLeft); animation.AddAnimations("Right", Left); animation.AddAnimations("UpRight", UpLeft); animation.AddAnimations("Up", Up); animation.AddAnimations("UpLeft", UpRight); animation.AddAnimations("Left", Right); animation.AddAnimations("DownLeft", DownRight); player = new Player(animation, new Vector2(200,200), 30f, 0); // TODO: use this.Content to load your game content here }