Hi,

My game is published but i need fix somethings that i don't know the best practices to do it: https://flyforcoins.prsolucoes.com/

My GUI is following the viewport at any size. If i resize it follow TOP RIGHT anchor.

But my "game" or the "center of the game" or the "main part of the game" don't follow it and is always on position 0,0 with the initial viewport size (960 x 640). Example:

And i can create objects out of initial viewport, like the coins and enemies as you can see on screenshot. Im using this code to spawn things:

var spawn = coin25.instance()
var vp_size = get_node("/root/World").get_viewport_rect().size
var spawn_size = spawn.get_node("Sprite").frames.get_frame("normal", 0).get_size()
var pos_x = (spawn_size.y / 2) + vp_size.x
var pos_y = rand_range((spawn_size.y / 2), (vp_size.y - (spawn_size.y / 2)))		
	
spawn.position = Vector2(pos_x, pos_y)
add_child(spawn)

It works very well.

The only problem is the game main part that don't follow the size of viewport. All other screens are very well positioned. Look:

This is very strange. Look at my scene to understand that i already put a physic body in control node and put the anchor to bottom left:

I don't know how can i solve it.

I put screenshots in desktop app only to simulate the problem. Because the only device that i really have problems is on iPad. On devices like iPhone, Android and Tablet with Android it works without this problem. And if i resize the screen i can simulate the problem.

Thanks.

Hi,

To better understand i put a Color Rect on Container Bottom. See:

Thanks.

I believe you want to put all your UI nodes under a parent Control node (probably center container would be your best best here) and make sure that parent node has the size of exactly the same as your game's original pixel size. But control nodes can sometimes be confusing, I think something like that would work.

I'm sorry, I was a little confused. What you do is make a normal Control Node as the parent. Set the Rect Size to 960 x 640 (or whatever your game window starts at). Then make the other UI Control Nodes as children of the parent Control Node. I just tested it and it works perfectly.

My "static body" already is inside a "Control":

If i put inside a control or not make no difference, it is in the same place. Fixed at position (640 - 40) that is the position on editor. Things like UI controls (score text and score bar) works with anchor and inside a control, but put the physic object, very strange.

Hi,

I made a sample and it appear work:

I need check my game to understand what is wrong in mine :(

Hi,

I adjust the camera. The difference is camera2d that was not checked as "current".

Now this is:

Two problems that i need understand best practices now.

1 - The enemies and coins are created out of that "area" of 960x640 because im using that code that get viewport size.

2 - The two controls bottom and top don't follow window size like score on top right, why?

Thanks.

Hi,

I have "fixed" it putting the camera limit to 640, so it is always on bottom.

Now the only thing that is wrong is parallax background.

We are changing background scale and it is wrong now.

Im setting initial mirroring as "x:1920". But after change background scale what is the correct mirroring value that i need use? There is any way to get texture size after scale?

Mirroring today is 1920 (960 * 2).

Thanks.

Hi,

Fixed the last thing now: get_node("/root/World/Background/BackgroundLayer").motion_mirroring.x = background_size.x * new_scale

Perfect now.

Thanks.

I was saying to put the control nodes under another control node (with a fixed size).

Sorry if I didn't explain clearly. See here: