XNA mon animation ne se fait pas :/
Salut a tous !
Je développe (enfin j'essaye) un Metal Slug a ma sauce.
J'ai les déplacement etc mais maintenant que je me lance dans les balles, je n'arrive pas a les animer.
Je ne vois pas d’où ca peut venir. Je les ajoutes dans une liste, je les dessines, mais c'est tout... Elle ne bouge pas (animations)
voila mon code :
CLASS PERSONNAGE :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
List<ClassBalles> ListBalles;
...
METHODE DE SHOOT
ListBalles.Add(new ClassBalles((int)Math.Round(Position.X + 50), (int)Math.Round(Position.Y) - 30, ClassRessources.pistolBullet));
...
public void Draw(SpriteBatch spriteBatch)
{
for (int i = 0; i < ListBalles.Count; i++)
{
ClassBalles currentBalle = ListBalles[i];
currentBalle.Draw(spriteBatch);
}
} |
CLASS BALLE
Code:
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
|
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SlugRemix
{
class ClassBalles
{
Rectangle Hitbox;
Texture2D Texture;
int Timer, AnimationSpeed, FrameColone;
public ClassBalles(int x, int y, Texture2D texture)
{
Hitbox = new Rectangle(x, y, texture.Width / 6, texture.Height);
Texture = texture;
}
public ClassBalles()
{
Texture = ClassRessources.pistolBullet;
AnimationSpeed = 10;
}
public void Animate()
{
this.Timer++;
if (this.Timer >= AnimationSpeed)
{
this.Timer = 0;
this.FrameColone++;
if (FrameColone == 6)
FrameColone = 0;
}
}
public void Update()
{
Animate();
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(
Texture,
Hitbox,
new Rectangle((FrameColone) * 18, 0, 18, 18),
Color.White,
0f,
new Vector2(18/2, 18/2),
SpriteEffects.None,
0f);
spriteBatch.DrawString(ClassRessources.font, "Frame " + FrameColone, new Vector2(50, 50), Color.Red);
}
}
} |
Voila mes codes... Le FrameColone tourne bien, mais l'animation ne se fait pas, une petite aide ? Thx !