physics_fixture_set_chain_shape

This function sets the shape of the fixture to that of a chain.

Syntax:

GML Code Example

physics_fixture_set_chain_shape(fixture, loop)


Argument Description
fixture The index of the fixture
loop Whether to close the chain (true) or not (false).


Returns: N/A


Description

This function defines a "chain" fixture shape. A chain fixture is comprised of a number of points, which are then connected together using edge shapes to join them. The function itself takes the index (ID) of the fixture and can tell the fixture to loop or not. Setting this to true will connect the last point to the first point with an edge, while setting it to false will not. Note that this function on prepares the fixture to accept the points required to make the chain, and these should be added after calling this function using physics_fixture_add_point, much as you would when building a polygon fixture.

When creating a chain fixture, you must give it at least two points but you are not limited in the number of subsequent points that you can add to make up the finished fixture.


Example:

GML Code Example

var xx = -100;
 var yy = room_height / 2;
 var fix = physics_fixture_create(); physics_fixture_set_chain_shape(fix, false);
 for (var i = 0; i < 10; i++;)
    {
    physics_fixture_add_point(fix, xx, yy);
    xx += 50 + random(150);
    yy = (room_height / 2) - 250 + irandom(500);
    }
 physics_fixture_bind(fix, id);
 

The above code will create a line of "edge" fixtures with a variety of heights over the length of the room.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here