Positioning Object to Touch Position On Non-Parallax Layer Not Working

0 favourites
  • 9 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I'm trying to implement an analog (360° angle only...not "tilt") control for an on-screen touch controller for my game.

    The control "button" (just a flat circle) sits to the left-side of the screen on a 0x0 parallax layer.

    When I use the Touch object condition on the control button, I tell it to position the control button to the Touch X/Y coordinates.

    However, this results in the control button being positioned offset from where I actually touched. So, I tried Touch.AbsoluteX/Y...same difference aside from the control button being positioned differently than simply Touch.X/Y. Meaning...it's still offset from where I actually touched.

    I have a feeling that the parallax of the layer the control button is on has something to do with it but I cannot figure out a solution. Can someone help me understand why this is happening, please?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Check your origin imagepoint on your controller's sprite object, to see if it is actually in the middle. If it is off to one side, when you position it, the image will appear of to the side as well.

  • It's definitely centered. In this issue, the whole object, when positioned per the current setup, the object isn't within the Touch vicinity at all. I'll get a video shot later today...

  • Are you using the viewporttop/left(layer) expressions to position your hud on the correct layer?

    Rather than a video of the problem, it would be more helpful to see the events and project properties. Isolated, if possible.

  • To answer your question, no I haven't been using the ViewportTop/Left expressions. My mind is drawing a blank - how would you employ them according to what you're thinking?

    So this is the only event line I'm using so far. As mentioned, I've tried using Touch.X and Touch.AbsoluteX (the difference being the distance the Button_Alog_Stick object is positioned away from the Touch coordinate.

    Here is the layout with the Button_Alog_Stick object highlighted.

    And finally, the Buttons_Steal layer highlighted.

  • are you using scale outer? when you do, the top left corner of the screen may not be 0,0. That is why oosyrag was asking about using viewport top and left.

    also, when using Touch.X and Touch.Y you can specify the layer to read from Touch.X(Buttons_Steal) Touch.Y(Buttons_Steal)

    that will eliminate any parallax trouble.

  • Nope. Not using Scale Outer. Just Letterbox Scale.

    But the Layer reference for Touch wasn't something I was aware you could do! I'll give that a try...

  • Well, HAWT DAWG, AllanR, you are a life-saver! That did the trick! Thank you so much!

  • And oosyrag, thank you, too for your effort to help me narrow down the problem!

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