Love2D APIFixtureOn this pageFixture Description: Fixtures attach shapes to bodies. type Type: Function. Description: Gets the type of the object as a string. Signature: type: function(self: Fixture): string Returns: Return TypeDescriptionstringThe type as a string. Of Type: Function. Description: Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true. Signature: typeOf: function(self: Fixture, type_name: string): boolean Parameters: ParameterTypeDescriptiontype_namestringThe name of the type to check for. Returns: Return TypeDescriptionbooleanTrue if the object is of the specified type, false otherwise. release Type: Function. Description: Destroys the object's Lua reference. The object will be completely deleted if it's not referenced by any other LÖVE object or thread. This method can be used to immediately clean up resources without waiting for Lua's garbage collector. Signature: release: function(self: Fixture): boolean Returns: Return TypeDescriptionbooleanTrue if the object was released by this call, false if it had been previously released. destroy Type: Function. Description: Destroys the fixture. Signature: destroy: function(self: Fixture) isDestroyed Type: Function. Description: Gets whether the Fixture is destroyed. Destroyed fixtures cannot be used. Signature: isDestroyed: function(self: Fixture): boolean getType: function(self: Fixture): string Returns: Return TypeDescriptionboolean or stringWhether the Fixture is destroyed. setFriction Type: Function. Description: Sets the friction of the fixture. Friction determines how shapes react when they 'slide' along other shapes. Low friction indicates a slippery surface, like ice, while high friction indicates a rough surface, like concrete. Range: 0.0 - 1.0. Signature: setFriction: function(self: Fixture, friction: number) Parameters: ParameterTypeDescriptionfrictionnumberThe fixture friction. getFriction Type: Function. Description: Returns the friction of the fixture. Signature: getFriction: function(self: Fixture): number Returns: Return TypeDescriptionnumberThe fixture friction. setRestitution Type: Function. Description: Sets the restitution of the fixture. Signature: setRestitution: function(self: Fixture, restitution: number) Parameters: ParameterTypeDescriptionrestitutionnumberThe fixture restitution. getRestitution Type: Function. Description: Returns the restitution of the fixture. Signature: getRestitution: function(self: Fixture): number Returns: Return TypeDescriptionnumberThe fixture restitution. setDensity Type: Function. Description: Sets the density of the fixture. Call Body:resetMassData if this needs to take effect immediately. Signature: setDensity: function(self: Fixture, density: number) Parameters: ParameterTypeDescriptiondensitynumberThe fixture density in kilograms per square meter. getDensity Type: Function. Description: Returns the density of the fixture. Signature: getDensity: function(self: Fixture): number Returns: Return TypeDescriptionnumberThe fixture density in kilograms per square meter. setSensor Type: Function. Description: Sets whether the fixture should act as a sensor. Sensors do not cause collision responses, but the begin-contact and end-contact World callbacks will still be called for this fixture. Signature: setSensor: function(self: Fixture, sensor: boolean) Parameters: ParameterTypeDescriptionsensorbooleanThe sensor status. isSensor Type: Function. Description: Returns whether the fixture is a sensor. Signature: isSensor: function(self: Fixture): boolean Returns: Return TypeDescriptionbooleanIf the fixture is a sensor. getBody Type: Function. Description: Returns the body to which the fixture is attached. Signature: getBody: function(self: Fixture): Body Returns: Return TypeDescriptionBodyThe parent body. getShape Type: Function. Description: Returns the shape of the fixture. This shape is a reference to the actual data used in the simulation. It's possible to change its values between timesteps. Signature: getShape: function(self: Fixture): Shape Returns: Return TypeDescriptionShapeThe fixture's shape. testPoint Type: Function. Description: Checks if a point is inside the shape of the fixture. Signature: testPoint: function(self: Fixture, x: number, y: number): boolean Parameters: ParameterTypeDescriptionxnumberThe x position of the point.ynumberThe y position of the point. Returns: Return TypeDescriptionbooleanTrue if the point is inside or false if it is outside. rayCast Type: Function. Description: Casts a ray against the shape of the fixture and returns the surface normal vector and the line position where the ray hit. If the ray missed the shape, nil will be returned. The ray starts on the first point of the input line and goes towards the second point of the line. The fifth argument is the maximum distance the ray is going to travel as a scale factor of the input line length. The childIndex parameter is used to specify which child of a parent shape, such as a ChainShape, will be ray casted. For ChainShapes, the index of 1 is the first edge on the chain. Ray casting a parent shape will only test the child specified so if you want to test every shape of the parent, you must loop through all of its children. The world position of the impact can be calculated by multiplying the line vector with the third return value and adding it to the line starting point. hitx, hity = x1 + (x2 - x1) * fraction, y1 + (y2 - y1) * fraction Signature: rayCast: function(self: Fixture, x1: number, y1: number, x2: number, y2: number, max_fraction: number, child_index?: integer): number | nil, number | nil, number | nil Parameters: ParameterTypeDescriptionx1numberThe x position of the input line starting point.y1numberThe y position of the input line starting point.x2numberThe x position of the input line end point.y2numberThe y position of the input line end point.max_fractionnumberRay length parameter.child_indexintegerThe index of the child the ray gets cast against. (Default: 1.) Returns: Return TypeDescriptionnumber or nilThe x component of the normal vector of the edge where the ray hit the shape.number or nilThe y component of the normal vector of the edge where the ray hit the shape.number or nilThe position on the input line where the intersection happened as a factor of the line length. setFilterData Type: Function. Description: Sets the filter data of the fixture. Groups, categories, and mask can be used to define the collision behaviour of the fixture. If two fixtures are in the same group they either always collide if the group is positive, or never collide if it's negative. If the group is zero or they do not match, then the contact filter checks if the fixtures select a category of the other fixture with their masks. The fixtures do not collide if that's not the case. If they do have each other's categories selected, the return value of the custom contact filter will be used. They always collide if none was set. There can be up to 16 categories. Categories and masks are encoded as the bits of a 16-bit integer. When created, prior to calling this function, all fixtures have category set to 1, mask set to 65535 (all categories) and group set to 0. This function allows setting all filter data for a fixture at once. To set only the categories, the mask or the group, you can use Fixture:setCategory, Fixture:setMask or Fixture:setGroupIndex respectively. Signature: setFilterData: function(self: Fixture, category_bits: integer, mask_bits: integer, group_index: integer) Parameters: ParameterTypeDescriptioncategory_bitsintegerThe categories as an integer from 0 to 65535.mask_bitsintegerThe mask as an integer from 0 to 65535.group_indexintegerThe group as an integer from -32768 to 32767. getFilterData Type: Function. Description: Returns the filter data of the fixture. Categories and masks are encoded as the bits of a 16-bit integer. Signature: getFilterData: function(self: Fixture): integer, integer, integer Returns: Return TypeDescriptionintegerThe categories as an integer from 0 to 65535.integerThe mask as an integer from 0 to 65535.integerThe group as an integer from -32768 to 32767. setCategory Type: Function. Description: Sets the categories the fixture belongs to. There can be up to 16 categories represented as a number from 1 to 16. -- All fixture's default category is 1. Signature: setCategory: function(self: Fixture, categories: {number}) Parameters: ParameterTypeDescriptioncategories{number}The categories. setCategory Type: Function. Description: Sets the categories the fixture belongs to. There can be up to 16 categories represented as a number from 1 to 16. -- All fixture's default category is 1. Signature: setCategory: function(self: Fixture, categories: number...) Parameters: ParameterTypeDescriptioncategoriesnumber...The categories. getCategory Type: Function. Description: Returns the categories the fixture belongs to. Signature: getCategory: function(self: Fixture): integer... Returns: Return TypeDescriptioninteger...The categories. setMask Type: Function. Description: Sets the category mask of the fixture. There can be up to 16 categories represented as a number from 1 to 16. -- This fixture will '''NOT''' collide with the fixtures that are in the selected categories if the other fixture also has a category of this fixture selected. Signature: setMask: function(self: Fixture, categories: {number}) Parameters: ParameterTypeDescriptioncategories{number}The masks. setMask Type: Function. Description: Sets the category mask of the fixture. There can be up to 16 categories represented as a number from 1 to 16. -- This fixture will '''NOT''' collide with the fixtures that are in the selected categories if the other fixture also has a category of this fixture selected. Signature: setMask: function(self: Fixture, categories: number...) Parameters: ParameterTypeDescriptioncategoriesnumber...The masks. getMask Type: Function. Description: Returns which categories this fixture should '''NOT''' collide with. Signature: getMask: function(self: Fixture): integer... Returns: Return TypeDescriptioninteger...The masks. setUserData Type: Function. Description: Associates a Lua value with the fixture. To delete the reference, explicitly pass nil. Signature: setUserData: function(self: Fixture, value: any) Parameters: ParameterTypeDescriptionvalueanyThe Lua value to associate with the fixture. getUserData Type: Function. Description: Returns the Lua value associated with this fixture. Signature: getUserData: function(self: Fixture): any Returns: Return TypeDescriptionanyThe Lua value associated with the fixture. getBoundingBox Type: Function. Description: Returns the points of the fixture bounding box. In case the fixture has multiple children a 1-based index can be specified. For example, a fixture will have multiple children with a chain shape. Signature: getBoundingBox: function(self: Fixture, child_index?: integer): number, number, number, number Parameters: ParameterTypeDescriptionchild_indexintegerA bounding box of the fixture. (Default: 1.) Returns: Return TypeDescriptionnumberThe x position of the top-left point.numberThe y position of the top-left point.numberThe x position of the bottom-right point.numberThe y position of the bottom-right point. getMassData Type: Function. Description: Returns the mass, its center and the rotational inertia. Signature: getMassData: function(self: Fixture): number, number, number, number Returns: Return TypeDescriptionnumberThe x position of the center of mass.numberThe y position of the center of mass.numberThe mass of the fixture.numberThe rotational inertia. getGroupIndex Type: Function. Description: Returns the group the fixture belongs to. Fixtures with the same group will always collide if the group is positive or never collide if it's negative. The group zero means no group. The groups range from -32768 to 32767. Signature: getGroupIndex: function(self: Fixture): integer Returns: Return TypeDescriptionintegerThe group of the fixture. setGroupIndex Type: Function. Description: Sets the group the fixture belongs to. Fixtures with the same group will always collide if the group is positive or never collide if it's negative. The group zero means no group. The groups range from -32768 to 32767. Signature: setGroupIndex: function(self: Fixture, index: integer) Parameters: ParameterTypeDescriptionindexintegerThe group as an integer from -32768 to 32767.