object:getMassWorldCenter()

Type Function
Object Body
Library physics.*
Return value Numbers
Revision Current Public Release (2017.3068)
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()