コード例 #1
0
 /// <summary>
 /// Use this to Add more frame Animation's for this sprite.
 /// </summary>
 /// <param name="Key"></param>
 /// <param name="Animation"></param>
 public void AddAnimations(string Key, FrameAnimation Animation)
 {
     if (Animation != null)
     {
         animations.Add(Key, Animation);
     }
 }
コード例 #2
0
        public virtual void Update(GameTime gameTime, Vector2 location)
        {
            if (!isAnimating)
            {
                return;
            }

            this.location = location;
            FrameAnimation anim = CurrentAnimation;

            if (anim == null)
            {
                return;
            }
            anim.Update(gameTime);
        }
コード例 #3
0
        public void Draw(SpriteBatch spriteBatch)
        {
            FrameAnimation anim = CurrentAnimation;

            if (anim == null)
            {
                return;
            }



            //Might not be wise to put Begin here for everysprite but for now lets leave it here and test.
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Camera.TransFormMatrix);

            if (Shader != null)
            {
                shade();
            }
            //spriteBatch.Draw(texture, location, anim.CurrentRect, Color.White);
            spriteBatch.Draw(
                texture,
                location,
                anim.CurrentRect,
                TintColor,
                Rotation,
                new Vector2(anim.CurrentRect.Width / 2, anim.CurrentRect.Height / 2),
                scaleFactor,
                SpriteEffects.None,
                0.0f);

            //spriteBatch.Draw(texture,
            //    new Rectangle(
            //       (int)location.X, (int)location.Y, CurrentAnimation.CurrentRect.Width, CurrentAnimation.CurrentRect.Height),
            //        anim.CurrentRect, Color.White, Rotation,
            //    new Vector2(CurrentAnimation.CurrentRect.Width / 2, CurrentAnimation.CurrentRect.Height / 2), SpriteEffects.None, 0);

            spriteBatch.End();
            ///Some Test this Code and tell me.
        }
コード例 #4
0
 /// <summary>
 /// Use this to Add more frame Animation's for this sprite.
 /// </summary>
 /// <param name="Key"></param>
 /// <param name="Animation"></param>
 public void AddAnimations(string Key, FrameAnimation Animation)
 {
     if(Animation != null)
         animations.Add(Key, Animation);
 }
コード例 #5
0
 /// <summary>
 /// Add items to the Dicionary of Animations
 /// </summary>
 /// <param name="Key"></param>
 /// <param name="Animation"></param>
 public void AddAnimations(string Key, FrameAnimation Animation)
 {
     spriteAnimation.AddAnimations(Key, Animation);
 }
コード例 #6
0
        /// <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
        }
コード例 #7
0
 /// <summary>
 /// Add items to the Dicionary of Animations
 /// </summary>
 /// <param name="Key"></param>
 /// <param name="Animation"></param>
 public void AddAnimations(string Key, FrameAnimation Animation)
 {
     spriteAnimation.AddAnimations(Key, Animation);
 }