onTap() Weirdness

This is a very basic program that demonstrates the onTap capabilities of an EDGE device. Tap the screen and it simply displays on the top, the X/Y coordinates of the tap location. And it is SUPPOSED to create a diminishing radar point where you tapped, in red. It should display a red circle with radius 15, then 10, and then a filled red circle with radius 5, then disappear.

Except for some unknown (to me) reason, it does not display the radius 15 view. It does print the radius 15 iteration to the console. I'm stumped. Why is drawCircle not working on the first iteration? I'm sure there is a simple explanation. Anyone care to take a quick look and/or run this in your simulator? Edge 820 or 1030 will show the issue.

CODE: (I can't put code in this post - I get a JSON error, so here it is)

https://docs.google.com/document/d/1...it?usp=sharing
  • If you add debug statements to onTap() and onUpdate(), you'll find that onUpdate() is triggered immediately after onTap(), as well as during the normal 1-second cycle:
    System.println("onTap now = " + System.getTimer());
    //...
    System.println("onUpdate now = " + System.getTimer());



    onUpdate now = 1537662906
    onTap now = 1537663875
    onUpdate now = 1537663875
    CIRCLE: 85/286 == 15
    onUpdate now = 1537663906
    CIRCLE: 85/286 == 10
    onUpdate now = 1537664906
    CIRCLE: 85/286 == 5
    onUpdate now = 1537665906


    So the first thing you draw in onUpdate is wiped out by the next call to onUpdate and is probably never drawn at all, since there's only 31 milliseconds between the two onUpdates. You should do a no-op for your first "iteration" of didTap, or alternatively, if you want to draw the circle right away to make it seem more responsive (which I'm sure is the point of onUpdate being called right after onTap()), make sure that each circle is drawn for at least one second

    BTW, I recommend using https://www.pastebin.com/ for sharing code. It has syntax highlighting (you can use Javascript for Monkey C) and it's perfect for sharing any kind of plain text.
  • THANK YOU!!!!! this forum rocks!