How do I track the X&Y for a parallax object

Get help using Construct 2

Post » Mon Nov 24, 2014 9:55 am

I have an object that's somewhere outside of my project.... I would like to track it's X&Y exactly, however because it has a different parallax than the 'arrow' i'm using to point at the object, the arrow reads a different X & Y coordinate, showing it off. When it's not zoomed in... it's fine. When you zoom in (layout scale) it screws up, because of the parallax.

Can anyone help me out? It's 5 in the morning... I've been up all night... probably the reason I'm not figuring this out.... also the reason this may not make any sense to anyone... hence the upload.

paracoordinate.capx


Thanks!
You do not have the required permissions to view the files attached to this post.
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Mon Nov 24, 2014 11:13 am

You'll need to convert Layer Co-ords to Canvas Co-ords.

paracoordinate.capx

I did it 2 ways.

Instance variables for the drag-able box that covert the x pos & y pos on the layer to canvas and store them as instance vaviables. This was so you can see the expression more clearly.

And a toggled disabled action that does it all in one expression but is a bit long and maybe hard to understand what's going on.

The expression you need is under System>Layers>LayerToCanvasX & LayerToCanvasY.
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Mon Nov 24, 2014 2:16 pm

Awesome.... figures I would have missed that one. :) Thanks!

With that, I also figured out how to change the position too:

Set X- CanvasToLayerX("Layer 0",LayerToCanvasX("Layer 1", sprite2.X, sprite2.Y) ,LayerToCanvasY("Layer 1", sprite2.X, sprite2.Y))
Set Y- CanvasToLayerY("Layer 0",LayerToCanvasX("Layer 1", sprite2.X, sprite2.Y) ,LayerToCanvasY("Layer 1", sprite2.X, sprite2.Y))


Thanks again!
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Mon Nov 24, 2014 2:36 pm

Glad you sorted it.

I updated the capx but you beat me to it. I'll post the capx anyway for anyone else who wants to achieve the same thing.

paracoordinate-2.capx
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Wed Nov 26, 2014 7:33 pm

this is great. thanks.
B
21
S
5
G
1
Posts: 96
Reputation: 1,927


Return to How do I....?

Who is online

Users browsing this forum: tarek2, Yahoo [Bot] and 14 guests