Corona SDK 配合使用 Graphic 2.0 时,位置不起作用。

我已经将我的 Corona SDK 版本升级到 2013.2076(带有 Graphic 2.0)。但现在我的背景图片无法工作,应用程序崩溃了。

local background = display.newImageRect("/bg.png", 570, 360 )
background:setReferencePoint( display.CenterReferencePoint )
background.x = display.contentCenterX ; background.y = display.contentCenterY
gameGroup:insert(background)

在 Corona SDK 的先前版本中,它运行得非常完美。我无法确定问题所在。请帮帮我。

点赞
用户1444321
用户1444321

随着 Corona Build 2013.2076 的发布,setReferencePoint已被弃用。 您可以使用

background.anchorX = 0.5 ;
background.anchorY = 0.5 ;

有关 anchors 的更多信息,请参见

http://docs.coronalabs.com/guide/graphics/transform-anchor.html

请参见这里的示例

http://docs.coronalabs.com/api/type/DisplayObject/anchorX.html

http://docs.coronalabs.com/api/type/DisplayObject/anchorY.html

2013-11-20 06:04:42