Hi, I want to make a simple game that the student will estimate the distance showing.
So when Screen initiates will get the initial coordinates (x1,y1) and when the student will press CHECK button will get the second coordinates (x2,y2) and will calculate the distance between the locations.
For some reason the Location Sensor does not get the coordinates when I press the PLAY AGAIN button that should grab new coordinates from new location.
Attached below is the .aia exported project file:
GuestDistance.aia (4.4 KB)
Also have a look at my code (blocks) below:
Any ideas what the fix might be?
SteveJG
November 21, 2024, 2:55pm
2
Welcome.
If you post your Project aia file someone can look at it. Otherwise someone has to type a lot of code to see how your app is supposed to work. Thanks.
The issue is probably how you set your play_again_btn.Enabled . You might not be setting it to true before you use play again.
Taifun
November 21, 2024, 3:01pm
3
To help debugging display the 4 lat long values in labels
Are you already familiar with Do ot?
Use the companion app and Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools
Taifun
Trying to push the limits! Snippets , Tutorials and Extensions from Pura Vida Apps by Taifun.
ABG
November 21, 2024, 6:26pm
4
Global init blocks are too early to catch location data, which takes time for the GPS to calculate or for the user to enter into a Text box.
Hi, yes of course. See attached .aia file below
GuestDistance.aia (4.4 KB)
ABG
November 22, 2024, 12:50am
6
Do you own a private jet?
How do you expect to move the phone a sufficient distance to change the latitude and longitude values enough to register a change?
I do not see in your Pythagorean distance formula the shrinkage of distance the nearer you get to the poles.
Latitude and Longitude are measured in degrees (+/- 90 and +/- 180.)
Do you really think the Earth is so small that taking a diagonal of degrees will return such a small number of meters as in your distance formula?