Hello I am having a serious problem with touch positions being offset whilst zoomed in.
The touch coordinates are really offset and making it very hard to drag an object whilst zoomed in.
The code i am using to zoom in is below (all objects including what i am trying to drag are included in localGroup) and i am using the standard drag code from the tutorials. I presume this is just a math issue and it needs to account for an offset when zoomed ?
1 | transition.to(localGroup, {x = localGroup.x - dragTarget.x, y = localGroup.y - dragTarget.y, xScale = 2.0, yScale = 2.0, delay = 200}) |
how much objects are in localGroup
have u chked the fps plz chk i doubt its going very very down
in case u don't know how to see fps
http://developer.anscamobile.com/code/output-fps-and-texture-memory-usage-your-app
:)
Why would it matter how many objects are in the localGroup? The problem is the offset. I just don't know what the offset should be. It's running at 60fps…
as i had said that's only my doubt i had think fps is very low say for example 5-6 at the time of zooming but good that's only my doubt
:)
Anyone have any ideas on this?
My game is ready to be released barring this issue. Willing to pay a small fee for a fix.
Thank you
After all inserts on the localGroup, put this:
localGroup:setReferencePoint(display.CenterReferencePoint)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | local x = 0 local y = 0 local a = display.newCircle(40,40,40) a.x = 150 a.y = 150 local f = function (e) if e.phase == "moved" then e.target.parent.x = e.x e.target.parent.y = e.y x = e.x y = e.y end end local g = display.newGroup() g:insert(a) g:setReferencePoint(display.CenterReferencePoint) a:addEventListener("touch", f) transition.to(g, {x = g.x - x, y = g.y - y, xScale = 2.0, yScale = 2.0, delay = 200}) |
look at "contentToLocal" and "localToContent" in your display group and all your problems will be solved... :)