How do I convert an UI position to world position?

Get help using Construct 2

Post » Mon Feb 06, 2017 5:34 pm

Hi,

I have some objects created in the UI layer (no parallax), and I want to move them to another layer preserving the "relative " position. I mean, i nthe UI layer one object can be at 100, 100 (UI layer) but in the real world is 1024, 345. How do I convert the UI position to world position to positionate that objects correctly when I move them to a new layer.

Thanks.
B
6
S
2
Posts: 61
Reputation: 1,099

Post » Mon Feb 06, 2017 5:37 pm

ImageImageImage
B
71
S
22
G
257
Posts: 3,791
Reputation: 142,698

Post » Mon Feb 06, 2017 5:49 pm

I don't know how to use it.

What I do first? Move the object to the new layer and then repositionate it?
B
6
S
2
Posts: 61
Reputation: 1,099

Post » Mon Feb 06, 2017 6:09 pm

ok, got it, without changing the layer. Thanks man
B
6
S
2
Posts: 61
Reputation: 1,099

Post » Mon Feb 06, 2017 6:10 pm

Assuming moving from layer 2 (no parallax) to layer 1:
SetPostion
X = CanvasToLayerX(1, LayerToCanvasX(2, Self.X, Self.Y),LayerToCanvasY(2, Self.X, Self.Y))
Y = CanvasToLayerY(1, LayerToCanvasX(2, Self.X, Self.Y),LayerToCanvasY(2, Self.X, Self.Y))
Move to layer 1
ImageImageImage
B
71
S
22
G
257
Posts: 3,791
Reputation: 142,698


Return to How do I....?

Who is online

Users browsing this forum: babymumu, dop2000, draiza and 4 guests