Core: Touch event xDelta and yDelta Fixes#525
Core: Touch event xDelta and yDelta Fixes#525scottrules44 wants to merge 3 commits intocoronalabs:masterfrom
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 )
endAnd 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 :) ? |
|
Any updates on this pull? Thanks. |
Addresses #269