1
\$\begingroup\$

I have created a dialog in Libgdx main menu screen.

I have tried

dialog.setPosition(300, 300);
dialog.show(stage);

It doesn't do anything. Is it a camera trick? Am I missing something?

\$\endgroup\$
3
\$\begingroup\$

Just in case some people encounter the same issue :


Libgdx javadoc says dialog is centered by default with show method.

Do :

dialog.setPosition(300, 300);
stage.addActor(dialog);

Instead of dialog.showto let the dialog use these positions instead of default ones computed by show method.

\$\endgroup\$
0
\$\begingroup\$

You could use the show method:

dialog.show(stage, sequence(Actions.alpha(0), Actions.fadeIn(0.4f, Interpolation.fade)));
dialog.setPosition(position.x, position.y);

According to the source code, the general show method just auto-sets the position to the center. By using this method, you could pass the auto-set center.

\$\endgroup\$
  • \$\begingroup\$ Welcome to GameDev! Please note that I have removed the part about "this is already answered, but.."; that does not really matter, in context. We like other answers that might cater to other users. If you have a good alternate answer, feel free to post it, even if the question already has an accepted answer! You might even get more votes than the original. \$\endgroup\$ – Gnemlock Apr 8 '17 at 7:17

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.