AGK for Pascal
TAgkSprite.SetPhysicsImpulse Method

Similar to a force but applied only once.

procedure SetPhysicsImpulse(const X: Single; const Y: Single; const VX: Single; const VY: Single);
const X: Single 
The X coordinate of the impulse position in world coordinates. 
const Y: Single 
The Y coordinate of the impulse position in world coordinates. 
const VX: Single 
The X component of the impulse direction. 
const VY: Single 
The Y component of the impulse direction. 

Whilst forces are applied continuously over time gradually influencing a sprite's velocity, an impulse simulates the sprite being hit suddenly and immediately changes the velocity with the equivalent power of a similar force applied for 1 second. 

The impulse consists of a point in world coordinates and a direction, if the point and direction are not in line with the sprite's offset point then it will result in a rotation of the sprite as it is moved by the impulse. The length of the impulse vector determines it strength. If the sprite is constrained by surrounding objects it will impart the impulse onto those objects and may not move itself. 

Impulses apply acceleration to an object relative to its mass, heavy objects will move less than light objects with the same impulse applied to them.

Copyright (c) 2012. All rights reserved.