How do I use CanvasToLayer correctly

Get help using Construct 2

Post » Wed Dec 02, 2015 10:56 pm

I'm trying to place the X object, dead center on the O object that is on a layer above with 0,0 parallax. But it is positioning to the top-left area of the object, even though its origin is in the center of it.

Here is the capx. Thanks.
https://www.dropbox.com/s/7i7cm5mu6uoqy ... .capx?dl=0
B
50
S
11
G
7
Posts: 274
Reputation: 8,146

Post » Thu Dec 03, 2015 12:15 am

try this:
set xpos to
Code: Select all
CanvasToLayerX("L0",LayerToCanvasX("L1", Self.X, Self.Y) ,LayerToCanvasY("L1",Self.X,Self.Y))

set ypos to
Code: Select all
CanvasToLayerY("L0",LayerToCanvasX("L1", Self.X, Self.Y) ,LayerToCanvasY("L1", Self.X, Self.Y))


LayerToCanvas/CanvasToLayer example
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Thu Dec 03, 2015 12:18 am

korbaach wrote:try this:
set xpos to
Code: Select all
CanvasToLayerX("L0",LayerToCanvasX("L1", Self.X, Self.Y) ,LayerToCanvasY("L1",Self.X,Self.Y))

set ypos to
Code: Select all
CanvasToLayerY("L0",LayerToCanvasX("L1", Self.X, Self.Y) ,LayerToCanvasY("L1", Self.X, Self.Y))


LayerToCanvas/CanvasToLayer example


Yep, that worked. Thanks!
B
50
S
11
G
7
Posts: 274
Reputation: 8,146


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests