In layer Zoom Mouse position do not work

Bugs will be moved here once resolved.

Post » Tue Nov 01, 2011 7:06 pm

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 http://www.regimientosdeamerica.com/bug/

Regards

Daniel
B
12
S
2
G
2
Posts: 28
Reputation: 1,695

Post » Fri Nov 04, 2011 8:06 am

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)
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Nov 04, 2011 8:13 am

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.

If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,843
Reputation: 48,287

Post » Fri Nov 04, 2011 9:32 am

Thank guys!!!
B
12
S
2
G
2
Posts: 28
Reputation: 1,695

Post » Wed May 29, 2013 8:31 pm

Thanks guys, I really need this.
B
41
S
9
G
4
Posts: 100
Reputation: 6,211

Post » Thu Jul 18, 2013 2:13 pm

Interesting. This should be added to docs about layer scale!
B
8
S
1
Posts: 31
Reputation: 598

Post » Thu Jul 18, 2013 5:21 pm

@amishstripclub: It is documented in the mouse plugin documentation.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Tue Sep 10, 2013 6:18 am

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!

B
5
Posts: 8
Reputation: 341

Post » Wed Jun 10, 2015 4:20 am

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.
ImageImageImage
B
79
S
33
G
16
Posts: 597
Reputation: 16,157

Post » Tue Jul 14, 2015 1:56 am

Had the same problem. Helped a lot!
B
17
S
4
G
5
Posts: 41
Reputation: 4,254

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests