physics_fixture_delete

This function deletes a fixture from memory.

Syntax:

GML Code Example

physics_fixture_delete(fixture)


Argument Description
fixture the fixture that is to be deleted from memory


Returns: N/A


Description

Since once a fixture has been bound to an instance that instance maintains the fixtures properties, we can remove the fixture from memory with this function, particularly if we no longer plan to use it again. Please note that failure to remove fixtures after they are no longer needed may cause a memory leak which will slow down and eventually crash your game, so you should take care to clean up properly after defining and binding fixtures.


Example:

GML Code Example

var fix, inst;
 fix = physics_fixture_create();
 physics_fixture_set_circle_shape(fix, 16);
 physics_fixture_set_density(fix, 1.0);
 inst = instance_create(x, y, genericBodyObject);
 physics_fixture_bind(fix, inst);
 physics_fixture_delete(fix);
 

The code above will create a fixture and assign its index to the variable "fix". It then defines the shape and density of the fixture before binding it to the instance that was created with the index stored in the variable "inst". Finally, the fixture is deleted to prevent memory leaks as it is no longer needed.





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