Slide in UI box mispositions on iOS devices
Asked Answered
B

2

0

I have basically an "error" or "yaar" type of node that I have tried dropping into the node tree in the editor, and instantiating via code. Either way, when I ask it to slide from below the bottom of the screen (y=bottom of screen) to the bottom area of the screen (y=bottom of screen - box height), this works on the desktop, but fails on iOS. On iOS I have to arbitrarily offset the landing spot 600 pixels up on the screen.

I am hoping an expert might see some fatal problem with this code:

	var loc = calculateSlideIn(correctFeedback)
	var tween = get_node("Tween")
	tween.interpolate_property(correctFeedback, "rect_global_position",
		loc.start, loc.end, 0.4,
		Tween.TRANS_EXPO, Tween.EASE_OUT)

func calculateSlideIn(n):
	var screenHeight = OS.window_size.y
	var start = Vector2(0, screenHeight)
	var end = Vector2(0, screenHeight - n.rect_size.y)
	print("slide in from ", start, " to ", end, " size: ", n.rect_size, " visible: ", n.visible)
	return {"start":start, "end":end}

There is a 120pixel safe area on the top of my iPhone, but it's too small of an offset to matter here as far as I can tell.

i.e. if the panel is 220 pixels heigh, and the device is 1200 pixels high, it slides from y=1200 to y=980. And works on the desktop. On my phone I just take off another 600 and all of a sudden I can see it.

Bakehouse answered 24/1, 2023 at 7:8 Comment(0)
B
0

What is interesting about this, is that OS.window_size.y reports: 2436 but when the app is showing a node at full screen, the node claims it's height is 800x1732

Bakehouse answered 24/1, 2023 at 7:44 Comment(0)
I
0

I think you have to enable Hi-DPI in the project settings and iOS export settings. Apple does weird stuff with virtual display scaling.

Izawa answered 24/1, 2023 at 9:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.