Sign in to follow this  

i dont think i get RECT

This topic is 4481 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;
    srcRect.top    = (( nFrame / 5 ) * 64);
    srcRect.left   = (( nFrame % 5 ) * 64);
	srcRect.bottom = srcRect.top  + 64;
    srcRect.right  = srcRect.left + 64;

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

	g_pDonutSprite->Begin();

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

	g_pDonutSprite->End();

    g_pd3dDevice->EndScene();

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

	if( fAnimationTimer > 0.01f )
	{
		++nFrame;

		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 Codesampler.com 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

This topic is 4481 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.

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

Sign in to follow this