Skip to main content
gamedev.net
🔒 Locked 🎲 GameMaker

2d Animation Problem

Started by justin12343 0 replies 350+ views
Original Post
justin12343
justin12343
I have a function thats supposed to draw a frame from a sprite sheet thats loaded in memory, but it only works if I set the subImg to something like "1" and it doesn't work when I set it to the value of another variable like "animation_frame."

Here the draw_sprite function
void spriteManager::draw_sprite( SPRITE &spr, float subImg, float angle, float x, float y){		RECT srcRect;	int image=floor( subImg);	int rowW=spr.imageInfo.Width/spr.w;    	srcRect.top    = ((image / rowW ) * spr.h);    srcRect.left   = ((image % rowW ) * spr.w);	srcRect.bottom = srcRect.top  + spr.h;    srcRect.right  = srcRect.left + spr.w;	D3DXVECTOR3 vCenter( spr.ox, spr.oy, 0.0f );	D3DXVECTOR3 vPosition( x, y, 0.0f );	D3DXMatrixRotationZ( &spr.matrix, (1/360)*angle);		spr.sprite->Begin( D3DXSPRITE_ALPHABLEND);		spr.sprite->SetTransform( &spr.matrix);	spr.sprite->Draw( spr.texture,                          &srcRect,                          &vCenter,                          &vPosition,                          D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) );	spr.sprite->End();}


it also doesn't rotate the sprite either. Where did I make a Error.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.