BUG - CCLabelTTF setPosition (ver cocos2d-2.0-rc0a-x-2.0)


#1

Hello,

I’m trying to port the HelloWorld example template project (automatically created with cocos2d-x scripts) using LUA Binding.
When I try to use the setPosition on label Android app will crash. If I remove the setPosition instruction the label appears at
the bottom-left of the screen. Note that the .cpp version works well.

local winSize = CCDirector:sharedDirector():getWinSize()

local function helloWorldScene()
@ local scene = CCLayer:node()@
@ local menuPopup@

@ local function menuCallbackExitApp()@
@ CCDirector:sharedDirector():endToLua()@
@ end@

@ — add a popup menu@
@ local closeItem = CCMenuItemImage:itemWithNormalImage(“CloseNormal.png”, “CloseSelected.png”)@
@ closeItem:setPosition(winSize.width - 20 , 20)@
@ closeItem:registerScriptHandler(menuCallbackExitApp)@
@ menuPopup = CCMenu:menuWithItem(closeItem)@
@ menuPopup:setPosition(0, 0)@

@ — add a background @
@ local pSprite = CCSprite:spriteWithFile(“HelloWorld.png”)@
@ pSprite:setPosition( winSize.width/2, winSize.height/2 )@

@ — add a label@
@ local pLabel = CCLabelTTF:labelWithString(“Hello World”, “Arial”, 24.0)@

@ — ####### THE FOLLOWING LINE CAUSE ANDROID CRASH ######@
*pLabel:setPosition( winSize.width/2, winSize.height - 50 )*

@ scene:addChild(pSprite)@
@ scene:addChild(menuPopup)@
@ scene:addChild(pLabel)@
@
@ return scene
end


#2

Thx, issue #1369 was created for it.


#3

Hi, the bug has been fixed at PR https://github.com/cocos2d/cocos2d-x/pull/1067.