Total Pageviews

Monday, April 21, 2014

physics.queryRegion()

physics.queryRegion()
សំរាប់ហ្វាំងសិននេះប្រើក្នុងការស្វែងរក Object ដែលមាន intersect ជាមួយនឹង​ an axis-aligned (non-rotated) box។ សំរាប់ទីតាំងត្រឡប់ជា Content space
Syntax:
local hits = physics.queryRegion( box_upper_left_x, box_upper_left_y, box_lower_right_x, box_lower_right_y )
from_x (required)
from_y (required)
to_x (required)
to_y (required)

Result properties
hits will be an array of DisplayObject colliding with the box.
សូមមើលកូដះ
local hits = physics.queryRegion( box_upper_left.x,
                                    box_upper_left.y,
                                    box_lower_right.x,
                                    box_lower_right.y )
if ( hits ) then
    -- There's at least one hit.
    print( "Hit count: " .. tostring( #hits ) )
    -- Output all the results.
    for i,v in ipairs(hits)
    do
        print( "Object position: ", v.x, v.y )
    end
else
    -- There's no hit.
end


No comments:

Post a Comment