_G.buttonShowInfo = display.newImageRect( _G.imagePath.."info.png", display.contentWidth*0.12, display.contentHeight*0.08)
--_G.buttonShowInfo:setReferencePoint( display.BottomLeftReferencePoint )
_G.buttonShowInfo:setReferencePoint( display.BottomRightReferencePoint )
我尝试将它切换到以下,但没有运气。你能指出我正确的方向吗?
_G.buttonShowInfo = display.newImageRect( _G.imagePath.."info.png", display.contentWidth*0.12, display.contentHeight*0.08)
_G.buttonShowInfo:info.anchorX = 0.0;
_G.buttonShowInfo:info.anchorY = 1.0;
答案 0 :(得分:0)
在你的情况下,我认为第二个代码块是:
_G.buttonShowInfo = display.newImageRect( _G.imagePath.."info.png", display.contentWidth*0.12, display.contentHeight*0.08)
_G.buttonShowInfo.anchorX = 0.0;
_G.buttonShowInfo.anchorY = 1.0;
(有一个:不需要信息)
此外,对于我需要迁移的项目,我创建了此功能,涵盖了最常用的参考点转换,它可以帮助您在某些特定情况下无法直接替换每个参考点的用法(就是这种情况)在我的)。如果您需要一个未列出的参考点,则很容易添加:):
function referenceToAnchor(oReferencePoint)
local nAnchorX = 0.0
local nAnchorY = 0.0
if oReferencePoint == display.TopLeftReferencePoint then
nAnchorX = 0.0
nAnchorY = 0.0
elseif oReferencePoint == display.CenterReferencePoint then
nAnchorX = 0.5
nAnchorY = 0.5
elseif oReferencePoint == display.BottomLeftReferencePoint then
nAnchorX = 0.0
nAnchorY = 1.0
elseif oReferencePoint == display.BottomRightReferencePoint then
nAnchorX = 1.0
nAnchorY = 1.0
end
return nAnchorX, nAnchorY
end