Corona SDK与Graphic 2.0的位置无法正常工作

时间:2013-11-20 06:00:12

标签: lua corona

我已将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中完美运行。我无法确定问题。请帮忙

1 个答案:

答案 0 :(得分:3)

随着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