objective c - Snap to grid effect with Quartz 2d? iphone dev -


Still trying on an iphone dev starter.

I want the user to see the screen on the screen, which indicates that the pin will be placed on the scene.

I have fulfilled it (yes), but I want to catch hold effect, and can not come with the solution. It is such that I am keeping that dot:

CGPETE Drepount = CP pointmack (lastTouch.x - horizontal offset, last RTO-> vertical offset); [Dryage drawpoint: dropout]; // Tell the image to attract yourself

I have a grid in the background as a view controller, overlapping that grid I have a custom diagram with one UIView is the screen that touches the user every time.

(And for some reasons the user already appears before touching the user ... although this is another query that I am currently seeing)

then grid Snap in effect. any idea?

Assume that your method faucets the user, and then the nearest grid intersection of the pin, this basic form There is only one spherical problem.

  // The constant value / kVGridOffset, kHGridOffset: the difference between the visible root // and the grid / / KVGridSpacing, kHGridSpacing: Set the initial coordinate from the grid size / set CGPoint drawpoint = CGPointMake (lastTouch.x - horizontal offset, last RTOI - vertical offset); // remove the offset, circle the distance of the nearest distance, and the offset dot.or ((DrawPoint.x - kHGridOffset) / kHGridSpacing + 0.5) * kHGridSpacing + kHGridOffset; DrawPoint.y = Floor ((DrawPoint.y - kVGridOffset) / KV GridSpacing + 0.5) * KVGridSpacing + KVGreeff Offset; // Drawing Image [Draw IIMAG Drawate Point: Dropout];   

Edit: For availability, with availability availability , things may be slightly lower:

  drawpoint.x = closest ((drawpoint.x - kHGrid offset) / kHGridSpacing) * kHGridSpacing + kHGridOffset; DrawPoint.y = closest ((drawpoint.y - kVGridOffset) / kVGridSpacing) * kVGridSpacing + kVGridOffset;  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -