Hello All - I am trying to initialize the position of a sprite based on GPS and then move it as my phone moves. I initialize Xstart and Ystart to the initial GPS location, and also Xnow and Ynow. Then when you hit the start button, it computes an X and Y coordinate for the sprite to start at. It does this correctly, with the initial Xstart and Ystart being equal so the result being pixel 120,120. Then as I move, the timer should update Xnow and Ynow and produce a new pixel location. But for some reason, when the timer fires, Xstart and Ystart become zero even though I have not changed them. Can anyone say why this is and what to do about it? Code here:
Thanks - it always fails (ie changes the values) as soon as the timer fires. I currently have that set for ten seconds so that I have time to observe. Everything is fine up to that point, then the values of Xstart and Ystart are changed to zero for reasons unknown. I need them to stay at their original values (ie where I started) so that I can plot the change in location.
Hi Tom,
looking at your code how can you say that at the beginning xstart and ystart are different from 0 ?
You say : It does this correctly, with the initial Xstart and Ystart being equal so the result being pixel 120,120.
But you initialize both Xstart and Xnow at Longitude and both Ystart, and Ynow at Latitude. Therefore you expect that their difference is 0 leading to the formula 120 + ((30000 * (Xnow- Ystart)) = 120. But this is true also if Xstart is initially = 0.
Then I'am afraid that Xstart is always = 0.
My suggestion is to print Xstart in the Button1 event, to be sure it is not = 0.
The same for Ystart.
What are your thoughts about ?
Cheers!
Well, that is a good suggestion and I will try it but I doubt it is going to work because when the timer fires, the values of Xnow and Ynow are correct, and they are computed the same way. But lets see.....
Yes, I put them inside the start button - at first I got a bad result but then it seems to be resolved. I will experiment some more and see what happens - but GREAT SUGGESTIONS
Sorry not having replied before. My PC has crashed the boot record, so I was not able to use it.
I've changed the broken SSD and now I have recovered, but I have to re-install all.
Thanks Andy, now everything is solved. I've replaced the SSD and I've restored data and app's.
Anyway, I take your advice for future needs .. .
Cheers !