如何将Corona的setReferencePoint转换为Anchor点?

所以我有一个使用 display.setReferencePoint 运行正常的 Corona 应用,但是现在尝试运行它时它不起作用了。在网上查找后,似乎现在需要使用 Anchor。以下是我当前的部分,但我在将其转换为 Anchor 点时遇到了麻烦,请帮助我。

background = display.newImage ( "Background.png");

--设置其位置参考点
background:setReferencePoint ( display.TopLeftReferencePoint );
点赞
用户1979583
用户1979583

试着这样写:

background = display.newImage ( "Background.png");
-- 将参考点设置为左上角
background.anchorX = 0.0;
background.anchorY = 0.0;

了解更多信息,请访问:教程:图形2.0中的锚点

2013-12-08 12:27:52
用户4201378
用户4201378

赞成 Karishna 的回答,但也有另一种通过在 Config.lua 文件中添加 graphicsCompatibility 字段来获得 setReferencePoint 支持的方法:

application =
{
    content =
    {
        graphicsCompatibility = 1,  -- 打开 V1 兼容模式

        width = 320,
        height = 480,
        scale = "letterbox"
    },
}

最新版本的 Graphics 2.0 通过设置上面代码中提到的 V1 兼容模式 来兼容 Graphics 1.0。这是一种特殊模式,可以大大减少迁移所需的工作量,默认情况下该模式处于关闭状态,更多信息请访问 这里

2015-12-07 17:02:46