Jump to content
  • Advertisement
Sign in to follow this  
Skykid

Sprite problem?

This topic is 4808 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 have a problem in which I cant display a second animation that I load for a sprite. I am using DirectX 8. The first part here says I am creating a sprite with two different animations.
void Entity::InitAnimations(IDirect3DDevice8* pD3Ddevice, Bitmap bitmap, D3DFORMAT format)
{
	animations = new Sprite[2]; 
	bitmap.Load(pD3Ddevice,"MegaMan.bmp",format,ALPHA_NONE);

	POINT start = {0,0};
	POINT end = {250,100};
	POINT dimensions = {50,50};

	animations[RUNNING].Load(pD3Ddevice,bitmap,start,end,dimensions,format);

	//bitmap.Load(pD3Ddevice,"MegaMan.bmp",format,ALPHA_NONE);

	start.x = 0; start.y = 100;
	end.x = 250; end.y = 150;
	animations[IDLE].Load(pD3Ddevice,bitmap,start,end,dimensions,format);
	
}
If I comment out the second bitmap.Load(...) function and try to display the IDLE animation I dont see anything. If I uncomment the second bitmap.Load(...) function the IDLE animation will be displayed. I should not have to reload the same bitmap image. I think the problem has something to do with the animations[RUNNING].Load() function. Here is what the animations[..].Load() function looks like.
void Sprite::Load(IDirect3DDevice8* pD3Ddevice, Bitmap bitmap,POINT start, POINT end, POINT dimensions, D3DFORMAT format)
{
	width = dimensions.x;
	height = dimensions.y;
	rows = (end.y-start.y)/height;
	columns = (end.x-start.x)/width;
	numbFrames = rows*columns;
	frame = 0;
	pTexture = new PDIRECT3DTEXTURE8[numbFrames];

	for(int row=0; row<rows; row++)
	{
		for(int column=0; column<columns; column++)
		{
			pD3Ddevice->CreateTexture(width,height,1,0,format,D3DPOOL_DEFAULT, &pTexture[frame]);
			pTexture[frame]->GetSurfaceLevel(0,&pTextureSurface);

			position.x = start.x+(column*width);
			position.y = start.y+(row*height);

			RECT rcSrc;
			SetRect(&rcSrc,position.x,position.y,(position.x+width),(position.y+height));
			POINT ptDst = {0,0};

			pD3Ddevice->CopyRects(bitmap.Image(),&rcSrc,1,pTextureSurface,&ptDst);
			frame ++;
		}
	}

	current_frame = 0;
}
Anybody see anything wrong?

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!