Share via


Use the Physics Engine (Compact 2013)

3/26/2014

The following example code shows how the default gesture handler uses the physics engine to process scroll gestures.

#include "physicsengine.h" // under public\common\oak\inc
.
.
.
case GID_SCROLL:
    ProcessFlick((int)GID_SCROLL_VELOCITY(pGestureInfo->ullArguments),
       (int)GID_SCROLL_ANGLE(pGestureInfo->ullArguments) );
.
.
.
HPHYSICSENGINE hPE;
ProcessFlick(TransitionSpeed, TransitionAngle)
{
     PHYSICSENGINEINIT initState; // fill initState with effect desire
     CreatePhysicsEngine(&initState, &hPE);
     SetTimer(NULL, NULL, GESTURE_ANIMATION_FRAME_DELAY_MS,
       AnimationProc);
}

AnimationProc()
{
     PHYSICSENGINESTATE state = {sizeof(state)};
     QueryPhysicsEngine(hPE, &state);
     // Scroll to state.ptPosition.x and state.ptPosition.y
}
.
.
.
DestroyPhysicsEngine(hPE);

See Also

Concepts

Physics Engine