How do I translate scaled layer positions?

Get help using Construct 2

Post » Wed Jun 10, 2015 12:32 am

Object A is on Layer 1.

Layer 1 is scaled to 1.25x.

Object B is on Layer 2.

Layer 2 is scaled to 1.0.

I want to place B directly over A.

Everything I'm coming up with seems way to convoluted. One of those days. :oops:

Is there any built in command to project the position of an object on a scaled layer to a position on another, differently scaled layer?
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Wed Jun 10, 2015 2:13 am

Figured it out. :P

For anyone reading this later on:

    Seeker object is on Layer "Pause"

    Target is on Layer "Game"

    "Game" is scaled to 1.25x.

We use LayerToCanvas to translate position out to canvas co-ors, then CanvasToLayer to translate back to the target layer. Like:

Code: Select all
X:

CanvasToLayerX("Pause", LayerToCanvasX("Game",Player.X, Player.Y), LayerToCanvasY("Game",Player.X, Player.Y) )

Y:

CanvasToLayerY("Pause", LayerToCanvasX("Game",Player.X, Player.Y), LayerToCanvasY("Game",Player.X, Player.Y) )
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202


Return to How do I....?

Who is online

Users browsing this forum: Bing [Bot] and 22 guests