Bonjour,

j'ai 2 soucis sur mon jeu, j'ai un "blanc" à la fin de l'animation de mon personnage, ce qui fait qu'il disparaît avant de repartir sur la première position, je ne vois pas d'où ça vient.
L'autre soucis est que si la touche clavier est up, l'animation s'arrête net comme si le perso jouait à 1 2 3 soleil, comment faire en sorte que ça se termine sur la position initiale?

Voilà les 2 classes en question

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
 
namespace test
{
    public class Animation
    {
        int nbFrame;
        int switchFrame;
 
        bool active;
 
        Vector2 position;
        Vector2 frameAmount;
        Vector2 currentFrame;
        public Texture2D Image;
        Rectangle sourceRect;
 
        public bool Active
        {
            get { return active; }
            set { active = value; }
        }
        public Vector2 CurrentFrame
        {
            get { return currentFrame; }
            set { currentFrame = value; }
        }
 
        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }
 
        public Texture2D AnimationImage
        {
            set { Image = value; }
        }
        public int FrameWidth
        {
            get { return Image.Width / (int)frameAmount.X; }
        }
 
        public int FrameHeight
        {
            get { return Image.Height / (int)frameAmount.Y; }
        }
 
        public void Initialize(Vector2 position, Vector2 Frames)
        {
            active = false;
            switchFrame = 100;
            this.position = position;
            this.frameAmount = Frames;
        }
 
        public void Update(GameTime gameTime)
        {
            if (active)
            {
                nbFrame += (int)gameTime.ElapsedGameTime.TotalMilliseconds;
            }
            else nbFrame = 0;
            if (nbFrame >= switchFrame)
            {
                nbFrame = 0;
                currentFrame.X += FrameWidth;
                if (currentFrame.X > Image.Width)
                {
                    currentFrame.X = 0;
                }
            }
            sourceRect = new Rectangle((int)currentFrame.X, (int)currentFrame.Y * FrameHeight, FrameHeight, FrameWidth);
        }
 
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Image, position, sourceRect, Color.White);
        }
    }
}
EDIT (ajouts)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
 
namespace test
{
    public class Player
    {
        Texture2D playerImage;
        Vector2 playerPosition;
        Vector2 tempCurrentFrame;
        KeyboardState keyState;
 
        float moveSpeed = 300f;
 
        bool hasJumped;
        Vector2 velocity;
 
        Animation playerAnimation = new Animation();
 
        public void Initialize()
        {
            playerAnimation.Initialize(playerPosition, new Vector2(6, 2));
            tempCurrentFrame = Vector2.Zero;
            playerAnimation.Position = new Vector2(50, 500);
            hasJumped = true;
        }
 
        public void LoadContent(ContentManager Content)
        {
            playerImage = Content.Load<Texture2D>("mainsheet");
            playerAnimation.AnimationImage = playerImage;
        }
 
        public void Update(GameTime gameTime)
        {
            keyState = Keyboard.GetState();
            playerAnimation.Active = true;
            playerPosition = playerAnimation.Position + velocity;
            //playerPosition += velocity;
            if (keyState.IsKeyDown(Keys.Right))
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Space) && hasJumped == false)
                {
                    playerPosition.Y -= 60f;
                    velocity.Y = -5f;
                    hasJumped = true;
                }
                //playerPosition.X += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                velocity.X = 3f;
                tempCurrentFrame.Y = 0;
            }
            else if (keyState.IsKeyDown(Keys.Left))
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Space) && hasJumped == false)
                {
                    playerPosition.Y -= 60f;
                    velocity.Y = -5f;
                    hasJumped = true;
                }
                //playerPosition.X -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                velocity.X = -3f;
                tempCurrentFrame.Y = 1;
            }
            //else playerAnimation.Active = false;
            else if (Keyboard.GetState().IsKeyDown(Keys.Space) && hasJumped == false)
            {
                playerPosition.Y -= 60f;
                velocity.Y = -5f;
                hasJumped = true;
            }
            else
            {
               playerAnimation.Active = false;
                velocity.X = 0f;
            }
 
            if (hasJumped == true)
            {
               float i = 1;
               velocity.Y += 0.20f * i;
            }
            if (hasJumped == false)
            {
               velocity.Y = 0f;
            }
            if (playerPosition.Y + playerImage.Height >= 650)
            {
               hasJumped = false;
            }
 
            tempCurrentFrame.X = playerAnimation.CurrentFrame.X;
            playerAnimation.Position = playerPosition;
            playerAnimation.CurrentFrame = tempCurrentFrame;
            playerAnimation.Update(gameTime); 
        }
 
        public void Draw(SpriteBatch spriteBatch)
        {
            playerAnimation.Draw(spriteBatch);
        }
    }
}
Merci d'avance,