diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua index 895e157be8..0e3774b505 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua @@ -195,15 +195,17 @@ function ArmatureTestLayer:createToExtensionMenu() end function ArmatureTestLayer:creatTitleAndSubTitle(idx) - local title = cc.LabelTTF:create(ArmatureTestLayer.title(idx),"Arial",18) + local title = cc.Label:create(ArmatureTestLayer.title(idx), s_arialPath, 18) title:setColor(cc.c3b(0,0,0)) self:addChild(title, 1, 10000) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) local subTitle = nil if "" ~= ArmatureTestLayer.subTitle(idx) then - local subTitle = cc.LabelTTF:create(ArmatureTestLayer.subTitle(idx), "Arial", 18) + local subTitle = cc.Label:create(ArmatureTestLayer.subTitle(idx), s_arialPath, 18) subTitle:setColor(cc.c3b(0,0,0)) self:addChild(subTitle, 1, 10001) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) end end @@ -226,16 +228,18 @@ function TestAsynchronousLoading:onEnter() self._restarItem:setEnabled(false) self._nextItem:setEnabled(false) - local title = cc.LabelTTF:create(ArmatureTestLayer.title(1),"Arial",18) + local title = cc.Label:create(ArmatureTestLayer.title(1), s_arialPath, 18) title:setColor(cc.c3b(0,0,0)) self:addChild(title, 1, 10000) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) local subTitle = nil if "" ~= ArmatureTestLayer.subTitle(1) then local subInfo = ArmatureTestLayer.subTitle(1) .. 0.0 - local subTitle = cc.LabelTTF:create(subInfo, "Arial", 18) + local subTitle = cc.Label:create(subInfo, s_arialPath, 18) subTitle:setColor(cc.c3b(0,0,0)) self:addChild(subTitle, 1, 10001) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) end @@ -1160,7 +1164,8 @@ function TestArmatureNesting2:onEnter() end self._touchedMenu = false - local label = cc.LabelTTF:create("Change Mount", "Arial", 20) + local label = cc.Label:create("Change Mount", s_arialPath, 20) + label:setAnchorPoint(cc.p(0.5, 0.5)) local menuItem = cc.MenuItemLabel:create(label) menuItem:registerScriptTapHandler(changeMountCallback) local menu = cc.Menu:create(menuItem) diff --git a/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua b/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua index 2fd67c6271..934a147865 100644 --- a/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua +++ b/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua @@ -5,7 +5,7 @@ local function CurrentLanguageTest() label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y-50) ) - local labelLanguage = cc.LabelTTF:create("", s_arialPath, 20) + local labelLanguage = cc.Label:create("", s_arialPath, 20) labelLanguage:setAnchorPoint(cc.p(0.5, 0.5)) labelLanguage:setPosition(VisibleRect:center()) diff --git a/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua b/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua index 14aed46552..68428b5450 100644 --- a/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua +++ b/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua @@ -72,7 +72,7 @@ local function drawPrimitivesMainLayer() lableTitle:setPosition(cc.p(size.width / 2, size.height - 32)) lableTitle:setColor(cc.c3b(255, 255, 40)) --SubTitle - local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), s_thonburiPath, 16) + local subLabelTitle = cc.Label:create(GetSubTitle(), s_thonburiPath, 16) layer:addChild(subLabelTitle, 15) subLabelTitle:setAnchorPoint(cc.p(0.5, 0.5)) subLabelTitle:setPosition(cc.p(size.width / 2, size.height - 80)) diff --git a/tests/lua-tests/src/EffectsTest/EffectsTest.lua b/tests/lua-tests/src/EffectsTest/EffectsTest.lua index 3696df33ee..4558f65c3c 100644 --- a/tests/lua-tests/src/EffectsTest/EffectsTest.lua +++ b/tests/lua-tests/src/EffectsTest/EffectsTest.lua @@ -352,7 +352,8 @@ function CreateEffectsTestLayer() local x, y = size.width, size.height - titleLabel = cc.LabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32) + titleLabel = cc.Label:create(EffectsList[ActionIdx], s_markerFeltFontPath, 32) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(x / 2, y - 80) testLayer:addChild(titleLabel) titleLabel:setTag(kTagLabel) diff --git a/tests/lua-tests/src/ExtensionTest/WebProxyTest.lua b/tests/lua-tests/src/ExtensionTest/WebProxyTest.lua index 9a2c203ffd..79fc85b03d 100644 --- a/tests/lua-tests/src/ExtensionTest/WebProxyTest.lua +++ b/tests/lua-tests/src/ExtensionTest/WebProxyTest.lua @@ -15,7 +15,8 @@ local receiveTextTimes = 0 local receiveBinaryTimes = 0 - local label = cc.LabelTTF:create("WebSocket Test", "Arial", 28) + local label = cc.Label:create("WebSocket Test", s_arialPath, 28) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p( winSize.width / 2, winSize.height - MARGIN)) layer:addChild(label, 0) @@ -36,7 +37,8 @@ end end end - local labelSendText = cc.LabelTTF:create("Send Text", "Arial", 22) + local labelSendText = cc.Label:create("Send Text", s_arialPath, 22) + labelSendText:setAnchorPoint(0.5, 0.5) local itemSendText = cc.MenuItemLabel:create(labelSendText) itemSendText:registerScriptTapHandler(onMenuSendTextClicked) itemSendText:setPosition(cc.p(winSize.width / 2, winSize.height - MARGIN - SPACE)) @@ -54,26 +56,27 @@ end end end - local labelSendBinary = cc.LabelTTF:create("Send Binary", "Arial", 22) + local labelSendBinary = cc.Label:create("Send Binary", s_arialPath, 22) + labelSendBinary:setAnchorPoint(cc.p(0.5, 0.5)) local itemSendBinary = cc.MenuItemLabel:create(labelSendBinary) itemSendBinary:registerScriptTapHandler(onMenuSendBinaryClicked) itemSendBinary:setPosition(cc.p(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)) menuRequest:addChild(itemSendBinary) --Send Text Status Label - sendTextStatus = cc.LabelTTF:create("Send Text WS is waiting...", "Arial", 14,cc.size(160, 100),cc.VERTICAL_TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_TOP) + sendTextStatus = cc.Label:create("Send Text WS is waiting...", s_arialPath, 14,cc.size(160, 100),cc.VERTICAL_TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_TOP) sendTextStatus:setAnchorPoint(cc.p(0, 0)) sendTextStatus:setPosition(cc.p(0, 25)) layer:addChild(sendTextStatus) --Send Binary Status Label - sendBinaryStatus = cc.LabelTTF:create("Send Binary WS is waiting...", "Arial", 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) + sendBinaryStatus = cc.Label:create("Send Binary WS is waiting...", s_arialPath, 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) sendBinaryStatus:setAnchorPoint(cc.p(0, 0)) sendBinaryStatus:setPosition(cc.p(160, 25)) layer:addChild(sendBinaryStatus) --Error Label - errorStatus = cc.LabelTTF:create("Error WS is waiting...", "Arial", 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) + errorStatus = cc.Label:create("Error WS is waiting...", s_arialPath, 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) errorStatus:setAnchorPoint(cc.p(0, 0)) errorStatus:setPosition(cc.p(320, 25)) layer:addChild(errorStatus) diff --git a/tests/lua-tests/src/KeypadTest/KeypadTest.lua b/tests/lua-tests/src/KeypadTest/KeypadTest.lua index 850a908225..12f1ef0947 100644 --- a/tests/lua-tests/src/KeypadTest/KeypadTest.lua +++ b/tests/lua-tests/src/KeypadTest/KeypadTest.lua @@ -4,11 +4,13 @@ local function KeypadMainLayer() local function onEnter() print("come in") local s = cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("Keypad Test", "Arial", 28) + local label = cc.Label:create("Keypad Test", s_thonburiPath, 28) layer:addChild(label, 0) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(s.width/2, s.height-50)) - local labelTip = cc.LabelTTF:create("Please press any key...", "Arial", 22) + local labelTip = cc.Label:create("Please press any key...", "s_thonburiPath", 22) + labelTip:setAnchorPoint(cc.p(0.5, 0.5)) labelTip:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(labelTip, 0) diff --git a/tests/lua-tests/src/LayerTest/LayerTest.lua b/tests/lua-tests/src/LayerTest/LayerTest.lua index 053bd2af63..ec74ef6430 100644 --- a/tests/lua-tests/src/LayerTest/LayerTest.lua +++ b/tests/lua-tests/src/LayerTest/LayerTest.lua @@ -436,8 +436,10 @@ local function LayerGradient() local layer1 = cc.LayerGradient:create(cc.c4b(255,0,0,255), cc.c4b(0,255,0,255), cc.p(0.9, 0.9)) ret:addChild(layer1, 0, kTagLayer) - local label1 = cc.LabelTTF:create("Compressed Interpolation: Enabled", "Marker Felt", 26) - local label2 = cc.LabelTTF:create("Compressed Interpolation: Disabled", "Marker Felt", 26) + local label1 = cc.Label:create("Compressed Interpolation: Enabled", s_markerFeltFontPath, 26) + label1:setAnchorPoint(cc.p(0.5, 0.5)) + local label2 = cc.Label:create("Compressed Interpolation: Disabled", s_markerFeltFontPath, 26) + label2:setAnchorPoint(cc.p(0.5, 0.5)) local item1 = cc.MenuItemLabel:create(label1) local item2 = cc.MenuItemLabel:create(label2) local item = cc.MenuItemToggle:create(item1) diff --git a/tests/lua-tests/src/LuaBridgeTest/LuaBridgeTest.lua b/tests/lua-tests/src/LuaBridgeTest/LuaBridgeTest.lua index 6fea800fee..baae0ff7c4 100644 --- a/tests/lua-tests/src/LuaBridgeTest/LuaBridgeTest.lua +++ b/tests/lua-tests/src/LuaBridgeTest/LuaBridgeTest.lua @@ -48,13 +48,15 @@ local function LuaBridgeLayer() local function newLuaJavaBridge() local newScene = cc.Scene:create() - local titleLabel = cc.LabelTTF:create("", "Arial", 28) + local titleLabel = cc.Label:create("", s_arialPath, 28) newScene:addChild(titleLabel, 1) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 50) titleLabel:setString("LuaJavaBridge Test") - subtitleLabel = cc.LabelTTF:create("", "Thonburi", 16) + subtitleLabel = cc.Label:create("", s_thonburiPath, 16) newScene:addChild(subtitleLabel, 1) + subtitleLabel:setAnchorPoint(cc.p(0.5, 0.5)) subtitleLabel:setPosition(s.width / 2, s.height - 80) subtitleLabel:setString("See the console.") if (cc.PLATFORM_OS_ANDROID == targetPlatform) then @@ -86,13 +88,15 @@ local function LuaBridgeLayer() local function newLuaObjectCBridge() local newScene = cc.Scene:create() - local titleLabel = cc.LabelTTF:create("", "Arial", 28) + local titleLabel = cc.Label:create("", s_arialPath, 28) newScene:addChild(titleLabel, 1) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 50) titleLabel:setString("LuaObjectCBridge Test") - subtitleLabel = cc.LabelTTF:create("", "Thonburi", 16) + subtitleLabel = cc.Label:create("", s_thonburiPath, 16) newScene:addChild(subtitleLabel, 1) + subtitleLabel:setAnchorPoint(cc.p(0.5, 0.5)) subtitleLabel:setPosition(s.width / 2, s.height - 80) subtitleLabel:setString("See the console.") if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or (cc.PLATFORM_OS_MAC == targetPlatform) then diff --git a/tests/lua-tests/src/MenuTest/MenuTest.lua b/tests/lua-tests/src/MenuTest/MenuTest.lua index 73d3574653..00bbe470b1 100644 --- a/tests/lua-tests/src/MenuTest/MenuTest.lua +++ b/tests/lua-tests/src/MenuTest/MenuTest.lua @@ -517,7 +517,8 @@ local function RemoveMenuItemWhenMove() local ret = cc.Layer:create() local s = cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("click item and move, should not crash", "Arial", 20) + local label = cc.Label:create("click item and move, should not crash", s_arialPath, 20) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(s.width/2, s.height - 30)) ret:addChild(label) diff --git a/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua b/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua index 3d422f005a..d3ddd73adb 100644 --- a/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua +++ b/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua @@ -140,15 +140,17 @@ function EventDispatcherTestDemo:createMenu() end function EventDispatcherTestDemo:creatTitleAndSubTitle(idx) - local title = cc.LabelTTF:create(EventDispatcherTestDemo.title(idx),"Arial",18) + local title = cc.Label:create(EventDispatcherTestDemo.title(idx),s_arialPath,18) title:setColor(cc.c3b(128,128,0)) self:addChild(title, 1, 10000) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) local subTitle = nil if "" ~= EventDispatcherTestDemo.subTitle(idx) then - local subTitle = cc.LabelTTF:create(EventDispatcherTestDemo.subTitle(idx), "Arial", 18) + local subTitle = cc.Label:create(EventDispatcherTestDemo.subTitle(idx), s_arialPath, 18) subTitle:setColor(cc.c3b(128,128,0)) self:addChild(subTitle, 1, 10001) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) end end @@ -463,7 +465,8 @@ function RemoveListenerWhenDispatchingTest:onEnter() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(listener1, sprite1) - local statusLabel = cc.LabelTTF:create("The sprite could be touched!", "", 20) + local statusLabel = cc.Label:create("The sprite could be touched!", "", 20) + statusLabel:setAnchorPoint(cc.p(0.5, 0.5)) statusLabel:setPosition(cc.p(origin.x + size.width/2, origin.y + size.height - 90)) self:addChild(statusLabel) @@ -529,7 +532,8 @@ function CustomEventTest:onEnter() cc.MenuItemFont:setFontSize(20) - local statusLabel1 = cc.LabelTTF:create("No custom event 1 received!", "", 20) + local statusLabel1 = cc.Label:create("No custom event 1 received!", "", 20) + statusLabel1:setAnchorPoint(cc.p(0.5, 0.5)) statusLabel1:setPosition(cc.p(origin.x + size.width/2, origin.y + size.height-90 )) self:addChild(statusLabel1) @@ -554,7 +558,8 @@ function CustomEventTest:onEnter() sendItem1:registerScriptTapHandler(sendCallback1) sendItem1:setPosition(cc.p(origin.x + size.width/2, origin.y + size.height/2)) - local statusLabel2 = cc.LabelTTF:create("No custom event 2 received!", "", 20) + local statusLabel2 = cc.Label:create("No custom event 2 received!", "", 20) + statusLabel2:setAnchorPoint(cc.p(0.5, 0.5)) statusLabel2:setPosition(cc.p(origin.x + size.width/2, origin.y + size.height-120 )) self:addChild(statusLabel2) @@ -626,7 +631,8 @@ function LabelKeyboardEventTest:onEnter() local origin = cc.Director:getInstance():getVisibleOrigin() local size = cc.Director:getInstance():getVisibleSize() - local statusLabel = cc.LabelTTF:create("No keyboard event received!", "", 20) + local statusLabel = cc.Label:create("No keyboard event received!", "", 20) + statusLabel:setAnchorPoint(cc.p(0.5, 0.5)) statusLabel:setPosition(cc.p(origin.x + size.width/2,origin.y + size.height/2)) self:addChild(statusLabel) @@ -905,7 +911,7 @@ function RemoveListenerAfterAddingTest:onEnter() listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN) eventDispatcher:addEventListenerWithFixedPriority(listener, -1) - eventDispatcher:removeEventListeners(cc.EVENT_TOUCH_ONE_BY_ONE) + eventDispatcher:removeEventListenersForType(cc.EVENT_TOUCH_ONE_BY_ONE) addNextButton() diff --git a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua index c2aff9d3c6..f1f2bbb33a 100644 --- a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua +++ b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua @@ -125,13 +125,15 @@ local function OpenGLTestMainLayer() local function InitTitle(layer) --Title - local lableTitle = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local lableTitle = cc.Label:create(GetTitle(), s_arialPath, 40) layer:addChild(lableTitle, 15) + lableTitle:setAnchorPoint(cc.p(0.5, 0.5)) lableTitle:setPosition(cc.p(size.width/2, size.height-32)) lableTitle:setColor(cc.c3b(255,255,40)) --SubTitle - local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) + local subLabelTitle = cc.Label:create(GetSubTitle(), s_thonburiPath, 16) layer:addChild(subLabelTitle, 15) + subLabelTitle:setAnchorPoint(cc.p(0.5, 0.5)) subLabelTitle:setPosition(cc.p(size.width/2, size.height-80)) end diff --git a/tests/lua-tests/src/ParticleTest/ParticleTest.lua b/tests/lua-tests/src/ParticleTest/ParticleTest.lua index 4cece01d69..9d04e86532 100644 --- a/tests/lua-tests/src/ParticleTest/ParticleTest.lua +++ b/tests/lua-tests/src/ParticleTest/ParticleTest.lua @@ -98,12 +98,14 @@ local function getBaseLayer() emitter = nil - titleLabel = cc.LabelTTF:create("", "Arial", 28) + titleLabel = cc.Label:create("", s_arialPath, 28) layer:addChild(titleLabel, 100, 1000) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 50) - subtitleLabel = cc.LabelTTF:create("", "Arial", 16) + subtitleLabel = cc.Label:create("", s_arialPath, 16) layer:addChild(subtitleLabel, 100) + subtitleLabel:setAnchorPoint(cc.p(0.5, 0.5)) subtitleLabel:setPosition(s.width / 2, s.height - 80) diff --git a/tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua b/tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua index a2707f5a51..7f9cadc484 100644 --- a/tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua +++ b/tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua @@ -357,8 +357,9 @@ local function initWithMainTest(scene, asubtest, nNodes) menu:setPosition(s.width / 2, s.height - 65) scene:addChild(menu, 1) - infoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + infoLabel = cc.Label:create("0 nodes", s_markerFeltFontPath, 30) infoLabel:setColor(cc.c3b(0, 200, 20)) + infoLabel:setAnchorPoint(cc.p(0.5, 0.5)) infoLabel:setPosition(s.width / 2, s.height - 90) scene:addChild(infoLabel, 1) @@ -388,8 +389,9 @@ local function initWithMainTest(scene, asubtest, nNodes) scene:addChild(subMenu, 1) -- add title label - titleLabel = cc.LabelTTF:create("No title", "Arial", 40) + titleLabel = cc.Label:create("No title", s_arialPath, 40) scene:addChild(titleLabel, 1) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 32) titleLabel:setColor(cc.c3b(255, 255, 40)) diff --git a/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua b/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua index 97f70e5071..d2231ac000 100644 --- a/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua +++ b/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua @@ -338,14 +338,16 @@ local function runNodeChildrenTest() local s = cc.Director:getInstance():getWinSize() --Title - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pNewscene:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) if (nil ~= GetSubTitle()) and ("" ~= GetSubTitle()) then - local pSubLabel = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) + local pSubLabel = cc.Label:create(GetSubTitle(), s_thonburiPath, 16) pNewscene:addChild(pSubLabel, 1) + pSubLabel:setAnchorPoint(cc.p(0.5, 0.5)) pSubLabel:setPosition(cc.p(s.width/2, s.height-80)) end @@ -370,8 +372,9 @@ local function runNodeChildrenTest() pNewscene:addChild(pMenuAddOrSub,1) --InfoLayer - local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + local pInfoLabel = cc.Label:create("0 nodes", s_markerFeltFontPath, 30) pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setAnchorPoint(cc.p(0.5, 0.5)) pInfoLabel:setPosition(cc.p(s.width/2, s.height/2-15)) pNewscene:addChild(pInfoLabel, 1, NodeChildrenTestParam.kTagInfoLayer) @@ -825,8 +828,9 @@ local function runParticleTest() pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) - local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + local pInfoLabel = cc.Label:create("0 nodes", s_markerFeltFontPath, 30) pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setAnchorPoint(cc.p(0.5, 0.5)) pInfoLabel:setPosition(cc.p(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, ParticleTestParam.kTagInfoLayer) @@ -863,8 +867,9 @@ local function runParticleTest() pSubMenu:setPosition(cc.p(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pNewScene:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) @@ -1269,8 +1274,9 @@ local function runSpriteTest() pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) - local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + local pInfoLabel = cc.Label:create("0 nodes", s_markerFeltFontPath, 30) pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setAnchorPoint(cc.p(0.5, 0.5)) pInfoLabel:setPosition(cc.p(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, SpriteTestParam.kTagInfoLayer) @@ -1307,8 +1313,9 @@ local function runSpriteTest() pSubMenu:setPosition(cc.p(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pNewScene:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) while nQuantityNodes < nNodes do @@ -1431,14 +1438,16 @@ local function runTextureTest() end --Title - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pLayer:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) --Subtitle - local pSubLabel = cc.LabelTTF:create(GetSubtitle(), "Thonburi", 16) + local pSubLabel = cc.Label:create(GetSubtitle(), s_thonburiPath, 16) pLayer:addChild(pSubLabel, 1) + pSubLabel:setAnchorPoint(cc.p(0.5, 0.5)) pSubLabel:setPosition(cc.p(s.width/2, s.height-80)) --menu @@ -1596,8 +1605,9 @@ local function runTouchesTest() pLayer:addChild(pTouchesTestMenu) --Title - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pLayer:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) @@ -1686,13 +1696,15 @@ local function runFuncRelateWithTable() end --Title - local title = cc.LabelTTF:create(GetTitle(), "Arial", 28) + local title = cc.Label:create(GetTitle(), s_arialPath, 28) layer:addChild(title, 1) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition(cc.p(s.width/2, s.height-32)) title:setColor(cc.c3b(255,255,40)) --Subtitle - local subTitle = cc.LabelTTF:create(GetSubtitle(), "Thonburi", 16) + local subTitle = cc.Label:create(GetSubtitle(), s_thonburiPath, 16) layer:addChild(subTitle, 1) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition(cc.p(s.width/2, s.height-80)) --"+","-" Menu @@ -1729,8 +1741,9 @@ local function runFuncRelateWithTable() layer:addChild(menuAddOrSub,1) --num - local numLabel = cc.LabelTTF:create("10000", "Marker Felt", 30) + local numLabel = cc.Label:create("10000", s_markerFeltFontPath, 30) numLabel:setColor(cc.c3b(0,200,20)) + numLabel:setAnchorPoint(cc.p(0.5, 0.5)) numLabel:setPosition(cc.p(s.width/2, s.height/2-15)) layer:addChild(numLabel, 1, NodeChildrenTestParam.kTagInfoLayer) diff --git a/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua b/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua index 409a8a28a4..beb8c9adb7 100644 --- a/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua +++ b/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua @@ -1076,20 +1076,24 @@ local function PhysicsContactTest() local s = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height); - local label = cc.LabelTTF:create(tostring(layer.yellowBoxNum), "Arial", 32); + local label = cc.Label:create(tostring(layer.yellowBoxNum), s_arialPath, 32); root:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2, s.height-50)); - label = cc.LabelTTF:create(tostring(layer.blueBoxNum), "Arial", 32); + label = cc.Label:create(tostring(layer.blueBoxNum), s_arialPath, 32); root:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2, s.height-90)); - label = cc.LabelTTF:create(tostring(layer.yellowTriangleNum), "Arial", 32); + label = cc.Label:create(tostring(layer.yellowTriangleNum), s_arialPath, 32); root:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2, s.height-130)); - label = cc.LabelTTF:create(tostring(layer.blueTriangleNum), "Arial", 32); + label = cc.Label:create(tostring(layer.blueTriangleNum), s_arialPath, 32); root:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2, s.height-170)); local wall = cc.Node:create(); @@ -1209,8 +1213,9 @@ local function PhysicsContactTest() menu1:setPosition(cc.p(s.width/2, s.height-50)); layer:addChild(menu1, 1); - local label = cc.LabelTTF:create("yellow box", "Arial", 32); + local label = cc.Label:create("yellow box", s_arialPath, 32); layer:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2 - 150, s.height-50)); local decrease2 = cc.MenuItemFont:create(" - "); @@ -1227,8 +1232,9 @@ local function PhysicsContactTest() menu2:setPosition(cc.p(s.width/2, s.height-90)); layer:addChild(menu2, 1); - label = cc.LabelTTF:create("blue box", "Arial", 32); + label = cc.Label:create("blue box", s_arialPath, 32); layer:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2 - 150, s.height-90)); local decrease3 = cc.MenuItemFont:create(" - "); @@ -1245,8 +1251,9 @@ local function PhysicsContactTest() menu3:setPosition(cc.p(s.width/2, s.height-130)); layer:addChild(menu3, 1); - label = cc.LabelTTF:create("yellow triangle", "Arial", 32); + label = cc.Label:create("yellow triangle", s_arialPath, 32); layer:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2 - 150, s.height-130)); local decrease4 = cc.MenuItemFont:create(" - "); @@ -1263,8 +1270,9 @@ local function PhysicsContactTest() menu4:setPosition(cc.p(s.width/2, s.height-170)); layer:addChild(menu4, 1); - label = cc.LabelTTF:create("blue triangle", "Arial", 32); + label = cc.Label:create("blue triangle", s_arialPath, 32); layer:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2 - 150, s.height-170)); diff --git a/tests/lua-tests/src/RotateWorldTest/RotateWorldTest.lua b/tests/lua-tests/src/RotateWorldTest/RotateWorldTest.lua index e196832723..1d2f03f387 100644 --- a/tests/lua-tests/src/RotateWorldTest/RotateWorldTest.lua +++ b/tests/lua-tests/src/RotateWorldTest/RotateWorldTest.lua @@ -54,7 +54,8 @@ local function CreateTestLayer() x = size.width y = size.height - local label = cc.LabelTTF:create("cocos2d", "Tahoma", 64) + local label = cc.Label:create("cocos2d", s_tahomaPath, 64) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(x / 2, y / 2) layer:addChild(label) diff --git a/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua b/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua index 3f58c1f0bd..67870e3900 100644 --- a/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua +++ b/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua @@ -959,7 +959,8 @@ local function TextureAsync() local size =cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("Loading...", "Marker Felt", 32) + local label = cc.Label:create("Loading...", s_markerFeltFontPath, 32) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p( size.width/2, size.height/2)) ret:addChild(label, 10) diff --git a/tests/lua-tests/src/TransitionsTest/TransitionsTest.lua b/tests/lua-tests/src/TransitionsTest/TransitionsTest.lua index b2811f5780..cddc951f9c 100644 --- a/tests/lua-tests/src/TransitionsTest/TransitionsTest.lua +++ b/tests/lua-tests/src/TransitionsTest/TransitionsTest.lua @@ -62,13 +62,15 @@ local function createLayer1() bg1:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) - local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32) + local titleLabel = cc.Label:create(Transition_Name[SceneIdx], s_thonburiPath, 32) layer:addChild(titleLabel) titleLabel:setColor(cc.c3b(255,32,32)) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(x / 2, y - 100) - local label = cc.LabelTTF:create("SCENE 1", "Marker Felt", 38) + local label = cc.Label:create("SCENE 1", s_markerFeltFontPath, 38) label:setColor(cc.c3b(16,16,255)) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(x / 2, y / 2) layer:addChild(label) @@ -105,13 +107,15 @@ local function createLayer2() bg1:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) - local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 ) + local titleLabel = cc.Label:create(Transition_Name[SceneIdx], s_thonburiPath, 32 ) layer:addChild(titleLabel) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setColor(cc.c3b(255,32,32)) titleLabel:setPosition(x / 2, y - 100) - local label = cc.LabelTTF:create("SCENE 2", "Marker Felt", 38) + local label = cc.Label:create("SCENE 2", s_markerFeltFontPath, 38) label:setColor(cc.c3b(16,16,255)) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(x / 2, y / 2) layer:addChild(label) diff --git a/tests/lua-tests/src/UserDefaultTest/UserDefaultTest.lua b/tests/lua-tests/src/UserDefaultTest/UserDefaultTest.lua index b86eb3a1d3..7ed6578d47 100644 --- a/tests/lua-tests/src/UserDefaultTest/UserDefaultTest.lua +++ b/tests/lua-tests/src/UserDefaultTest/UserDefaultTest.lua @@ -72,8 +72,9 @@ end function UserDefaultTestMain() local ret = cc.Scene:create() local s = cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("UserDefault test see log", "Arial", 28) + local label = cc.Label:create("UserDefault test see log", s_arialPath, 28) ret:addChild(label, 0) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition( cc.p(s.width/2, s.height-50) ) ret:addChild(CreateBackMenuItem()) doTest() diff --git a/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua b/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua index 4bec50a734..5208580401 100644 --- a/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua +++ b/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua @@ -7,12 +7,14 @@ local function XMLHttpRequestLayer() local space = 35 local function init() - local label = cc.LabelTTF:create("XML Http Request Test", "Arial", 28) + local label = cc.Label:create("XML Http Request Test", s_arialPath, 28) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(winSize.width / 2, winSize.height - margin)) layer:addChild(label, 0) --Response Code Label - local labelStatusCode = cc.LabelTTF:create("HTTP Status Code", "Marker Felt", 20) + local labelStatusCode = cc.Label:create("HTTP Status Code", s_markerFeltFontPath, 20) + labelStatusCode:setAnchorPoint(cc.p(0.5, 0.5)) labelStatusCode:setPosition(cc.p(winSize.width / 2, winSize.height - margin - 6 * space)) layer:addChild(labelStatusCode) @@ -38,7 +40,8 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelGet = cc.LabelTTF:create("Test Get", "Arial", 22) + local labelGet = cc.Label:create("Test Get", s_arialPath, 22) + labelGet:setAnchorPoint(cc.p(0.5, 0.5)) local itemGet = cc.MenuItemLabel:create(labelGet) itemGet:registerScriptTapHandler(onMenuGetClicked) itemGet:setPosition(cc.p(winSize.width / 2, winSize.height - margin - space)) @@ -59,7 +62,8 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelPost = cc.LabelTTF:create("Test Post", "Arial", 22) + local labelPost = cc.Label:create("Test Post", s_arialPath, 22) + labelPost:setAnchorPoint(cc.p(0.5, 0.5)) local itemPost = cc.MenuItemLabel:create(labelPost) itemPost:registerScriptTapHandler(onMenuPostClicked) itemPost:setPosition(cc.p(winSize.width / 2, winSize.height - margin - 2 * space)) @@ -93,7 +97,8 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelPostBinary = cc.LabelTTF:create("Test Post Binary", "Arial", 22) + local labelPostBinary = cc.Label:create("Test Post Binary", s_arialPath, 22) + labelPostBinary:setAnchorPoint(cc.p(0.5, 0.5)) local itemPostBinary = cc.MenuItemLabel:create(labelPostBinary) itemPostBinary:registerScriptTapHandler(onMenuPostBinaryClicked) itemPostBinary:setPosition(cc.p(winSize.width / 2, winSize.height - margin - 3 * space)) @@ -121,7 +126,8 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelPostJson = cc.LabelTTF:create("Test Post Json", "Arial", 22) + local labelPostJson = cc.LabelTTF:create("Test Post Json", s_arialPath, 22) + labelPostJson:setAnchorPoint(cc.p(0.5, 0.5)) local itemPostJson = cc.MenuItemLabel:create(labelPostJson) itemPostJson:registerScriptTapHandler(onMenuPostJsonClicked) itemPostJson:setPosition(cc.p(winSize.width / 2, winSize.height - margin - 4 * space)) diff --git a/tests/lua-tests/src/helper.lua b/tests/lua-tests/src/helper.lua index c2706d02d3..05763b944b 100644 --- a/tests/lua-tests/src/helper.lua +++ b/tests/lua-tests/src/helper.lua @@ -40,7 +40,8 @@ end -- add the menu item for back to main menu function CreateBackMenuItem() - local label = cc.LabelTTF:create("MainMenu", "Arial", 20) + local label = cc.Label:create("MainMenu", s_arialPath, 20) + label:setAnchorPoint(cc.p(0.5, 0.5)) local MenuItem = cc.MenuItemLabel:create(label) MenuItem:registerScriptTapHandler(MainMenuCallback) @@ -100,11 +101,13 @@ function Helper.initWithLayer(layer) Helper.currentLayer = layer local size = cc.Director:getInstance():getWinSize() - Helper.titleLabel = cc.LabelTTF:create("", "Arial", 28) + Helper.titleLabel = cc.Label:create("", s_arialPath, 28) + Helper.titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) layer:addChild(Helper.titleLabel, 1) Helper.titleLabel:setPosition(size.width / 2, size.height - 50) - Helper.subtitleLabel = cc.LabelTTF:create("", "Thonburi", 16) + Helper.subtitleLabel = cc.Label:create("", s_thonburiPath, 16) + Helper.subtitleLabel:setAnchorPoint(cc.p(0.5, 0.5)) layer:addChild(Helper.subtitleLabel, 1) Helper.subtitleLabel:setPosition(size.width / 2, size.height - 80) diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index 4d0b967332..8afcc3bcda 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -155,7 +155,8 @@ function CreateTestMenu() local index = 0 local obj = nil for index, obj in pairs(_allTests) do - local testLabel = cc.LabelTTF:create(obj.name, "Arial", 24) + local testLabel = cc.Label:create(obj.name, s_arialPath, 24) + testLabel:setAnchorPoint(cc.p(0.5, 0.5)) local testMenuItem = cc.MenuItemLabel:create(testLabel) if not obj.isSupported then testMenuItem:setEnabled(false) diff --git a/tests/lua-tests/src/testResource.lua b/tests/lua-tests/src/testResource.lua index b490e3a6dc..466082560f 100644 --- a/tests/lua-tests/src/testResource.lua +++ b/tests/lua-tests/src/testResource.lua @@ -44,3 +44,4 @@ s_pPathSpineBoyAtlas = "spine/spineboy.atlas" s_markerFeltFontPath = "fonts/Marker Felt.ttf" s_arialPath = "fonts/arial.ttf" s_thonburiPath = "fonts/Thonburi.ttf" +s_tahomaPath = "fonts/tahoma.ttf"