Skip to first unread message

clara zhang

unread,
May 13, 2019, 10:38:22 AM5/13/19
to MIT App Inventor Forum
The screen is suppose to display an arrow (up, down, left, right). If you swipe within the directional degree range corresponding to the arrow direction, the image will change to another arrow. The problem is that only the up (45 to 135 degrees) swipe is working, while the other directions are not and I don't know why. My understanding is that 0 degrees is right, 90 is up, 180 is left, 270 is down. I've also tried using absolute values but that didn't work either. The screenshot above is a picture of my code.

Screenshot (2).png

ABG

unread,
May 13, 2019, 2:59:30 PM5/13/19
to MIT App Inventor Forum
See the attached fix.  
The broken range needs an or test.

Your swipe range (0-359 is right (see 
Flung(number x, number y, number speed, number heading, number xvel, number yvel, boolean flungSprite)
When a fling gesture (quick swipe) is made on the canvas: provides the (x,y) position of the start of the fling, relative to the upper left of the canvas. Also provides the speed (pixels per millisecond) and heading (0-360 degrees) of the fling, as well as the x velocity and y velocity components of the fling's vector. The value "flungSprite" is true if a sprite was located near the the starting point of the fling gesture.
)

 According to the Heading definitions at
Heading

Returns the sprite's heading in degrees above the positive x-axis. Zero degrees is toward the right of the screen; 90 degrees is toward the top of the screen.


the rest of your comparisons are correct.

You did not show the rest of your code,
and we can't check if your images match their names.

ABG

 
Screenshot (2).png

ABG

unread,
May 13, 2019, 3:03:39 PM5/13/19
to MIT App Inventor Forum
P.S. For debugging, add a Label and in the Flung event
set the Label.Text to the direction.
That should help see what's going on.

ABG

Reply all
Reply to author
Forward
0 new messages