How do I set angle to Touch X/Y regardless of layer scale

Get help using Construct 2

Post » Tue Aug 04, 2015 5:19 am

Hi Constructors,

I already know how to set an object's angle based on TouchX and TouchY. But the problem is when i'm using Layer.Scale let's say 0.5, the X and Y of touch coordinates are slightly different, thus making the angle pointing misses by some degrees. How to fix this?
B
3
Posts: 5
Reputation: 179

Post » Tue Aug 04, 2015 5:33 am

Risk Rocket now available on Google Play
Image
B
35
S
15
G
6
Posts: 337
Reputation: 6,275

Post » Tue Aug 04, 2015 5:39 am

you need to add the layer's name to the touch x and y reference to get the correct coordinates for the scaled layer.

Touch.X("Layer 0")
Touch.Y("Layer 0")

just replace Layer 0 with the name of your layer...

EDIT: I see Usman Haq beat me to it, however in that thread the suggestion was to use the layer number. Using the layer name is safer because if you add layers later (like another background layer at the bottom), you may break your code because layers will get re-numbered but the name will stay the same.
B
94
S
33
G
20
Posts: 438
Reputation: 17,605


Return to How do I....?

Who is online

Users browsing this forum: khelaghor, R0J0hound and 6 guests