In layer Zoom Mouse position do not work

0 favourites
  • 13 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • When using the layer "set scale" action the coordinates for mouse position (x,y) do not match the position where the mouse pointer is on the window.

    I've created a file where doing a left click with the mouse, the game marks a position and places a sprite (sprite2) where another sprite will move using bullet behaviour.

    In scale 1 the "sprite2" is placed exactly where the mouse pointer is, but in scale 0.5 or 1.5 or above the "sprite2" is placed off the mouse pointer position.

    You can download the Scout.capx file from regimientosdeamerica.com/bug

    Regards

    Daniel

  • I already had this problem and asked in the forum, but ok that was 2 weeks ago, it might be hard to find.

    The issue is logical, because coordinates get scale in the layer (to conserv relative position between elements).

    I was surprised by the answer 'cause it looked like a hidden feature of c2 and is actually quite interesting.

    If you want the mouse position projected on the layer that is scaled :

    Mouse.X("layerName") or Mouse.X(layerNumber) (same for Y of course)

  • As Yann has said, there is an undocumented method to get the correct co-ordinates. In your case, change condition 2 to:

    Sprite2 - Set Position to (Mouse.X(1), Mouse.Y(1))

    and it should be OK.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank guys!!!

  • Thanks guys, I really need this. <img src="smileys/smiley32.gif" border="0" align="middle" />

  • Interesting. This should be added to docs about layer scale!

  • amishstripclub: It is documented in the mouse plugin documentation.

  • Oh thank you sweet merciful god!

    I've been killing myself trying to figure this issue out for days. Finally found that the issue was caused by the mouse position discrepancy during scale/zoom. I was trying to find a work around and finally found this thread which has completely solved the problem!

    THANK YOU!

  • I test the method using touch plugin and it works the same:

    Sprite | set position to ( Touch.X(0), Touch.Y(0) )

    Really useful trick to handle cursor object in touch device.

  • Had the same problem. Helped a lot!

  • Bless your hearts for this. I was racking my brain trying to get the mouse to align to the scale factor of the layer!

  • Spot on! That's what I'm looking for! This is really a hidden gem

  • One spend evening & all morning trying to find solution on this. He wrote horrible pieces of math in tight dialogue windows just to find out that all he had to do is write layer in brackets.

    After finding this post he was so happy that he had his soul separated from the body and now he writes about this in third person.

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