object:getMassWorldCenter()

Type Function
Object Body
Library physics.*
Return value Numbers
Revision Release 2024.3703
Keywords body, mass, world, center
See also object:getMassLocalCenter()

Overview

A function that returns the x and y components for the body's center of mass in content coordinates.

Syntax

object:getMassWorldCenter()

Example

-- Create a rectangle
local myRect = display.newRect( 0, 0, 100, 100 )

-- Add a body to the rectangle
physics.addBody( myRect, "dynamic" )

-- Get mass world center values
local x, y = myRect:getMassWorldCenter()