Can someone help me make a when pinched code.
Sorry I don’t know that much about code and math but you just came up with an idea for a new block!
This code requires three variables.
One to measure the x position of where you first tap, one to remember the y position of where you first tap, and one to remember the distance from the second tap to the first tap when you first place down your second finger.
It requires three rules:
1 when is tapped.
In here, we have two check once ifs. The first one is if the first variable, the original tap position, is > than zero, set the third variable, the original distance between the two fingers, to the square root of distance x between last touch and first touch, which we can get by doing last touch x - original last touch, the first variable I mentioned, squared plus the same thing for y squared. If the reason this works isn’t clear, check this out:
The second checks if the first variable is zero. If it is, we set the first variable to last touch x and the second variable to last touch y, in order to record the first tap position.
The second rule is when not pressed.
In here we set all three variables to 0.
The third rule is when pressed.
Here we check if the formula we used above to set the third variable is less than the third variable itself. This means your two fingers have gotten closer together.
Here is my project I made:
Awesome! You’ve already solved this.
Thank you peppyWafer21
Could you go on hopscotch and show me the code?
I put a link in that post
The pinch code is inside of Gonzalo.