Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

TapStream: usable in place of CurrentTouch, and more

edited May 14 in Code Sharing Posts: 1,277

I was told a while ago that accessing CurrentTouch from inside draw() was kind of a no-no, so I made this as a small stand-alone class that can stand in for CurrentTouch.

It has a few extra capabilities too: it can easily fetch the most recent n touches for you, and objects can subscribe to it and unsubscribe to it in order to have their own touched(touch) functions called, or not, at will.

Right now it caches all touches starting from program launch, and never clears the cache, I don’t know if that might spell trouble later on. 127.5K


  • Posts: 887

    @UberGoober looks interesting. I’ve found touches quite challenging to use in the past - here is a basic framework I’ve used in a few of my programs. Not updated in a while and I think some of the new functions have probably superseded this

  • edited May 13 Posts: 1,277

    @West I love it! Very useful for analyzing touch behavior.

    I intended my code for a very specific purpose, because a criticism of my SimpleButtons UI system was that it relies on using CurrentTouch in its draw() functions, and I wanted to make something that would serve the same purpose but be kosher, so to speak.

    Another intended use of TapStream is to help people avoid having so much code in the Main tab’s touched(touch) function; it’s probably a pipe dream that anyone will use it, but at lest it’s there to be used now.

  • Posts: 887

    @UberGoober great - I can see it being useful

  • Posts: 193

    @UberGoober I can add it as our first library project on WebRepo if you want? :)

  • Posts: 1,277
    @Steppers i’ll leave it in your hands as to whether or not it’s worth posting. It does run on its own, though, so does that still mean it should be classified as library?
  • edited May 14 Posts: 2,348
    @West - tried to load touch tracker but found no icon whilst sharing and can't find it in my project page.

    Edit: Ignore that worked when I shut down and restarted Codea.
Sign In or Register to comment.