function GetObjectRectOnWorldSpace( object )
if object == nil then return nil end
local obj = tolua.cast(object, "CCNode")
if obj == nil then return nil end
local x,y = obj:getPosition()
if type(x) == "userdata" then
local pos = x
x = pos.x
y = pos.y
end
local sz = obj:getContentSize()
local scale = obj:getScale()
sz = CCSizeMake(sz.width * scale, sz.height * scale)
local anchor = obj:getAnchorPoint()
local parent = obj:getParent()
if parent == nil then return nil end
local wpos = parent:convertToWorldSpace( ccp(x,y) )
local r = CCRectMake( wpos.x-sz.width*anchor.x, wpos.y-sz.height*anchor.y, sz.width, sz.height);
return r
end
Lua获取object在全图中的位置
最新推荐文章于 2022-11-22 17:19:42 发布