Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 2 characters in body
Source Link
Draw:  
myPlayer = new Player(TextureLibrary.GetTexture("player"), myPlayerPos, 200, new Vector2(.3f, .3f), 0, Color.White, 1000, 1);
Draw: myPlayer = new Player(TextureLibrary.GetTexture("player"), myPlayerPos, 200, new Vector2(.3f, .3f), 0, Color.White, 1000, 1);
Draw:  
myPlayer = new Player(TextureLibrary.GetTexture("player"), myPlayerPos, 200, new Vector2(.3f, .3f), 0, Color.White, 1000, 1);
added 1827 characters in body; edited title
Source Link

How to add a animation that loops constantly?to myPlayer

For example, my player will have 4 different images for it and I'd want it to always swap trough these images.

Edit

I managed to make a constantly looping animation to a sprite and but I don't know how to insert into myPlayer.

Game1:
        Texture2D myPlayerAnim;
        Rectangle myDestRect;
        Rectangle mySourceRect;
        Texture2D myEnemyAnim;
        Rectangle myEnemyDestRect;
        Rectangle myEnemySourceRect;
        float myElapsed;
        float myDelay = 100f;
        int myFrames = 0;

Initialize:
            myDestRect = new Rectangle(0, 0, 512, 512);
            myEnemyDestRect = new Rectangle(0, 0, 808, 608);

LoadContent: 

            myPlayerAnim = Content.Load<Texture2D>("SpriteSheetPlayerAnim");
            myEnemyAnim = Content.Load<Texture2D>("SpriteSheetEnemyAnim");

Update:    
            myElapsed += (float)aGameTime.ElapsedGameTime.TotalMilliseconds;

            if (myElapsed >= myDelay)
            {
                if (myFrames >= 3)
                {
                    myFrames = 0;
                }
                else
                {
                    myFrames++;
                }
                myElapsed = 0;
            }

            mySourceRect = new Rectangle(512 * myFrames, 0, 512, 512);
            myEnemySourceRect = new Rectangle(808 * myFrames, 0, 808, 608);

Draw: 

            mySpriteBatch.Draw(myPlayerAnim, myDestRect , mySourceRect, 
            Color.White);
            mySpriteBatch.Draw(myEnemyAnim, myEnemyDestRect, myEnemySourceRect, 
            Color.White);´

Draw just draws the animations out but I don't know how to insert it into myPlayer. For myPlayer I currently have this but I couldn't figure out how to do it with my animations.

Draw: myPlayer = new Player(TextureLibrary.GetTexture("player"), myPlayerPos, 200, new Vector2(.3f, .3f), 0, Color.White, 1000, 1);

How to add a animation that loops constantly?

For example my player will have 4 different images for it and I'd want it to always swap trough these images.

How to add a animation to myPlayer

For example, my player will have 4 different images for it and I'd want it to always swap trough these images.

Edit

I managed to make a constantly looping animation to a sprite and but I don't know how to insert into myPlayer.

Game1:
        Texture2D myPlayerAnim;
        Rectangle myDestRect;
        Rectangle mySourceRect;
        Texture2D myEnemyAnim;
        Rectangle myEnemyDestRect;
        Rectangle myEnemySourceRect;
        float myElapsed;
        float myDelay = 100f;
        int myFrames = 0;

Initialize:
            myDestRect = new Rectangle(0, 0, 512, 512);
            myEnemyDestRect = new Rectangle(0, 0, 808, 608);

LoadContent: 

            myPlayerAnim = Content.Load<Texture2D>("SpriteSheetPlayerAnim");
            myEnemyAnim = Content.Load<Texture2D>("SpriteSheetEnemyAnim");

Update:    
            myElapsed += (float)aGameTime.ElapsedGameTime.TotalMilliseconds;

            if (myElapsed >= myDelay)
            {
                if (myFrames >= 3)
                {
                    myFrames = 0;
                }
                else
                {
                    myFrames++;
                }
                myElapsed = 0;
            }

            mySourceRect = new Rectangle(512 * myFrames, 0, 512, 512);
            myEnemySourceRect = new Rectangle(808 * myFrames, 0, 808, 608);

Draw: 

            mySpriteBatch.Draw(myPlayerAnim, myDestRect , mySourceRect, 
            Color.White);
            mySpriteBatch.Draw(myEnemyAnim, myEnemyDestRect, myEnemySourceRect, 
            Color.White);´

Draw just draws the animations out but I don't know how to insert it into myPlayer. For myPlayer I currently have this but I couldn't figure out how to do it with my animations.

Draw: myPlayer = new Player(TextureLibrary.GetTexture("player"), myPlayerPos, 200, new Vector2(.3f, .3f), 0, Color.White, 1000, 1);
Clarifying
Source Link
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

How to add a animation that always is trueloops constantly?

I'm currently making a shoot em up in monogame. I'm a beginner to programming so I'm sorry if I don't understand so much. 

I want to add animationsjust one animation to my object where it's only one animation. No commands or transitions between animations for different actions: just an object swapping between different images all the time. 

For example myPlayer but Imy player will have 4 different images for it and I'd want it to always swap trough these images. Compared to other animations videos that just

Animation guides I've reviewed seem way too complicated and unlike themfor my needs. Unlike the examples they cover, I don't want different animations for different commands. But I have no idea how to do it. Help is very much appreciated for

How can I have not so much time to finishmake this project.type of simple, always-looping frame animation?

How to add a animation that always is true

I'm currently making a shoot em up in monogame. I'm a beginner to programming so I'm sorry if I don't understand so much. I want to add animations to my object where it's only one animation. No commands just an object swapping between different images all the time. For example myPlayer but I have 4 different images for it and I'd want it to always swap trough these images. Compared to other animations videos that just seem way too complicated and unlike them I don't want different animations for different commands. But I have no idea how to do it. Help is very much appreciated for I have not so much time to finish this project.

How to add a animation that loops constantly?

I'm currently making a shoot em up in monogame. 

I want to add just one animation to my object. No commands or transitions between animations for different actions: just an object swapping between different images all the time. 

For example my player will have 4 different images for it and I'd want it to always swap trough these images.

Animation guides I've reviewed seem way too complicated for my needs. Unlike the examples they cover, I don't want different animations for different commands.

How can I make this type of simple, always-looping frame animation?

Source Link
Loading