Advertisement Jump to content
Sign in to follow this  

i dont think i get RECT

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i know what is is and what the params mean but i see net apps using this to look at a portion of a texture and then another and in the end they have an animation, for example this code is from code sampler can someone explain it to me

RECT srcRect;    = (( nFrame / 5 ) * 64);
    srcRect.left   = (( nFrame % 5 ) * 64);
	srcRect.bottom =  + 64;
    srcRect.right  = srcRect.left + 64;

	D3DXVECTOR3 vCenter( 0.0f, 0.0f, 0.0f );
	D3DXVECTOR3 vPosition( fPosition, 200.0f, 0.0f );


    g_pDonutSprite->Draw( g_pDonutTexture,
                          D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) );



static float fAnimationTimer = 0.0f;
	fAnimationTimer += g_fElpasedTime;

	if( fAnimationTimer > 0.01f )

		if( nFrame > 29 )
			nFrame = 0;

		fAnimationTimer = 0.0f;

thanks, nframe is justa normal int variable set to 0 . . how does it work, the code can be found in the directx9 samples on codesampler - 3dsprite

Share this post

Link to post
Share on other sites
Hi there zerotheend2000,
How are you doing?

The Problem
Rectangles in sprite animation

The Solution
What this person doing here is they have a large texture that is split up into different animation frames. You then have a rectangle that shifts for each part of the texture to load another texture from this larger texture... all these rectangles does is they shift to the next frame in the texture...

1) Big texture has little frame animation key frames in it
2) The rectangle slices a frame out of the larger texture
3) Draws it through the use of sprite
4) Next frame is sliced out of the texture.

I hope this helps a bit. Take care.

Share this post

Link to post
Share on other sites
thanks, i know that its doing that but where and how does it know when to skip to the next frame on the loaded texture.

for example, when does it know when to go to a new line. if you download the tutorial from you may see what im tlking bout

its just these little bits of info im mising to get along with this subject

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!