Answer the question
In order to leave comments, you need to log in
How to fix sprite rotation problem?
Hello. Please, tell me the solution to the problem of rotating the sprite on the screen.. There is a similar code in two files:
.h file: https://github.com/Debug-/samp-omega/blob/master/C...
.cpp file: https ://github.com/Debug-/samp-omega/blob/master/C...
The bottom line is that when the rotation changes (here: https://github.com/Debug-/samp-omega/blob/ master/C... the rotation angle itself does not seem to change.I
think when changing, you need to recalculate the location of the sprite on the screen, so before the Draw function ( https://github.com/Debug-/samp-omega/blob/master/ C... added SetTransformation ( https://github.com/Debug-/samp-omega/blob/master/C... but to no avail(
What solution to the problem can be? Many thanks to whoever helps.
Answer the question
In order to leave comments, you need to log in
You have the matrix updated in the Sprite::SetTransformation method, but you don't apply it to your sprite. Most likely it should be done.
void Sprite::SetTransformation()
{
D3DXVECTOR2 spriteCenter = center;
D3DXVECTOR2 trans = pos;
D3DXVECTOR2 scaling = scale;
D3DXMatrixTransformation2D(&mat, NULL, 0.0, &scaling, &spriteCenter, rotation, &trans);
sprite->SetTransform(&mat);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question