Calculating mouse XY offset when zoomed?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Using complex softwares zoom shader, mouse coordinates gets offset when zooming in and I can't figure out a formula to correct it (and no, moving the object to a non zoomable layer won't cut it).
    Could anyone please help?

    I think these guys ([mention]schrodinger[/mention]) managed to figure it out in this old thread but I still don't understand using the examples in there.
    Please login to see this link.

  • What you need to do is find the centre of the screen. This can be done with:

    X Left Frame / 2 + X Right Frame / 2
    and
    Y Top Frame / 2 + Y Bottom Frame / 2

    With this, you can subtract the centre from the current position of the cursor, which now allows for the cursor to be zoomed in and out just like the screen.
    The final repositioning equation looks like this:

    Centre + (Cursor - Centre) / Zoom

    Check the mfa out: Please login to see this attachment.

    Edit: You might want to mess around when you center the frame, because at some configurations the mouse lags one frame behind when the screen moves (currently in the above mfa)

    - BartekB

    Join the Click Converse Discord! - Please login to see this link.

    Edited once, last by BartekB (December 30, 2020 at 9:47 PM).

  • You are moving the zoom center by setting fZoomX and fZoomY. The expression X Left Frame / 2 + X Right Frame / 2 stands for the middle of the screen i.e. 0.5, so if fZoomX/fZoomY isn't set to that value, that will no longer work. What you're looking for is interpolation:

    X Left Frame + (X Right Frame - X Left Frame) * fZoomX

    With this the center changes with fZoomX/Y, so now you should be able to reuse the previous expression:

    Centre + (Cursor - Centre) / Zoom

    Please login to see this attachment.

    - BartekB

    Join the Click Converse Discord! - Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!