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

0 favourites
  • 7 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • 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...

    [attachment=0:9vx64xjv][/attachment:9vx64xjv]

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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...

  • 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.

  • 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...

  • 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!

    I added another "Dragging" layer, just under the HUD, but above all other layers with 100/100 parallax. It's working now.

  • 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[attachment=0:fqfm07ll][/attachment:fqfm07ll] You can use a similar formula for your picking.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)