Jump to content
  • 0

Seperate frame Width for _idle


Ainz Ooal Gown

Question

Hi All,

 

So ive spent the best part of today trying to figure this out but I am having no luck, so thought id ask the pro's :)

 

I have added 8 frames to my game for everything, apart from I would like to use only 3x4 frame sprite in for _idle (To save on adding the extra frames and them not being used).

 

I have tried a few modifications to Entity.cs, but I can not seem to get it right, as I get warnings and errors or it just does not work.

 

These are my sprites:

 

Normal Sprite

37cc0e78ea9d33b52774eb49c4cf1fac.png

 

Idle Sprite

e83b0b5422c1fa57f5e52071fff039a6.png

 

I tried to add a else if to the Draw function:

 

                   if (SpriteAnimation == SpriteAnimations.Idle)
                        {
                            srcRectangle = new FloatRect(
                                3 * (int)texture.GetWidth() / 3, d * (int)texture.GetHeight() / 4,
                                (int)texture.GetWidth() / 3, (int)texture.GetHeight() / 4
                            );
                        }

But It doesnt work. I added this above "if (SpriteAnimation == SpriteAnimations.Normal)"

 

Any ideas where im going wrong? My knowledge of C# is very limited and I am still learning. So I mainly use what I can see in the code already a minic it (Noob way :P)

 

Thanks

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Instead of changing the calculation around the entire time in several ifs, wouldn't it be easier to turn the amount of frames into a variable to not have a load of repeated code?

 

That way a single change affects everything below it should you need this change again in the future.

Link to comment
Share on other sites

  • 0
8 minutes ago, Joyce said:

Instead of changing the calculation around the entire time in several ifs, wouldn't it be easier to turn the amount of frames into a variable to not have a load of repeated code?

 

That way a single change affects everything below it should you need this change again in the future.

 

Thanks for the reply. I think I understand what you mean, but to be honest I wouldn't know what to change or do.

 

Do you mean changing (int)texture.GetWidth() / 3 to a input variable?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...