类型 函数 对象 粒子系统 库 physics.* 返回值 数组 修订 版本 2024.3703 关键词 queryRegion, physics, LiquidFun 另请参阅 physics.newParticleSystem() object:rayCast()
此函数用于查找与
此函数返回一个描述每次碰撞的表格数组。返回的位置位于内容空间中。
ParticleSystem:queryRegion( upperLeftX, upperLeftY, lowerRightX, lowerRightY, hitProperties )
数字. 盒子区域的左上角 **x** 坐标。
数字. 盒子区域的左上角 **y** 坐标。
数字. 盒子区域的右下角 **x** 坐标。
数字. 盒子区域的右下角 **y** 坐标。
表格. 可应用于区域中每个粒子的可选属性表。可接受的选项包括
deltaX
— 应用于每个粒子的 **x** 位置增量。deltaY
— 应用于每个粒子的 **y** 位置增量。velocityX
— 应用于每个粒子的 **x** 速度。velocityY
— 应用于每个粒子的 **y** 速度。deltaVelocityX
— 应用于每个粒子的 **x** 速度增量。deltaVelocityY
— 应用于每个粒子的 **y** 速度增量。hits
将是一个包含以下属性的元素数组
x
— 粒子在内容空间中的 **x** 位置。y
— 粒子在内容空间中的 **y** 位置。local hits = ParticleSystem:queryRegion( 10, 40, 100, 160, { deltaVelocityY = -40 } --apply delta Y velocity of -40 to each particle in region ) if ( hits ) then -- There's at least one hit print( "Hit count: " .. tostring( #hits ) ) -- Output the results for i,v in ipairs( hits ) do print( "Object position: ", v.x, v.y ) end else -- No hits in region end