physics_fixture_set_density


描述

The density of something is defined as its mass per unit volume, which basically means how much mass is crammed into the space it takes up in the world. 所以气球的密度很小,因为它的质量很小,占据很大的空间,而铅棒的密度很高,因为它的质量很大,而且空间很小。

In the GameMaker Studio 2 2D physics world mass is calculated automatically for you from the values you input for the density and by the surface area of the shape you define for the fixture. 这将直接影响固定装置具有多少惯性以及如何对碰撞和力产生反应,因此,如果你制造出高密度的小形状,则会产生非常大的质量效应(如铅棒)但是如果你定义了一个较小密度的大形状,那么它的质量效应会更小(像一个气球)。

NOTE: If you wish the instance that is going to receive the fixture to be static (ie: immobile in the game world) then the density should be set to 0, essentially giving it an infinite density.


语法:

physics_fixture_set_density(fixture, density)

参数 描述
fixture the index of the fixture
density the density of the fixture calculated as kg/m²


返回:

N/A(无返回值)


例如:

physics_fixture_set_density(fix_Balloon, 0.1);

The code above will set the density of the fixture indexed in "fix_Ballon" to 0.1.