B2.DistanceJoint:setFrequency: Difference between revisions

From GiderosMobile
No edit summary
m Text replacement - "</source" to "</syntaxhighlight"
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/b2.DistanceJoint|b2.DistanceJoint]]<br/>
'''Class:''' [[b2.DistanceJoint]]<br/>
=== <translate>Description</translate> ===
 
<translate><br />
=== Description ===
Sets the mass-spring-damper frequency in Hertz.<br />
Sets the mass-spring-damper frequency in Hertz, that is the speed of oscillation also known as the harmonic motion.
<br /></translate>
<syntaxhighlight lang="lua">
<source lang="lua">
b2.DistanceJoint:setFrequency(frequency)
b2.DistanceJoint:setFrequency(frequency)
</syntaxhighlight>
</source>
 
=== <translate>Parameters</translate> ===
For a rigid distance joint you would set the frequency equals to 0 and the damping equals to 1.
'''frequency''': (number) <translate>the mass-spring-damper frequency in Hertz</translate> <br/>
 
=== Parameters ===
'''frequency''': (number) the mass-spring-damper frequency in Hertz (usually between 1 and 5)<br/>
 
=== Example ===
'''This is some code from an actual game ;-)'''
<syntaxhighlight lang="lua">
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
</syntaxhighlight>
 
{{B2.DistanceJoint}}

Latest revision as of 16:07, 12 July 2023

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)

For a rigid distance joint you would set the frequency equals to 0 and the damping equals to 1.

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




LiquidFun