Type Function Object ParticleSystem Library physics.* Return value Array Revision Release 2024.3703 Keywords queryRegion, physics, LiquidFun See also physics.newParticleSystem() object:rayCast()
This function is used to find the particles that intersect with an
This function returns an array of tables describing each hit. The positions returned are in content space.
ParticleSystem:queryRegion( upperLeftX, upperLeftY, lowerRightX, lowerRightY, hitProperties )
Number. The upper-left x coordinate for the box region.
Number. The upper-left y coordinate for the box region.
Number. The lower-right x coordinate for the box region.
Number. The lower-right y coordinate for the box region.
Table. Table of optional properties which can be applied to each particle in the region. Acceptable options include:
deltaX
— The x position delta to apply to each particle.deltaY
— The y position delta to apply to each particle.velocityX
— The x velocity to apply to each particle.velocityY
— The y velocity to apply to each particle.deltaVelocityX
— The x velocity delta to apply to each particle.deltaVelocityY
— The y velocity delta to apply to each particle.hits
will be an array of elements containing these properties:
x
— The x position of the particle in content space.y
— The y position of the particle in content space.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