object:getLinearVelocity()

类型 函数
对象 主体
程序库 physics.*
返回值 数字
修订版 发行版 2024.3703
关键词 主体,getLinearVelocity
请参阅 object:setLinearVelocity()

概述

返回主体线性速度的xy分量(单位:像素/秒)的函数。

语法

object:getLinearVelocity()

示例

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

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

-- Start moving the rectangle
myRect:setLinearVelocity( 50, 20 )

-- Get the linear velocity values
local vx, vy = myRect:getLinearVelocity()