Chipmunk2D Pro API Reference  7.0.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Instance Methods | Properties | List of all members
ChipmunkMultiGrab Class Reference

Simple class to implement multitouch grabbing of physics objects. More...

#import <ChipmunkMultiGrab.h>

Inherits NSObject.

Instance Methods

(id) - initForSpace:withSmoothing:withGrabForce:
 space is the space to grab shapes in. More...
 
(ChipmunkGrab *) - beginLocation:
 Start tracking a new grab point Returns the ChipmunkGrab that is tracking the touch, but only if a shape was grabbed. More...
 
(ChipmunkGrab *) - updateLocation:
 Update a grab point. More...
 
(ChipmunkGrab *) - endLocation:
 End a grab point. More...
 

Properties

cpShapeFilter filter
 Layers used for the point query when grabbing objects.
 
cpGroup group
 Group used for the point query when grabbing objects.
 
bool(^ grabFilter )(ChipmunkShape *shape)
 Gives you the opportunity to further filter shapes. More...
 
cpFloat(^ grabSort )(ChipmunkShape *shape, cpFloat depth)
 When clicking on a spot where two shapes overlap, the default behavior is to grab the shape that overlaps the grab point the most. More...
 
cpFloat grabFriction
 Amount of friction applied by the touch. More...
 
cpFloat grabRotaryFriction
 The amount torque to apply to the grab to keep it from spinning. More...
 
cpFloat grabRadius
 On a touch screen, a single point query can make it really hard to grab small objects with a fat finger. More...
 

Detailed Description

Simple class to implement multitouch grabbing of physics objects.

Method Documentation

- (ChipmunkGrab *) beginLocation: (cpVect pos

Start tracking a new grab point Returns the ChipmunkGrab that is tracking the touch, but only if a shape was grabbed.

Returns nil when creating a push shape (if push mode is enabled), or when no shape is grabbed.

- (ChipmunkGrab *) endLocation: (cpVect pos

End a grab point.

Returns the ChipmunkGrab that was tracking the touch, but only if the grab was tracking a shape.

- (id) initForSpace: (ChipmunkSpace *)  space
withSmoothing: (cpFloat smoothing
withGrabForce: (cpFloat grabForce 

space is the space to grab shapes in.

smoothing is the amount of mouse smoothing to apply as percentage of remaining error per second. cpfpow(0.8, 60) is a good starting point that provides fast response, but smooth mouse updates. force is the force the grab points can apply.

- (ChipmunkGrab *) updateLocation: (cpVect pos

Update a grab point.

Returns the ChipmunkGrab that is tracking the touch, but only if the grab is tracking a shape.

Property Documentation

- (bool(^ grabFilter)(ChipmunkShape *shape))
readwritenonatomiccopy

Gives you the opportunity to further filter shapes.

Return FALSE to ignore a shape. The default implementation always returns TRUE.

- (cpFloat) grabFriction
readwritenonatomicassign

Amount of friction applied by the touch.

Should be less than the grabForce. Defaults to 0.0.

- (cpFloat) grabRadius
readwritenonatomicassign

On a touch screen, a single point query can make it really hard to grab small objects with a fat finger.

By providing a radius, it will make it much easier for users to grab objects. Defaults to 0.0.

- (cpFloat) grabRotaryFriction
readwritenonatomicassign

The amount torque to apply to the grab to keep it from spinning.

Defaults to 0.0.

- (cpFloat(^ grabSort)(ChipmunkShape *shape, cpFloat depth))
readwritenonatomiccopy

When clicking on a spot where two shapes overlap, the default behavior is to grab the shape that overlaps the grab point the most.

It's possible to use a custom sorting order instead however. The block is called with each shape and the grab depth. It should return a positive float. The shape with the highest value is grabbed. The block is only called if the touch location is within a shape.


The documentation for this class was generated from the following file: