Jump to content

View more

Image of the Day

Working on an auto spawn system. #gamedev #indiedev #screenshotsaturday https://t.co/Mm2kfekz7b
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Does sprite set transform transform the location too?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 noatom   Members   

925
Like
0Likes
Like

Posted 06 March 2014 - 05:39 AM

D3DXMATRIX mat;
D3DXMatrixTransformation2D(&mat, &D3DXVECTOR2(all_sprites.at(i)->width / 2, all_sprites.at(i)->height / 2), 0.0, &D3DXVECTOR2(1, 1), &D3DXVECTOR2(all_sprites.at(i)->width / 2, all_sprites.at(i)->height / 2), D3DXToRadian(270), 0);
ppSprite->SetTransform(&mat);

That's all I do, and my sprite gets all messed up( I literally can't see it). If I don't setup the rotation, the sprite get drawn correctly at the right position!



#2 Buckeye   GDNet+   

10743
Like
0Likes
Like

Posted 06 March 2014 - 08:58 AM

Just a guess: since you're not scaling, set scaling center vector pointer and scaling vector pointer to NULL to default to an identity matrix.


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


#3 Norman Barrows   Members   

7149
Like
0Likes
Like

Posted 06 March 2014 - 09:58 PM

this may help:

 

 

 
 
 
 
 
 
// draw a sprite. x,y are screen coords of the UL corner.
void Zdrawsprite(int texID,int x,int y,float sx,float sy)
{
D3DXVECTOR3 position;
D3DXMATRIX m;
D3DXMatrixScaling(&m,sx,sy,1.0f);
Zsprite->SetTransform(&m);
position.x=(float)x/sx;
position.y=(float)y/sy;
position.z=0;
Zsprite->Draw(Ztex[texID].tex,NULL,NULL,&position,0xFFFFFFFF);
}
 
 
 
 
 
// draw a rotated sprite. x,y are screen coords of the center.
void Zdrawsprite2(int texID,int x,int y,float sx,float sy,float rz)
{
D3DXVECTOR3 center;
D3DXMATRIX m,m2;
D3DXMatrixScaling(&m,sx,sy,1.0f);
D3DXMatrixRotationZ(&m2,rz);
D3DXMatrixMultiply(&m,&m,&m2);
D3DXMatrixTranslation(&m2,(float)x,(float)y,0.0f);
D3DXMatrixMultiply(&m,&m,&m2);
Zsprite->SetTransform(&m);
center.x=128.0f;
center.y=128.0f;
center.z=0.0f;
Zsprite->Draw(Ztex[texID].tex,NULL,&center,NULL,0xFFFFFFFF);
}
 
 

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

 

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

 

 





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.