Skip to main content
deleted 29 characters in body
Source Link

I personally haven't used the method your using. But since you have asked if there is another way to do this...

Suppose you have a texture atlas (texture made up of sub-textures) where each sub-texture has the same dimensions:

Then if you create a RECT R = {j*64, i*64, (j+1)*64, (i+1)*64};
   ->Where j = currentFrame / 6     //row 
   ->Where i = currentFrame % 6     //col
        ->(6 because of 6 sub-textures in a row)
   ->Where 64 is the width and height of the sub-tecture

Then if you create a RECT R = {j*64, i*64, (j+1)*64, (i+1)*64};

->Where int j = currentFrame / 6 //row

->Where int i = currentFrame % 6 //col

->(6 because of 6 sub-textures in a row)

->Where 64 is the width and height of the sub-texture

You would simply use this line to draw:

mSprite->Draw(yourTexture, &R, &mSpriteCenter, 0, D3DCOLOR_XRGB(255, 255, 255));

So as you update your currentFrame in an update method, this will effectively update your rect to be draw from the texture.

AdditionAdditional note: I learned this method from Introduction to 3D Game Programming With DirectX 9.0c A Shader Approach - by Frank D. Luna

I personally haven't used the method your using. But since you have asked if there is another way to do this...

Suppose you have a texture atlas (texture made up of sub-textures) where each sub-texture has the same dimensions:

Then if you create a RECT R = {j*64, i*64, (j+1)*64, (i+1)*64};
   ->Where j = currentFrame / 6     //row 
   ->Where i = currentFrame % 6     //col
        ->(6 because of 6 sub-textures in a row)
   ->Where 64 is the width and height of the sub-tecture

You would simply use this line to draw:

mSprite->Draw(yourTexture, &R, &mSpriteCenter, 0, D3DCOLOR_XRGB(255, 255, 255));

So as you update your currentFrame in an update method, this will effectively update your rect to be draw from the texture.

Addition note: I learned this method from Introduction to 3D Game Programming With DirectX 9.0c A Shader Approach - by Frank D. Luna

I personally haven't used the method your using. But since you have asked if there is another way to do this...

Suppose you have a texture atlas (texture made up of sub-textures) where each sub-texture has the same dimensions:

Then if you create a RECT R = {j*64, i*64, (j+1)*64, (i+1)*64};

->Where int j = currentFrame / 6 //row

->Where int i = currentFrame % 6 //col

->(6 because of 6 sub-textures in a row)

->Where 64 is the width and height of the sub-texture

You would simply use this line to draw:

mSprite->Draw(yourTexture, &R, &mSpriteCenter, 0, D3DCOLOR_XRGB(255, 255, 255));

So as you update your currentFrame in an update method, this will effectively update your rect to be draw from the texture.

Additional note: I learned this method from Introduction to 3D Game Programming With DirectX 9.0c A Shader Approach - by Frank D. Luna

I personally haven't used the method your using. But since you have asked if there is another way to do this...

Suppose you have a texture atlas (texture made up of sub-textures) where each sub-texture has the same dimensions?:

Then if you create a RECT R = {j*64, i*64, (j+1)*64, (i+1)*64};
   ->Where j = currentFrame / 6     //row 
   ->Where i = currentFrame % 6     //col
        ->(6 because of 6 sub-textures in a row)
   ->Where 64 is the width and height of the sub-tecture

Then if you create a RECT R = {j64, i64, (j+1)*64, (i+1)*64}; ->Where j = currentFrame / 6 //row ->Where i = currentFrame % 6 //col ->(6 because of 6 sub-textures in a row) ->Where 64 is the width and height of the sub-tecture Then youYou would simply use this line, mSprite->Draw(yourTexture, &R, &mSpriteCenter, 0, D3DCOLOR_XRGB(255, 255, 255)); to draw:

mSprite->Draw(yourTexture, &R, &mSpriteCenter, 0, D3DCOLOR_XRGB(255, 255, 255));

So as you update your currentFramecurrentFrame in an update method, this will effectively update your rect to be draw from the texture.

Addition notesnote: I learned this method from 'Introduction to 3D Game Programming With DirectX 9.0c A Shader Approach'Introduction to 3D Game Programming With DirectX 9.0c A Shader Approach - by Frank D. Luna

I personally haven't used the method your using. But since you have asked if there is another way to do this...

Suppose you have a texture atlas (texture made up sub-textures) where each sub-texture has the same dimensions?

Then if you create a RECT R = {j64, i64, (j+1)*64, (i+1)*64}; ->Where j = currentFrame / 6 //row ->Where i = currentFrame % 6 //col ->(6 because of 6 sub-textures in a row) ->Where 64 is the width and height of the sub-tecture Then you would simply use this line, mSprite->Draw(yourTexture, &R, &mSpriteCenter, 0, D3DCOLOR_XRGB(255, 255, 255));

So as you update your currentFrame in an update method, this will effectively update your rect to be draw from the texture.

Addition notes: I learned this method from 'Introduction to 3D Game Programming With DirectX 9.0c A Shader Approach' - by Frank D. Luna

I personally haven't used the method your using. But since you have asked if there is another way to do this...

Suppose you have a texture atlas (texture made up of sub-textures) where each sub-texture has the same dimensions:

Then if you create a RECT R = {j*64, i*64, (j+1)*64, (i+1)*64};
   ->Where j = currentFrame / 6     //row 
   ->Where i = currentFrame % 6     //col
        ->(6 because of 6 sub-textures in a row)
   ->Where 64 is the width and height of the sub-tecture

You would simply use this line to draw:

mSprite->Draw(yourTexture, &R, &mSpriteCenter, 0, D3DCOLOR_XRGB(255, 255, 255));

So as you update your currentFrame in an update method, this will effectively update your rect to be draw from the texture.

Addition note: I learned this method from Introduction to 3D Game Programming With DirectX 9.0c A Shader Approach - by Frank D. Luna

Source Link

I personally haven't used the method your using. But since you have asked if there is another way to do this...

Suppose you have a texture atlas (texture made up sub-textures) where each sub-texture has the same dimensions?

Then if you create a RECT R = {j64, i64, (j+1)*64, (i+1)*64}; ->Where j = currentFrame / 6 //row ->Where i = currentFrame % 6 //col ->(6 because of 6 sub-textures in a row) ->Where 64 is the width and height of the sub-tecture Then you would simply use this line, mSprite->Draw(yourTexture, &R, &mSpriteCenter, 0, D3DCOLOR_XRGB(255, 255, 255));

So as you update your currentFrame in an update method, this will effectively update your rect to be draw from the texture.

Addition notes: I learned this method from 'Introduction to 3D Game Programming With DirectX 9.0c A Shader Approach' - by Frank D. Luna