[Solved] Why is this Pick failing when Viewport is scrolled?

Get help using Construct 2

Post » Sun Mar 01, 2015 12:11 am

Why is this Pick-while-dragging-Token working only when Viewport is at 0/0? It Picks Tiles and highlights them as I drag around the Token. However, when I scroll the Viewport, then try to drag a Token, this completely breaks and picks incorrect Tiles...

C2TilePickFailsWhenScrolled.PNG
You do not have the required permissions to view the files attached to this post.
Last edited by locohost on Sun Mar 01, 2015 1:55 pm, edited 1 time in total.
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sun Mar 01, 2015 5:00 am

It sounds like perhaps these obects are on layers with different layer parallax? I know that in my inventory system, Items move between my UI layer and my Game layer, and I have to keep adding and subtracting the viewport coordinates for every transition.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Sun Mar 01, 2015 1:28 pm

That's a very interesting thought I had not considered. Checking now, the parallax is identical on 4 of my 5 layers. The only layer that doesn't have a matching parallax is HUD, which is 0/0, and on top of course so my HUD controls stay visible and in the same position. It would be an awful surprise if the HUD must also be 100/100 to fix this. I will try now...
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sun Mar 01, 2015 1:42 pm

Please ignore this post, see solution below...

Wow, you were right. It's very, very bad that you were right :-(

So it appears you cannot use a stationary (0/0 parallax) HUD layer for your controls.

So unless there is some trick documented in fine print, to use the system-pick-overlapping-at-point function, you cannot have any parallax at all. You will have to add code to the every tick event to reposition your HUD controls.
Last edited by locohost on Sun Mar 01, 2015 1:49 pm, edited 1 time in total.
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sun Mar 01, 2015 1:45 pm

Oh wait!!

I'm momentarily moving the Token up to HUD layer when dragging so it always floats on top of the viewport, then moving it back down to it's Tokens layer on drop. This must be the issue! Testing now...
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sun Mar 01, 2015 1:51 pm

locohost wrote:Oh wait!!

I'm momentarily moving the Token up to HUD layer when dragging so it always floats on top of the viewport, then moving it back down to it's Tokens layer on drop. This must be the issue! Testing now...


@bladedpenguin You actually were right and you solved my problem. Thank you, thank you! :D

I added another "Dragging" layer, just under the HUD, but above all other layers with 100/100 parallax. It's working now.
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sun Mar 01, 2015 2:53 pm

Glad I could give a hand. For reference, if you need to deal with layers that have differing parallax, heres a chunk from my item events. You can see the set position call where I compensate for the fact that neither UI nor Game is centered at 0,0
layertransitionoffsets.png
You can use a similar formula for your picking.
You do not have the required permissions to view the files attached to this post.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536


Return to How do I....?

Who is online

Users browsing this forum: SneakyHands and 7 guests