B2.DistanceJoint:setFrequency
From GiderosMobile
Available since: Gideros 2011.6
Class: b2.DistanceJoint
Description
Sets the mass-spring-damper frequency in Hertz, that is the speed of oscillation also known as the harmonic motion.
b2.DistanceJoint:setFrequency(frequency)
Parameters
frequency: (number) the mass-spring-damper frequency in Hertz (usually between 1 and 5)
Example
This is some code from an actual game ;-)
self.body.ground = self.world:createBody({})
if g_currentlevel == 1 then
self.body.ground:setPosition(xposx, xposy)
local jointDef = b2.createDistanceJointDef(self.body.ground, self.body, xposx, xposy - 128, xposx, xposy)
self.body.joint = self.world:createJoint(jointDef)
self.body.joint:setDampingRatio(0.5)
self.body.joint:setFrequency(1.2)
end