Translating touches?

I’m reworking some UI pieces so that they correctly support various display modes. The neatest way I found to do this was to use translate. That way I can just change the coordinates on one framing element and draw everything else against that boundary. It turns my UI into movable, resizable tiles that I can arrange depending on screen space.

It works great for drawing BUT, the elements and sub-elements of the UI are heavily dependent on passing around a touch element and letting each piece respond appropriately. And I can’t seem to translate touch.

Even if I copy CurrentTouch into another touch instance, it won’t let me alter the values of x and y.

Is there any way out of this short of breaking down touch into it’s values and passing them all individually?

t = vec2(touch.x, touch.y) and pass t around? Or some other {} variable that contains what you want?

Or I don’t understand the question.

I can certainly pass the coordinates, but I also need to pass state, delta, and tap count.

So what I’m asking I guess is “is there a way to translate the coordinates in the touch so I don’t have to change the interface on a hundred different functions.”

@Mark maybe you could create your own class with the exact same interface, then translate it once into that class and pass it on as if it’s a regular touch.

E.g.

MutableTouch = class()

function MutableTouch:init( touch )
    self.x = touch.x
    self.y = touch.y
    -- and so on...
end

-- Any other functions you need

@Mark, I’ve run into this exact question before. My solution was to write a function touch.translate(dx,dy) that returns a table that has exactly the same keys as the “touch” userdata but with x and y translated. This table is treated in my code everywhere exactly as if it were a touch.

Ah, cool. I knew someone would have a slick answer. Thanks!

Side note: Are you releasing a Cidea UI or is it only for Spritely (which I absolutely love).

I’m just working on Spritely, but the bits (buttons, sliders, etc) are designed to be usable elsewhere.

Cool. I really liked your sliders. I forgot to mention that.