1
\$\begingroup\$

I want to render one sprite on top of another one. I create both sprites using same coordinates and while debuging I can see that they have same position but still one is being rendered beneath another and slightly to the left. Could somebody tell me what am I doing wrong? here is my code where I create sprites:

Sprite sprite1 = new Sprite(new Texture("1.png"));
sprite1.setScale(1/PPM);
Sprite sprite2 = new Sprite(new TextureRegion(...));
sprite2.setScale(1/PPM);
sprite1.setPosition(x,y);
sprite2.setPosition(x,y);

Could it have something to do with scaling? Or maybe the fact that second sprite is created from TextureRegion?

\$\endgroup\$
1
  • \$\begingroup\$ Screenshot? This isn't nearly enough code for us to help you, too \$\endgroup\$
    – mid
    Apr 22 '17 at 16:44
1
\$\begingroup\$

Check the origins of the sprites. if one has its pivot in the middle and the other one top left for example then they appear in different positions.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.