-
-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Touch event xDelta and yDelta Fixes #525
base: master
Are you sure you want to change the base?
Conversation
I am worried about this one... It would break existing games, wouldn't it? |
Well, due to the fact that event.xDelta and event.yDelta were implemented wrong, it is most likely they were ignored. A handful of people may have used the delta value and worked around the wrong values. Either way, the values are wrong; I would argue that this fix does way more good than harm. |
Also I scanned all 44 cases publicly available games on Github and non of them should be affected by the change. It will mainly affect games that have implement a crazy workaround get xDelta/yDelta |
I would agree with Scott on this one.
I would be genuinely surprised if anyone was using these properties. As the initial implementation was flawed, these properties gave correct values if and only if the content area perfectly matched the device/window resolution. Given what these properties are mostly used for, any developer would have run into issues with them and they would have either had to fall back to calculating the deltas themselves or writing a workaround. The current way of calculating delta x and delta y in Lua that devs are likely using: local function touchEvent( event )
local dx = event.x - event.xStart
local dy = event.y - event.yStart
print( dx, dy )
end And here's a workaround for using local function touchEvent( event )
local scaleFactor
if string.find( system.orientation, "portrait" ) then
scaleFactor = display.pixelWidth / display.actualContentWidth
else
scaleFactor = display.pixelWidth / display.actualContentHeight
end
local dx = event.xDelta / scaleFactor
local dy = event.yDelta / scaleFactor
print( dx, dy )
end |
Ok. I'll test an merge then |
^Figured out there is a much simpler way to implement, also here attached a demo project you can test with, should compare the values
|
Any updates on this pull @Shchvova :) ? |
Addresses #269