Input action moved feature

Hi, I am @Grass_dev

I would like to suggest that please make action.moved script for users…

thank you…

You can do something like:

local offset_x = 0
local previous_x = nil

In on_input

if action.repeated or action.pressed then
    local current_mouse_x = action.x
    offsetx =  (offsetx + current_mouse_x - (previous_x or current_mouse_x))
    --Set limits if necessary
    --offsetx is the change in coordinate x between action.pressed and action.released
end
if action.released then
    previous_x = nil
end

You can replace the coordinate with y or track both

3 Likes

We already have action.dx and action.dy to give you the delta movement of an input (e.g. mouse or touch). Documentation.

If that doesn’t work for you, please explain a bit further for us to understand your use case better.

5 Likes

No, It works well…
But I think if you make this feature relative to the engine like corona sdk, the users can easily manage their input actions…