【问题标题】:Reference Points To Anchor Points? (Newbie)锚点的参考点? (新手)
【发布时间】:2014-03-24 06:40:34
【问题描述】:

您能帮我解决以下问题吗?我正在转换使用以前版本的 Corona 构建的应用程序。它一直告诉我“object:setReferencePoint() 仅在 v1Compatibility 模式下可用。请改用锚点。”

_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;

【问题讨论】:

  • 右下角是 1, 1 而不是 0, 1
  • @Lukis 你应该回复它作为可能的答案,而不是评论。

标签: android ios mobile app-store coronasdk


【解决方案1】:

在你的情况下,我认为第二个代码块是:

_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;

(有一个 :info 不需要)

另外,对于我需要迁移的项目,我创建了这个函数,它涵盖了最常用的参考点转换,它可以在某些特定情况下提供帮助,您不能只去替换每个参考点的用法(就是这种情况在我的)。如果您需要未列出的参考点,很容易添加:):

    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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-22
    • 1970-01-01
    • 2022-11-03
    • 1970-01-01
    • 2020-04-16
    • 2011-05-06
    • 1970-01-01
    • 2020-05-21
    相关资源
    最近更新 更多