Window x,y vs layer XY

Get help using Construct 2

Post » Thu May 23, 2013 8:00 am

Hi all,
   Im new to construct and love it so far. Ive done quite a bit of game dev in the past and C2 is just great! Ive hardly hit a snag except for this one :)

I have a layer 5000,5000 pixels. I have enabled my window to scroll on my level around this layer. I have a 3rd layer with anchored sprites for my gui. All is working scrolling gui is in place etc.. however. I am trying to spawn an object after I drag from an element in my gui.

It spawns fine if I dont move the window but once I move my window on the layer the object is spawning back at the original 0,0 of the layer and not within my window.

So I am trying to spawn an Item from my gui(im dragging from and icon) to a different layer. This works but it will not spawn where once I start moving the window around. Well I had it working until I anchored the sprites and started scrolling ;)

How do I get the object to spawn on the window coordinates instead of on the layer cords?
Thanks and I hope that makes sense.
Posts: 4
Reputation: 183

Post » Thu May 23, 2013 8:58 am

Maybe this will work?

On mouse button released - destroy gui instance - spawn on game layer at mouse-x mouse-y.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
Posts: 6,157
Reputation: 19,744

Post » Thu May 23, 2013 2:23 pm

There is a system expression to convert the layer X, Y coordinates to the viewport coordinates...

or maybe adding "(layer number)" to your mouse X, Y will be better for you...


place object at mouse.X(0) mouse.Y(0) will place an object at layer 0 mouse X, Y,

place object at mouse.X(1) mouse.Y(1) will place it on layer 1 mouse X, Y coordinates...

Hope that helps...
As long as I can move left, right and fire, I'm Happy...
Posts: 655
Reputation: 12,235

Post » Fri May 24, 2013 12:41 am

Thanks for the replies. I solved it with touch.x and touch.y . Those are getting the layer coordinates but the mouse format you posted is very useful! I was unaware that I could specify layer number to the command!
Posts: 4
Reputation: 183

Return to How do I....?

Who is online

Users browsing this forum: Colorfish and 21 guests