From 7a9f1d6804c15e7eeb2d2a6f48b330ed6db09e1d Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Tue, 20 Aug 2013 13:44:37 +0800 Subject: [PATCH] issue #2433:Modify TestLua samples and some .ini files --- .../AccelerometerTest/AccelerometerTest.lua | 24 +- .../luaScript/ExtensionTest/ExtensionTest.lua | 530 +++++------ .../luaScript/LayerTest/LayerTest.lua | 2 + .../Resources/luaScript/MenuTest/MenuTest.lua | 384 ++++---- .../MotionStreakTest/MotionStreakTest.lua | 62 +- .../Resources/luaScript/NodeTest/NodeTest.lua | 307 +++--- .../luaScript/OpenGLTest/OpenGLTest.lua | 207 ++--- .../luaScript/ParallaxTest/ParallaxTest.lua | 61 +- .../luaScript/ParticleTest/ParticleTest.lua | 483 +++++----- .../PerformanceTest/PerformanceSpriteTest.lua | 162 ++-- .../PerformanceTest/PerformanceTest.lua | 539 ++++++----- .../RenderTextureTest/RenderTextureTest.lua | 241 +++-- .../RotateWorldTest/RotateWorldTest.lua | 70 +- .../luaScript/SceneTest/SceneTest.lua | 101 +- .../luaScript/SpriteTest/SpriteTest.lua | 872 +++++++++--------- .../luaScript/Texture2dTest/Texture2dTest.lua | 765 +++++++-------- .../luaScript/TileMapTest/TileMapTest.lua | 423 ++++----- .../Resources/luaScript/TouchesTest/Ball.lua | 62 +- .../luaScript/TouchesTest/Paddle.lua | 12 +- .../luaScript/TouchesTest/TouchesTest.lua | 26 +- .../TransitionsTest/TransitionsTest.lua | 160 ++-- .../UserDefaultTest/UserDefaultTest.lua | 52 +- .../luaScript/ZwoptexTest/ZwoptexTest.lua | 32 +- .../TestLua/Resources/luaScript/extern.lua | 10 +- .../TestLua/Resources/luaScript/mainMenu.lua | 32 +- scripting/lua/cocos2dx_support/CCLuaStack.cpp | 2 + .../cocos2dx_support/LuaBasicConversions.cpp | 317 ++++--- .../cocos2dx_support/LuaBasicConversions.h | 8 + .../LuaOpengl.cpp.REMOVED.git-id | 2 +- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_auto.hpp | 70 ++ .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_extension_auto.hpp | 137 +++ .../lua_cocos2dx_extension_auto_api.js | 860 ++++++++++++++++- .../generated/lua_cocos2dx_manual.cpp | 745 ++++++++++++++- scripting/lua/script/Cocos2d.lua | 136 ++- scripting/lua/script/Cocos2dConstants.lua | 31 +- tools/tolua/cocos2dx.ini | 6 +- tools/tolua/cocos2dx_extension.ini | 8 +- 40 files changed, 4834 insertions(+), 3113 deletions(-) diff --git a/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua b/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua index 65c0313efd..dbdb62a470 100644 --- a/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua @@ -3,37 +3,37 @@ local function AccelerometerMainLayer() local function title() return "AccelerometerTest" end - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() pLayer:setAccelerometerEnabled(true) - local pLabel = CCLabelTTF:create(title(), "Arial", 32) + local pLabel = cc.LabelTTF:create(title(), "Arial", 32) pLayer:addChild(pLabel, 1) - pLabel:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 50) ) + pLabel:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 50) ) - local pBall = CCSprite:create("Images/ball.png") - pBall:setPosition(CCPoint(VisibleRect:center().x, VisibleRect:center().y)) + local pBall = cc.Sprite:create("Images/ball.png") + pBall:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y)) pLayer:addChild(pBall) pBall:retain() local function didAccelerate(x,y,z,timestamp) - local pDir = CCDirector:getInstance() + local pDir = cc.Director:getInstance() if nil == pBall then return end local szBall = pBall:getContentSize() - - local ptNowX,ptNowY = pBall:getPosition() + local ptNow = pBall:getPosition() + local ptNowX,ptNowY = ptNow.x, ptNow.y - local ptTmp = pDir:convertToUI(CCPoint(ptNowX,ptNowY)) + local ptTmp = pDir:convertToUI(cc.p(ptNowX,ptNowY)) ptTmp.x = ptTmp.x + x * 9.81 ptTmp.y = ptTmp.y - y * 9.81 - local ptNext = pDir:convertToGL(CCPoint(ptTmp.x,ptTmp.y)) + local ptNext = pDir:convertToGL(cc.p(ptTmp.x,ptTmp.y)) local nMinX = math.floor(VisibleRect:left().x + szBall.width / 2.0) local nMaxX = math.floor(VisibleRect:right().x - szBall.width / 2.0) if ptNext.x < nMinX then @@ -50,7 +50,7 @@ local function AccelerometerMainLayer() ptNext.y = nMaxY end - pBall:setPosition(CCPoint(ptNext.x,ptNext.y)) + pBall:setPosition(cc.p(ptNext.x,ptNext.y)) end @@ -63,7 +63,7 @@ end function AccelerometerMain() cclog("AccelerometerMain") - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(AccelerometerMainLayer()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua index 4d7d78b849..70f68e16dc 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua @@ -35,14 +35,14 @@ function CreateExtensionsBasicLayerMenu(pMenu) local function toMainLayer() local pScene = ExtensionsTestMain() if pScene ~= nil then - CCDirector:getInstance():replaceScene(pScene) + cc.Director:getInstance():replaceScene(pScene) end end --Create BackMneu - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local pMenuItemFont = cc.MenuItemFont:create("Back") + pMenuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end @@ -59,40 +59,40 @@ local NotificationCenterParam = } local function runNotificationCenterTest() - local pNewScene = CCScene:create() - local pNewLayer = CCLayer:create() + local pNewScene = cc.Scene:create() + local pNewLayer = cc.Layer:create() local function BaseInitSceneLayer(pLayer) if nil == pLayer then return end - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local function toggleSwitch(tag,menuItem) - local toggleItem = tolua.cast(menuItem,"CCMenuItemToggle") + local toggleItem = tolua.cast(menuItem,"MenuItemToggle") local nIndex = toggleItem:getSelectedIndex() local selectedItem = toggleItem:getSelectedItem() if 0 == nIndex then selectedItem = nil end - CCNotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE,selectedItem) + cc.NotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE,selectedItem) end - local switchlabel1 = CCLabelTTF:create("switch off", "Marker Felt", 26) - local switchlabel2 = CCLabelTTF:create("switch on", "Marker Felt", 26) - local switchitem1 = CCMenuItemLabel:create(switchlabel1) - local switchitem2 = CCMenuItemLabel:create(switchlabel2) - local switchitem = CCMenuItemToggle:create(switchitem1) + local switchlabel1 = cc.LabelTTF:create("switch off", "Marker Felt", 26) + local switchlabel2 = cc.LabelTTF:create("switch on", "Marker Felt", 26) + local switchitem1 = cc.MenuItemLabel:create(switchlabel1) + local switchitem2 = cc.MenuItemLabel:create(switchlabel2) + local switchitem = cc.MenuItemToggle:create(switchitem1) switchitem:addSubItem(switchitem2) switchitem:registerScriptTapHandler(toggleSwitch) --turn on switchitem:setSelectedIndex(1) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(switchitem) - menu:setPosition(CCPoint(s.width/2+100, s.height/2)) + menu:setPosition(cc.p(s.width/2+100, s.height/2)) pLayer:addChild(menu) - local menuConnect = CCMenu:create() - menuConnect:setPosition(CCPoint(0,0)) + local menuConnect = cc.Menu:create() + menuConnect:setPosition(cc.p(0,0)) pLayer:addChild(menuConnect) local i = 1 local bSwitchOn = false @@ -129,32 +129,32 @@ local function runNotificationCenterTest() local function setIsConnectToSwitch(pLight,bConnect,nIdx) bConnectArray[nIdx] = bConnect if bConnect then - CCNotificationCenter:getInstance():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE) + cc.NotificationCenter:getInstance():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE) else - CCNotificationCenter:getInstance():unregisterScriptObserver(pLight,NotificationCenterParam.MSG_SWITCH_STATE) + cc.NotificationCenter:getInstance():unregisterScriptObserver(pLight,NotificationCenterParam.MSG_SWITCH_STATE) end updateLightState() end for i = 1, 3 do - lightArray[i] = CCSprite:create("Images/Pea.png") + lightArray[i] = cc.Sprite:create("Images/Pea.png") lightArray[i]:setTag(NotificationCenterParam.kTagLight + i) - lightArray[i]:setPosition(CCPoint(100, s.height / 4 * i) ) + lightArray[i]:setPosition(cc.p(100, s.height / 4 * i) ) pLayer:addChild(lightArray[i]) - local connectlabel1 = CCLabelTTF:create("not connected", "Marker Felt", 26) + local connectlabel1 = cc.LabelTTF:create("not connected", "Marker Felt", 26) - local connectlabel2 = CCLabelTTF:create("connected", "Marker Felt", 26) - local connectitem1 = CCMenuItemLabel:create(connectlabel1) - local connectitem2 = CCMenuItemLabel:create(connectlabel2) - local connectitem = CCMenuItemToggle:create(connectitem1) + local connectlabel2 = cc.LabelTTF:create("connected", "Marker Felt", 26) + local connectitem1 = cc.MenuItemLabel:create(connectlabel1) + local connectitem2 = cc.MenuItemLabel:create(connectlabel2) + local connectitem = cc.MenuItemToggle:create(connectitem1) connectitem:addSubItem(connectitem2) connectitem:setTag(NotificationCenterParam.kTagConnect+i) local function connectToSwitch(tag,menuItem) - local connectMenuitem = tolua.cast(menuItem,"CCMenuItemToggle") + local connectMenuitem = tolua.cast(menuItem,"MenuItemToggle") local bConnected = true if connectMenuitem:getSelectedIndex() == 0 then bConnected = false @@ -165,7 +165,7 @@ local function runNotificationCenterTest() connectitem:registerScriptTapHandler(connectToSwitch) local nX,nY = lightArray[i]:getPosition() - connectitem:setPosition(CCPoint(nX,nY+50)) + connectitem:setPosition(cc.p(nX,nY+50)) menuConnect:addChild(connectitem, 0,connectitem:getTag()) @@ -186,48 +186,48 @@ local function runNotificationCenterTest() if 0 == toggleSelectIndex then toggleSelectedItem = nil end - CCNotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE, toggleSelectedItem) + cc.NotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE, toggleSelectedItem) --for testing removeAllObservers */ local function doNothing() end - CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer1") - CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer2") - CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer3") + cc.NotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer1") + cc.NotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer2") + cc.NotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer3") local function CreateToMainMenu(pMenu) if nil == pMenu then return end local function toMainLayer() - local numObserversRemoved = CCNotificationCenter:getInstance():removeAllObservers(pNewLayer) + local numObserversRemoved = cc.NotificationCenter:getInstance():removeAllObservers(pNewLayer) if 3 ~= numObserversRemoved then print("All observers were not removed!") end for i = 1 , 3 do if bConnectArray[i] then - CCNotificationCenter:getInstance():unregisterScriptObserver(lightArray[i],NotificationCenterParam.MSG_SWITCH_STATE) + cc.NotificationCenter:getInstance():unregisterScriptObserver(lightArray[i],NotificationCenterParam.MSG_SWITCH_STATE) end end local pScene = ExtensionsTestMain() if pScene ~= nil then - CCDirector:getInstance():replaceScene(pScene) + cc.Director:getInstance():replaceScene(pScene) end end --Create BackMneu - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local pMenuItemFont = cc.MenuItemFont:create("Back") + pMenuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end --Add Menu - local pToMainMenu = CCMenu:create() + local pToMainMenu = cc.Menu:create() CreateToMainMenu(pToMainMenu) - pToMainMenu:setPosition(CCPoint(0, 0)) + pToMainMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pToMainMenu,10) end @@ -281,7 +281,7 @@ local function runCCControlTest() return ControlExtensionsTestArray[nCurCase + 1] end - local pNewScene = CCScene:create() + local pNewScene = cc.Scene:create() local function CreateBasicMenu(pMenu) if nil == pMenu then @@ -307,21 +307,21 @@ local function runCCControlTest() CurrentControlScene() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end @@ -330,31 +330,31 @@ local function runCCControlTest() return end --Add Menu - local pToMainMenu = CCMenu:create() + local pToMainMenu = cc.Menu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(CCPoint(0, 0)) + pToMainMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pToMainMenu,10) --Add the generated background - local pBackground = CCSprite:create("extensions/background.png") + local pBackground = cc.Sprite:create("extensions/background.png") pBackground:setPosition(VisibleRect:center()) pLayer:addChild(pBackground) --Add the ribbon - local pRibbon = CCScale9Sprite:create("extensions/ribbon.png", CCRect(1, 1, 48, 55)) - pRibbon:setContentSize(CCSize(VisibleRect:getVisibleRect().size.width, 57)) - pRibbon:setPosition(CCPoint(VisibleRect:center().x, VisibleRect:top().y - pRibbon:getContentSize().height / 2.0)) + local pRibbon = cc.Scale9Sprite:create("extensions/ribbon.png", cc.rect(1, 1, 48, 55)) + pRibbon:setContentSize(cc.size(VisibleRect:getVisibleRect().size.width, 57)) + pRibbon:setPosition(cc.p(VisibleRect:center().x, VisibleRect:top().y - pRibbon:getContentSize().height / 2.0)) pLayer:addChild(pRibbon) --Add the title - pSceneTitleLabel = CCLabelTTF:create("Title", "Arial", 12) - pSceneTitleLabel:setPosition(CCPoint (VisibleRect:center().x, VisibleRect:top().y - pSceneTitleLabel:getContentSize().height / 2 - 5)) + pSceneTitleLabel = cc.LabelTTF:create("Title", "Arial", 12) + pSceneTitleLabel:setPosition(cc.p (VisibleRect:center().x, VisibleRect:top().y - pSceneTitleLabel:getContentSize().height / 2 - 5)) pLayer:addChild(pSceneTitleLabel, 1) pSceneTitleLabel:setString(pStrTitle) - local pOperateMenu = CCMenu:create() + local pOperateMenu = cc.Menu:create() CreateBasicMenu(pOperateMenu) - pOperateMenu:setPosition(CCPoint(0, 0)) + pOperateMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pOperateMenu,1) end @@ -363,19 +363,19 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() --Add a label in which the slider value will be displayed - local pDisplayValueLabel = CCLabelTTF:create("Move the slider thumb!\nThe lower slider is restricted." ,"Marker Felt", 32) + local pDisplayValueLabel = cc.LabelTTF:create("Move the slider thumb!\nThe lower slider is restricted." ,"Marker Felt", 32) pDisplayValueLabel:retain() - pDisplayValueLabel:setAnchorPoint(CCPoint(0.5, -1.0)) - pDisplayValueLabel:setPosition(CCPoint(screenSize.width / 1.7, screenSize.height / 2.0)) + pDisplayValueLabel:setAnchorPoint(cc.p(0.5, -1.0)) + pDisplayValueLabel:setPosition(cc.p(screenSize.width / 1.7, screenSize.height / 2.0)) pLayer:addChild(pDisplayValueLabel) local function valueChanged(pSender) if nil == pSender or nil == pDisplayValueLabel then return end - local pControl = tolua.cast(pSender,"CCControlSlider") + local pControl = tolua.cast(pSender,"ControlSlider") local strFmt = nil if pControl:getTag() == 1 then strFmt = string.format("Upper slider value = %.02f",pControl:getValue()) @@ -384,31 +384,31 @@ local function runCCControlTest() end if nil ~= strFmt then - pDisplayValueLabel:setString(CCString:create(strFmt):getCString()) + pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) end end --Add the slider - local pSlider = CCControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") - pSlider:setAnchorPoint(CCPoint(0.5, 1.0)) + local pSlider = cc.ControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") + pSlider:setAnchorPoint(cc.p(0.5, 1.0)) pSlider:setMinimumValue(0.0) pSlider:setMaximumValue(5.0) - pSlider:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0 + 16)) + pSlider:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0 + 16)) pSlider:setTag(1) --When the value of the slider will change, the given selector will be call - pSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + pSlider:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) - local pRestrictSlider = CCControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") - pRestrictSlider:setAnchorPoint(CCPoint(0.5, 1.0)) + local pRestrictSlider = cc.ControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") + pRestrictSlider:setAnchorPoint(cc.p(0.5, 1.0)) pRestrictSlider:setMinimumValue(0.0) pRestrictSlider:setMaximumValue(5.0) pRestrictSlider:setMaximumAllowedValue(4.0) pRestrictSlider:setMinimumAllowedValue(1.5) pRestrictSlider:setValue(3.0) - pRestrictSlider:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0 - 24)) + pRestrictSlider:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0 - 24)) pRestrictSlider:setTag(2) --same with restricted - pRestrictSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + pRestrictSlider:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) pLayer:addChild(pSlider) pLayer:addChild(pRestrictSlider) end @@ -418,11 +418,11 @@ local function runCCControlTest() if nil == pLayer then return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() local pColorLabel = nil - local pNode = CCNode:create() - pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) + local pNode = cc.Node:create() + pNode:setPosition(cc.p (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 @@ -433,33 +433,33 @@ local function runCCControlTest() return end - local pPicker = tolua.cast(pSender,"CCControlColourPicker") + local pPicker = tolua.cast(pSender,"ControlColourPicker") local strFmt = string.format("#%02X%02X%02X",pPicker:getColor().r, pPicker:getColor().g, pPicker:getColor().b) - pColorLabel:setString(CCString:create(strFmt):getCString()) + pColorLabel:setString(cc.String:create(strFmt):getCString()) end - local pColourPicker = CCControlColourPicker:create() - pColourPicker:setColor(Color3B(37, 46, 252)) - pColourPicker:setPosition(CCPoint (pColourPicker:getContentSize().width / 2, 0)) - pColourPicker:registerControlEventHandler(colourValueChanged, CCControlEventValueChanged) + local pColourPicker = cc.ControlColourPicker:create() + pColourPicker:setColor(cc.c3b(37, 46, 252)) + pColourPicker:setPosition(cc.p (pColourPicker:getContentSize().width / 2, 0)) + pColourPicker:registerControlEventHandler(colourValueChanged, cc.ControlEventValueChanged) pNode:addChild(pColourPicker) dLayer_width = dLayer_width + pColourPicker:getContentSize().width --Add the black background for the text - local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSize(150, 50)) - pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + local pBackground = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackground:setContentSize(cc.size(150, 50)) + pBackground:setPosition(cc.p(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width - pColorLabel = CCLabelTTF:create("#color", "Marker Felt", 30) + pColorLabel = cc.LabelTTF:create("#color", "Marker Felt", 30) pColorLabel:retain() pColorLabel:setPosition(pBackground:getPosition()) pNode:addChild(pColorLabel) --Set the layer size - pNode:setContentSize(CCSize(dLayer_width, 0)) - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(cc.size(dLayer_width, 0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) --Update the color text colourValueChanged(pColourPicker) @@ -471,22 +471,22 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() - local pNode = CCNode:create() - pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) + local pNode = cc.Node:create() + pNode:setPosition(cc.p (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 --Add the black background for the text - local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSize(80, 50)) - pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + local pBackground = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackground:setContentSize(cc.size(80, 50)) + pBackground:setPosition(cc.p(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width - local pDisplayValueLabel = CCLabelTTF:create("#color" ,"Marker Felt" ,30) + local pDisplayValueLabel = cc.LabelTTF:create("#color" ,"Marker Felt" ,30) pDisplayValueLabel:retain() pDisplayValueLabel:setPosition(pBackground:getPosition()) @@ -498,28 +498,28 @@ local function runCCControlTest() return end - local pControl = tolua.cast(pSender,"CCControlSwitch") + local pControl = tolua.cast(pSender,"ControlSwitch") if pControl:isOn() then pDisplayValueLabel:setString("On") else pDisplayValueLabel:setString("Off") end end - local pSwitchControl = CCControlSwitch:create( - CCSprite:create("extensions/switch-mask.png"), - CCSprite:create("extensions/switch-on.png"), - CCSprite:create("extensions/switch-off.png"), - CCSprite:create("extensions/switch-thumb.png"), - CCLabelTTF:create("On", "Arial-BoldMT", 16), - CCLabelTTF:create("Off", "Arial-BoldMT", 16) + local pSwitchControl = cc.ControlSwitch:create( + cc.Sprite:create("extensions/switch-mask.png"), + cc.Sprite:create("extensions/switch-on.png"), + cc.Sprite:create("extensions/switch-off.png"), + cc.Sprite:create("extensions/switch-thumb.png"), + cc.LabelTTF:create("On", "Arial-BoldMT", 16), + cc.LabelTTF:create("Off", "Arial-BoldMT", 16) ) - pSwitchControl:setPosition(CCPoint (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0)) + pSwitchControl:setPosition(cc.p (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0)) pNode:addChild(pSwitchControl) - pSwitchControl:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + pSwitchControl:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) --Set the layer size - pNode:setContentSize(CCSize(dLayer_width, 0)) - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(cc.size(dLayer_width, 0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) --Update the value label valueChanged(pSwitchControl) @@ -528,16 +528,16 @@ local function runCCControlTest() --Hvs:HelloVariableSize local function HvsStandardButtonWithTitle(pStrTitle) -- Creates and return a button with a default background and title color. - local pBackgroundButton = CCScale9Sprite:create("extensions/button.png") - local pBackgroundHighlightedButton = CCScale9Sprite:create("extensions/buttonHighlighted.png") + local pBackgroundButton = cc.Scale9Sprite:create("extensions/button.png") + local pBackgroundHighlightedButton = cc.Scale9Sprite:create("extensions/buttonHighlighted.png") - pTitleButton = CCLabelTTF:create(pStrTitle, "Marker Felt", 30) + pTitleButton = cc.LabelTTF:create(pStrTitle, "Marker Felt", 30) - pTitleButton:setColor(Color3B(159, 168, 176)) + pTitleButton:setColor(cc.c3b(159, 168, 176)) - local pButton = CCControlButton:create(pTitleButton, pBackgroundButton) - pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, CCControlStateHighlighted) - pButton:setTitleColorForState(Color3B(255,255,255), CCControlStateHighlighted) + local pButton = cc.ControlButton:create(pTitleButton, pBackgroundButton) + pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) + pButton:setTitleColorForState(cc.c3b(255,255,255), cc.ControlStateHighlighted) return pButton end @@ -547,14 +547,14 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() - local strArray = CCArray:create() - strArray:addObject(CCString:create("Hello")) - strArray:addObject(CCString:create("Variable")) - strArray:addObject(CCString:create("Size")) - strArray:addObject(CCString:create("!")) + local screenSize = cc.Director:getInstance():getWinSize() + local strArray = cc.Array:create() + strArray:addObject(cc.String:create("Hello")) + strArray:addObject(cc.String:create("Variable")) + strArray:addObject(cc.String:create("Size")) + strArray:addObject(cc.String:create("!")) - local pNode = CCNode:create() + local pNode = cc.Node:create() pLayer:addChild(pNode,1) local dTotalWidth = 0 local dHeight = 0 @@ -563,10 +563,10 @@ local function runCCControlTest() local i = 0 local nLen = strArray:count() for i = 0, nLen - 1 do - pObj = tolua.cast(strArray:objectAtIndex(i), "CCString") + pObj = tolua.cast(strArray:objectAtIndex(i), "String") --Creates a button with pLayer string as title local pButton = HvsStandardButtonWithTitle(pObj:getCString()) - pButton:setPosition(CCPoint (dTotalWidth + pButton:getContentSize().width / 2, pButton:getContentSize().height / 2)) + pButton:setPosition(cc.p (dTotalWidth + pButton:getContentSize().width / 2, pButton:getContentSize().height / 2)) pNode:addChild(pButton) --Compute the size of the layer @@ -574,30 +574,30 @@ local function runCCControlTest() dTotalWidth = dTotalWidth + pButton:getContentSize().width end - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) - pNode:setContentSize(CCSize(dTotalWidth, dHeight)) - pNode:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) + pNode:setContentSize(cc.size(dTotalWidth, dHeight)) + pNode:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) --Add the black background - local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSize(dTotalWidth + 14, dHeight + 14)) - pBackground:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + local pBackground = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackground:setContentSize(cc.size(dTotalWidth + 14, dHeight + 14)) + pBackground:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackground) end local function StylingStandardButtonWithTitle(pStrTitle) - local pBackgroundButton = CCScale9Sprite:create("extensions/button.png") - pBackgroundButton:setPreferredSize(CCSize(45, 45)) - local pBackgroundHighlightedButton = CCScale9Sprite:create("extensions/buttonHighlighted.png") - pBackgroundHighlightedButton:setPreferredSize(CCSize(45, 45)) + local pBackgroundButton = cc.Scale9Sprite:create("extensions/button.png") + pBackgroundButton:setPreferredSize(cc.size(45, 45)) + local pBackgroundHighlightedButton = cc.Scale9Sprite:create("extensions/buttonHighlighted.png") + pBackgroundHighlightedButton:setPreferredSize(cc.size(45, 45)) - local pTitleButton = CCLabelTTF:create(pStrTitle, "Marker Felt", 30) + local pTitleButton = cc.LabelTTF:create(pStrTitle, "Marker Felt", 30) - pTitleButton:setColor(Color3B(159, 168, 176)) + pTitleButton:setColor(cc.c3b(159, 168, 176)) - local pButton = CCControlButton:create(pTitleButton, pBackgroundButton) - pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, CCControlStateHighlighted) - pButton:setTitleColorForState(Color3B(255,255,255), CCControlStateHighlighted) + local pButton = cc.ControlButton:create(pTitleButton, pBackgroundButton) + pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) + pButton:setTitleColorForState(cc.c3b(255,255,255), cc.ControlStateHighlighted) return pButton end @@ -607,9 +607,9 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() - local pNode = CCNode:create() + local pNode = cc.Node:create() pLayer:addChild(pNode, 1) local nSpace = 10 @@ -622,9 +622,9 @@ local function runCCControlTest() for j = 0, 2 do --Add the buttons local strFmt = string.format("%d",math.random(0,32767) % 30) - local pButton = StylingStandardButtonWithTitle(CCString:create(strFmt):getCString()) + local pButton = StylingStandardButtonWithTitle(cc.String:create(strFmt):getCString()) pButton:setAdjustBackgroundImage(false) - pButton:setPosition(CCPoint (pButton:getContentSize().width / 2 + (pButton:getContentSize().width + nSpace) * i, + pButton:setPosition(cc.p (pButton:getContentSize().width / 2 + (pButton:getContentSize().width + nSpace) * i, pButton:getContentSize().height / 2 + (pButton:getContentSize().height + nSpace) * j)) pNode:addChild(pButton) @@ -635,14 +635,14 @@ local function runCCControlTest() end - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) - pNode:setContentSize(CCSize(nMax_w, nMax_h)) - pNode:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) + pNode:setContentSize(cc.size(nMax_w, nMax_h)) + pNode:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) --Add the black background - local pBackgroundButton = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackgroundButton:setContentSize(CCSize(nMax_w + 14, nMax_h + 14)) - pBackgroundButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + local pBackgroundButton = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackgroundButton:setContentSize(cc.size(nMax_w + 14, nMax_h + 14)) + pBackgroundButton:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackgroundButton) end @@ -651,99 +651,99 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() --Add a label in which the button events will be displayed local pDisplayValueLabel = nil - pDisplayValueLabel = CCLabelTTF:create("No Event", "Marker Felt", 32) - pDisplayValueLabel:setAnchorPoint(CCPoint(0.5, -1)) - pDisplayValueLabel:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + pDisplayValueLabel = cc.LabelTTF:create("No Event", "Marker Felt", 32) + pDisplayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + pDisplayValueLabel:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pDisplayValueLabel, 1) --Add the button - local pBackgroundButton = CCScale9Sprite:create("extensions/button.png") - local pBackgroundHighlightedButton = CCScale9Sprite:create("extensions/buttonHighlighted.png") + local pBackgroundButton = cc.Scale9Sprite:create("extensions/button.png") + local pBackgroundHighlightedButton = cc.Scale9Sprite:create("extensions/buttonHighlighted.png") - local pTitleButtonLabel = CCLabelTTF:create("Touch Me!", "Marker Felt", 30) - pTitleButtonLabel:setColor(Color3B(159, 168, 176)) + local pTitleButtonLabel = cc.LabelTTF:create("Touch Me!", "Marker Felt", 30) + pTitleButtonLabel:setColor(cc.c3b(159, 168, 176)) - local pControlButton = CCControlButton:create(pTitleButtonLabel, pBackgroundButton) + local pControlButton = cc.ControlButton:create(pTitleButtonLabel, pBackgroundButton) local function touchDownAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Touch Down"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Touch Down"):getCString()) end local function touchDragInsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Drag Inside"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Drag Inside"):getCString()) end local function touchDragOutsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Drag Outside"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Drag Outside"):getCString()) end local function touchDragEnterAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Drag Enter"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Drag Enter"):getCString()) end local function touchDragExitAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Drag Exit"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Drag Exit"):getCString()) end local function touchUpInsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Touch Up Inside."):getCString()) + pDisplayValueLabel:setString(cc.String:create("Touch Up Inside."):getCString()) end local function touchUpOutsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Touch Up Outside."):getCString()) + pDisplayValueLabel:setString(cc.String:create("Touch Up Outside."):getCString()) end local function touchCancelAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Touch Cancel"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Touch Cancel"):getCString()) end - pControlButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, CCControlStateHighlighted) - pControlButton:setTitleColorForState(Color3B(255, 255, 255), CCControlStateHighlighted) - pControlButton:setAnchorPoint(CCPoint(0.5, 1)) - pControlButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) - pControlButton:registerControlEventHandler(touchDownAction,CCControlEventTouchDown) - pControlButton:registerControlEventHandler(touchDragInsideAction,CCControlEventTouchDragInside) - pControlButton:registerControlEventHandler(touchDragOutsideAction,CCControlEventTouchDragOutside) - pControlButton:registerControlEventHandler(touchDragEnterAction,CCControlEventTouchDragEnter) - pControlButton:registerControlEventHandler(touchDragExitAction,CCControlEventTouchDragExit) - pControlButton:registerControlEventHandler(touchUpInsideAction,CCControlEventTouchUpInside) - pControlButton:registerControlEventHandler(touchUpOutsideAction,CCControlEventTouchUpOutside) - pControlButton:registerControlEventHandler(touchCancelAction,CCControlEventTouchCancel) + pControlButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) + pControlButton:setTitleColorForState(cc.c3b(255, 255, 255), cc.ControlStateHighlighted) + pControlButton:setAnchorPoint(cc.p(0.5, 1)) + pControlButton:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) + pControlButton:registerControlEventHandler(touchDownAction,cc.ControlEventTouchDown) + pControlButton:registerControlEventHandler(touchDragInsideAction,cc.ControlEventTouchDragInside) + pControlButton:registerControlEventHandler(touchDragOutsideAction,cc.ControlEventTouchDragOutside) + pControlButton:registerControlEventHandler(touchDragEnterAction,cc.ControlEventTouchDragEnter) + pControlButton:registerControlEventHandler(touchDragExitAction,cc.ControlEventTouchDragExit) + pControlButton:registerControlEventHandler(touchUpInsideAction,cc.ControlEventTouchUpInside) + pControlButton:registerControlEventHandler(touchUpOutsideAction,cc.ControlEventTouchUpOutside) + pControlButton:registerControlEventHandler(touchCancelAction,cc.ControlEventTouchCancel) pLayer:addChild(pControlButton, 1) --Add the black background - local pBackgroundButton = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackgroundButton:setContentSize(CCSize(300, 170)) - pBackgroundButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + local pBackgroundButton = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackgroundButton:setContentSize(cc.size(300, 170)) + pBackgroundButton:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackgroundButton) end --PotentiometerTest @@ -752,23 +752,23 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() - local pNode = CCNode:create() - pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) + local pNode = cc.Node:create() + pNode:setPosition(cc.p (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 -- Add the black background for the text - local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSize(80, 50)) - pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + local pBackground = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackground:setContentSize(cc.size(80, 50)) + pBackground:setPosition(cc.p(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width - local pDisplayValueLabel = CCLabelTTF:create("", "HelveticaNeue-Bold", 30) + local pDisplayValueLabel = cc.LabelTTF:create("", "HelveticaNeue-Bold", 30) pDisplayValueLabel:setPosition(pBackground:getPosition()) pNode:addChild(pDisplayValueLabel) @@ -778,24 +778,24 @@ local function runCCControlTest() return end - local pControl = tolua.cast(pSender,"CCControlPotentiometer") + local pControl = tolua.cast(pSender,"ControlPotentiometer") local strFmt = string.format("%0.2f",pControl:getValue()) - pDisplayValueLabel:setString(CCString:create(strFmt):getCString()) + pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) end - local pPotentiometer = CCControlPotentiometer:create("extensions/potentiometerTrack.png","extensions/potentiometerProgress.png" + local pPotentiometer = cc.ControlPotentiometer:create("extensions/potentiometerTrack.png","extensions/potentiometerProgress.png" ,"extensions/potentiometerButton.png") - pPotentiometer:setPosition(CCPoint (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0)) + pPotentiometer:setPosition(cc.p (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0)) -- When the value of the slider will change, the given selector will be call - pPotentiometer:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + pPotentiometer:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) pNode:addChild(pPotentiometer) dLayer_width = dLayer_width + pPotentiometer:getContentSize().width -- Set the layer size - pNode:setContentSize(CCSize(dLayer_width, 0)) - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(cc.size(dLayer_width, 0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) -- Update the value label valueChanged(pPotentiometer) @@ -806,49 +806,49 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() - local pNode = CCNode:create() - pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) + local pNode = cc.Node:create() + pNode:setPosition(cc.p (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local layer_width = 0 -- Add the black background for the text - local background = CCScale9Sprite:create("extensions/buttonBackground.png") - background:setContentSize(CCSize(100, 50)) - background:setPosition(CCPoint(layer_width + background:getContentSize().width / 2.0, 0)) + local background = cc.Scale9Sprite:create("extensions/buttonBackground.png") + background:setContentSize(cc.size(100, 50)) + background:setPosition(cc.p(layer_width + background:getContentSize().width / 2.0, 0)) pNode:addChild(background) - local pDisplayValueLabel = CCLabelTTF:create("0", "HelveticaNeue-Bold", 30) + local pDisplayValueLabel = cc.LabelTTF:create("0", "HelveticaNeue-Bold", 30) pDisplayValueLabel:setPosition(background:getPosition()) pNode:addChild(pDisplayValueLabel) layer_width = layer_width + background:getContentSize().width - local minusSprite = CCSprite:create("extensions/stepper-minus.png") - local plusSprite = CCSprite:create("extensions/stepper-plus.png") + local minusSprite = cc.Sprite:create("extensions/stepper-minus.png") + local plusSprite = cc.Sprite:create("extensions/stepper-plus.png") local function valueChanged(pSender) if nil == pDisplayValueLabel or nil == pSender then return end - local pControl = tolua.cast(pSender,"CCControlStepper") + local pControl = tolua.cast(pSender,"ControlStepper") local strFmt = string.format("%0.02f",pControl:getValue() ) - pDisplayValueLabel:setString(CCString:create(strFmt):getCString()) + pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) end - local stepper = CCControlStepper:create(minusSprite, plusSprite) - stepper:setPosition(CCPoint (layer_width + 10 + stepper:getContentSize().width / 2, 0)) - stepper:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + local stepper = cc.ControlStepper:create(minusSprite, plusSprite) + stepper:setPosition(cc.p (layer_width + 10 + stepper:getContentSize().width / 2, 0)) + stepper:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) pNode:addChild(stepper) layer_width = layer_width + stepper:getContentSize().width -- Set the layer size - pNode:setContentSize(CCSize(layer_width, 0)) - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(cc.size(layer_width, 0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) -- Update the value label valueChanged(stepper) @@ -876,18 +876,18 @@ local function runCCControlTest() function CurrentControlScene() pNewScene = nil - pNewScene = CCScene:create() - local pNewLayer = CCLayer:create() + pNewScene = cc.Scene:create() + local pNewLayer = cc.Layer:create() BaseInitSceneLayer(pNewLayer,GetControlExtensionsTitle()) InitSpecialSceneLayer(pNewLayer) pNewScene:addChild(pNewLayer) if nil ~= pNewScene then - CCDirector:getInstance():replaceScene(pNewScene) + cc.Director:getInstance():replaceScene(pNewScene) end end - local pNewLayer = CCLayer:create() + local pNewLayer = cc.Layer:create() BaseInitSceneLayer(pNewLayer,GetControlExtensionsTitle()) InitSpecialSceneLayer(pNewLayer) pNewScene:addChild(pNewLayer) @@ -896,32 +896,32 @@ local function runCCControlTest() end local function runEditBoxTest() - local newScene = CCScene:create() - local newLayer = CCLayer:create() - local visibleOrigin = CCEGLView:getInstance():getVisibleOrigin() - local visibleSize = CCEGLView:getInstance():getVisibleSize() + local newScene = cc.Scene:create() + local newLayer = cc.Layer:create() + local visibleOrigin = cc.EGLView:getInstance():getVisibleOrigin() + local visibleSize = cc.EGLView:getInstance():getVisibleSize() - local pBg = CCSprite:create("Images/HelloWorld.png") - pBg:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) + local pBg = cc.Sprite:create("Images/HelloWorld.png") + pBg:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) newLayer:addChild(pBg) - local TTFShowEditReturn = CCLabelTTF:create("No edit control return!", "", 30) - TTFShowEditReturn:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)) + local TTFShowEditReturn = cc.LabelTTF:create("No edit control return!", "", 30) + TTFShowEditReturn:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)) newLayer:addChild(TTFShowEditReturn) -- Back Menu - local pToMainMenu = CCMenu:create() + local pToMainMenu = cc.Menu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(CCPoint(0, 0)) + pToMainMenu:setPosition(cc.p(0, 0)) newLayer:addChild(pToMainMenu,10) - local editBoxSize = CCSize(visibleSize.width - 100, 60) + local editBoxSize = cc.size(visibleSize.width - 100, 60) local EditName = nil local EditPassword = nil local EditEmail = nil local function editBoxTextEventHandle(strEventName,pSender) - local edit = tolua.cast(pSender,"CCEditBox") + local edit = tolua.cast(pSender,"EditBox") local strFmt if strEventName == "began" then strFmt = string.format("editBox %p DidBegin !", edit) @@ -945,18 +945,18 @@ local function runEditBoxTest() end end -- top - EditName = CCEditBox:create(editBoxSize, CCScale9Sprite:create("extensions/green_edit.png")) - EditName:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)) - local targetPlatform = CCApplication:getInstance():getTargetPlatform() + EditName = cc.EditBox:create(editBoxSize, cc.Scale9Sprite:create("extensions/green_edit.png")) + EditName:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)) + local targetPlatform = cc.Application:getInstance():getTargetPlatform() if kTargetIphone == targetPlatform or kTargetIpad == targetPlatform then EditName:setFontName("Paint Boy") else EditName:setFontName("fonts/Paint Boy.ttf") end EditName:setFontSize(25) - EditName:setFontColor(Color3B(255,0,0)) + EditName:setFontColor(cc.c3b(255,0,0)) EditName:setPlaceHolder("Name:") - EditName:setPlaceholderFontColor(Color3B(255,255,255)) + EditName:setPlaceholderFontColor(cc.c3b(255,255,255)) EditName:setMaxLength(8) EditName:setReturnType(kKeyboardReturnTypeDone) --Handler @@ -964,8 +964,8 @@ local function runEditBoxTest() newLayer:addChild(EditName) --middle - EditPassword = CCEditBox:create(editBoxSize, CCScale9Sprite:create("extensions/orange_edit.png")) - EditPassword:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) + EditPassword = cc.EditBox:create(editBoxSize, cc.Scale9Sprite:create("extensions/orange_edit.png")) + EditPassword:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) if kTargetIphone == targetPlatform or kTargetIpad == targetPlatform then EditPassword:setFont("American Typewriter", 30) else @@ -973,7 +973,7 @@ local function runEditBoxTest() end - EditPassword:setFontColor(Color3B(0,255,0)) + EditPassword:setFontColor(cc.c3b(0,255,0)) EditPassword:setPlaceHolder("Password:") EditPassword:setMaxLength(6) EditPassword:setInputFlag(kEditBoxInputFlagPassword) @@ -982,14 +982,14 @@ local function runEditBoxTest() newLayer:addChild(EditPassword) --bottom - EditEmail = CCEditBox:create(CCSize(editBoxSize.width, editBoxSize.height), CCScale9Sprite:create("extensions/yellow_edit.png")) - EditEmail:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)) - EditEmail:setAnchorPoint(CCPoint(0.5, 1.0)) + EditEmail = cc.EditBox:create(cc.size(editBoxSize.width, editBoxSize.height), cc.Scale9Sprite:create("extensions/yellow_edit.png")) + EditEmail:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)) + EditEmail:setAnchorPoint(cc.p(0.5, 1.0)) EditEmail:setPlaceHolder("Email:") EditEmail:setInputMode(kEditBoxInputModeEmailAddr) EditEmail:registerScriptEditBoxHandler(editBoxTextEventHandle) newLayer:addChild(EditEmail) - newLayer:setPosition(CCPoint(10, 20)) + newLayer:setPosition(cc.p(10, 20)) newScene:addChild(newLayer) @@ -997,20 +997,20 @@ local function runEditBoxTest() end local function runScrollViewTest() - local newScene = CCScene:create() - local newLayer = CCLayer:create() + local newScene = cc.Scene:create() + local newLayer = cc.Layer:create() -- Back Menu - local pToMainMenu = CCMenu:create() + local pToMainMenu = cc.Menu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(CCPoint(0, 0)) + pToMainMenu:setPosition(cc.p(0, 0)) newLayer:addChild(pToMainMenu,10) - local layerColor = CCLayerColor:create(Color4B(128,64,0,255)) + local layerColor = cc.LayerColor:create(cc.c4b(128,64,0,255)) newLayer:addChild(layerColor) - local scrollView1 = CCScrollView:create() - local screenSize = CCDirector:getInstance():getWinSize() + local scrollView1 = cc.ScrollView:create() + local screenSize = cc.Director:getInstance():getWinSize() local function scrollView1DidScroll() print("scrollView1DidScroll") end @@ -1018,11 +1018,11 @@ local function runScrollViewTest() print("scrollView1DidZoom") end if nil ~= scrollView1 then - scrollView1:setViewSize(CCSize(screenSize.width / 2,screenSize.height)) - scrollView1:setPosition(CCPoint(0,0)) + scrollView1:setViewSize(cc.size(screenSize.width / 2,screenSize.height)) + scrollView1:setPosition(cc.p(0,0)) scrollView1:setScale(1.0) scrollView1:ignoreAnchorPointForPosition(true) - local flowersprite1 = CCSprite:create("ccb/flower.jpg") + local flowersprite1 = cc.Sprite:create("ccb/flower.jpg") if nil ~= flowersprite1 then scrollView1:setContainer(flowersprite1) scrollView1:updateInset() @@ -1036,7 +1036,7 @@ local function runScrollViewTest() end newLayer:addChild(scrollView1) - local scrollView2 = CCScrollView:create() + local scrollView2 = cc.ScrollView:create() local function scrollView2DidScroll() print("scrollView2DidScroll") end @@ -1044,11 +1044,11 @@ local function runScrollViewTest() print("scrollView2DidZoom") end if nil ~= scrollView2 then - scrollView2:setViewSize(CCSize(screenSize.width / 2,screenSize.height)) - scrollView2:setPosition(CCPoint(screenSize.width / 2,0)) + scrollView2:setViewSize(cc.size(screenSize.width / 2,screenSize.height)) + scrollView2:setPosition(cc.p(screenSize.width / 2,0)) scrollView2:setScale(1.0) scrollView2:ignoreAnchorPointForPosition(true) - local flowersprite2 = CCSprite:create("ccb/flower.jpg") + local flowersprite2 = cc.Sprite:create("ccb/flower.jpg") if nil ~= flowersprite2 then scrollView2:setContainer(flowersprite2) scrollView2:updateInset() @@ -1082,7 +1082,7 @@ local CreateExtensionsTestTable = local function ExtensionsMainLayer() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local function CreateExtensionsTestScene(nPerformanceNo) local pNewscene = CreateExtensionsTestTable[nPerformanceNo]() @@ -1094,16 +1094,16 @@ local function ExtensionsMainLayer() local nIdx = pMenuItem:getZOrder() - kItemTagBasic local ExtensionsTestScene = CreateExtensionsTestScene(nIdx) if nil ~= ExtensionsTestScene then - CCDirector:getInstance():replaceScene(ExtensionsTestScene) + cc.Director:getInstance():replaceScene(ExtensionsTestScene) end end - local layer = CCLayer:create() - local menu = CCMenu:create() - menu:setPosition(CCPoint(0, 0)) - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local targetPlatform = CCApplication:getInstance():getTargetPlatform() + local layer = cc.Layer:create() + local menu = cc.Menu:create() + menu:setPosition(cc.p(0, 0)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local targetPlatform = cc.Application:getInstance():getTargetPlatform() local bSupportWebSocket = false if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) then bSupportWebSocket = true @@ -1115,7 +1115,7 @@ local function ExtensionsMainLayer() bSupportEdit = true end for i = 1, ExtensionTestEnum.TEST_MAX_COUNT do - local item = CCMenuItemFont:create(testsName[i]) + local item = cc.MenuItemFont:create(testsName[i]) item:registerScriptTapHandler(menuCallback) item:setPosition(s.width / 2, s.height - i * LINE_SPACE) menu:addChild(item, kItemTagBasic + i) @@ -1135,7 +1135,7 @@ end -- Extensions Test ------------------------------------- function ExtensionsTestMain() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(ExtensionsMainLayer()) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua index 5314142ab4..04e54d2842 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua @@ -49,12 +49,14 @@ local function setEnableRecursiveCascading(node, enable) local children = node:getChildren() if children == nil then -- cclog("children is nil") + print("children is nil") return end local i = 0 local len = table.getn(children) for i = 0, len-1, 1 do + print("come in") local child = tolua.cast(children[i + 1], "Node") setEnableRecursiveCascading(child, enable) end diff --git a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua index 6f9d193543..cb2dc86af3 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua @@ -21,38 +21,38 @@ local MID_BACKCALLBACK = 1009 local function MenuLayerMainMenu() local m_disabledItem = nil - local ret = CCLayer:create() + local ret = cc.Layer:create() ret:setTouchEnabled(true) - ret:setTouchPriority(kCCMenuHandlerPriority + 1) - ret:setTouchMode(kCCTouchesOneByOne) + ret:setTouchPriority(cc.MENU_HANDLER_PRIORITY + 1) + ret:setTouchMode(cc.TOUCHES_ONE_BY_ONE ) -- Font Item - local spriteNormal = CCSprite:create(s_MenuItem, CCRect(0,23*2,115,23)) - local spriteSelected = CCSprite:create(s_MenuItem, CCRect(0,23*1,115,23)) - local spriteDisabled = CCSprite:create(s_MenuItem, CCRect(0,23*0,115,23)) + local spriteNormal = cc.Sprite:create(s_MenuItem, cc.rect(0,23*2,115,23)) + local spriteSelected = cc.Sprite:create(s_MenuItem, cc.rect(0,23*1,115,23)) + local spriteDisabled = cc.Sprite:create(s_MenuItem, cc.rect(0,23*0,115,23)) - local item1 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) + local item1 = cc.MenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) local function menuCallback(sender) cclog("menuCallback...") - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(1) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(1) end item1:registerScriptTapHandler(menuCallback) -- Image Item local function menuCallback2(sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(2) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(2) end - local item2 = CCMenuItemImage:create(s_SendScore, s_PressSendScore) + local item2 = cc.MenuItemImage:create(s_SendScore, s_PressSendScore) item2:registerScriptTapHandler(menuCallback2) local schedulerEntry = nil - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() local function allowTouches(dt) - local pDirector = CCDirector:getInstance() - --pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority+1, ret) + local pDirector = cc.Director:getInstance() + --pDirector:getTouchDispatcher():setPriority(cc.MENU_HANDLER_PRIORITY +1, ret) if nil ~= schedulerEntry then scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil @@ -63,57 +63,57 @@ local function MenuLayerMainMenu() local function menuCallbackDisabled(sender) -- hijack all touch events for 5 seconds - local pDirector = CCDirector:getInstance() - --pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority-1, ret) + local pDirector = cc.Director:getInstance() + --pDirector:getTouchDispatcher():setPriority(cc.MENU_HANDLER_PRIORITY -1, ret) schedulerEntry = scheduler:scheduleScriptFunc(allowTouches, 5, false) cclog("TOUCHES DISABLED FOR 5 SECONDS") end -- Label Item (LabelAtlas) - local labelAtlas = CCLabelAtlas:create("0123456789", "fonts/labelatlas.png", 16, 24, string.byte('.')) - local item3 = CCMenuItemLabel:create(labelAtlas) + local labelAtlas = cc.LabelAtlas:_create("0123456789", "fonts/labelatlas.png", 16, 24, string.byte('.')) + local item3 = cc.MenuItemLabel:create(labelAtlas) item3:registerScriptTapHandler(menuCallbackDisabled) - item3:setDisabledColor( Color3B(32,32,64) ) - item3:setColor( Color3B(200,200,255) ) + item3:setDisabledColor( cc.c3b(32,32,64) ) + item3:setColor( cc.c3b(200,200,255) ) local function menuCallbackEnable(sender) m_disabledItem:setEnabled(not m_disabledItem:isEnabled() ) end -- Font Item - local item4 = CCMenuItemFont:create("I toggle enable items") + local item4 = cc.MenuItemFont:create("I toggle enable items") item4:registerScriptTapHandler(menuCallbackEnable) item4:setFontSizeObj(20) - CCMenuItemFont:setFontName("Marker Felt") + cc.MenuItemFont:setFontName("Marker Felt") local function menuCallbackConfig(sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(3) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(3) end - -- Label Item (CCLabelBMFont) - local label = CCLabelBMFont:create("configuration", "fonts/bitmapFontTest3.fnt") - local item5 = CCMenuItemLabel:create(label) + -- Label Item (cc.LabelBMFont) + local label = cc.LabelBMFont:create("configuration", "fonts/bitmapFontTest3.fnt") + local item5 = cc.MenuItemLabel:create(label) item5:registerScriptTapHandler(menuCallbackConfig) -- Testing issue #500 item5:setScale( 0.8 ) local function menuCallbackPriorityTest(pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(4) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(4) end -- Events - CCMenuItemFont:setFontName("Marker Felt") - local item6 = CCMenuItemFont:create("Priority Test") + cc.MenuItemFont:setFontName("Marker Felt") + local item6 = cc.MenuItemFont:create("Priority Test") item6:registerScriptTapHandler(menuCallbackPriorityTest) local function menuCallbackBugsTest(pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(5) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5) end -- Bugs Item - local item7 = CCMenuItemFont:create("Bugs") + local item7 = cc.MenuItemFont:create("Bugs") item7:registerScriptTapHandler(menuCallbackBugsTest) local function onQuit(sender) @@ -121,25 +121,22 @@ local function MenuLayerMainMenu() end -- Font Item - local item8 = CCMenuItemFont:create("Quit") + local item8 = cc.MenuItemFont:create("Quit") item8:registerScriptTapHandler(onQuit) local function menuMovingCallback(pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(6) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(6) end - local item9 = CCMenuItemFont:create("Remove menu item when moving") + local item9 = cc.MenuItemFont:create("Remove menu item when moving") item9:registerScriptTapHandler(menuMovingCallback) - local color_action = CCTintBy:create(0.5, 0, -255, -255) + local color_action = cc.TintBy:create(0.5, 0, -255, -255) local color_back = color_action:reverse() - local arr = CCArray:create() - arr:addObject(color_action) - arr:addObject(color_back) - local seq = CCSequence:create(arr) - item8:runAction(CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(color_action, color_back) + item8:runAction(cc.RepeatForever:create(seq)) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) @@ -154,27 +151,27 @@ local function MenuLayerMainMenu() menu:alignItemsVertically() -- elastic effect - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local i = 0 local child = nil local pArray = menu:getChildren() - local len = pArray:count() + local len = table.getn(pArray) local pObject = nil for i = 0, len-1 do - pObject = pArray:objectAtIndex(i) + pObject = pArray[i + 1] if pObject == nil then break end - child = tolua.cast(pObject, "CCNode") - - local dstPointX, dstPointY = child:getPosition() + child = tolua.cast(pObject, "Node") + local dstPoint = child:getPosition() + local dstPointX, dstPointY = dstPoint.x,dstPoint.y local offset = s.width/2 + 50 if i % 2 == 0 then offset = 0-offset end - child:setPosition( CCPoint( dstPointX + offset, dstPointY) ) - child:runAction( CCEaseElasticOut:create(CCMoveBy:create(2, CCPoint(dstPointX - offset,0)), 0.35) ) + child:setPosition( cc.p( dstPointX + offset, dstPointY) ) + child:runAction( cc.EaseElasticOut:create(cc.MoveBy:create(2, cc.p(dstPointX - offset,0)), 0.35) ) end m_disabledItem = item3 @@ -183,7 +180,7 @@ local function MenuLayerMainMenu() m_disabledItem:setEnabled( false ) ret:addChild(menu) - menu:setPosition(CCPoint(s.width/2, s.height/2)) + menu:setPosition(cc.p(s.width/2, s.height/2)) -- local schedulerEntry = nil local function onNodeEvent(event) @@ -208,25 +205,27 @@ end -- -------------------------------------------------------------------- local function MenuLayer2() - local ret = CCLayer:create() + local ret = cc.Layer:create() local m_centeredMenu = nil local m_alignedH = false local function alignMenusH() local i = 0 for i=0, 1 do - local menu = tolua.cast(ret:getChildByTag(100+i), "CCMenu") + local menu = tolua.cast(ret:getChildByTag(100+i), "Menu") menu:setPosition( m_centeredMenu ) if i==0 then -- TIP: if no padding, padding = 5 menu:alignItemsHorizontally() - local x, y = menu:getPosition() - menu:setPosition( CCPoint.__add(CCPoint(x, y), CCPoint(0,30)) ) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + menu:setPosition( cc.pAdd(cc.p(x, y), cc.p(0,30)) ) else -- TIP: but padding is configurable menu:alignItemsHorizontallyWithPadding(40) - local x, y = menu:getPosition() - menu:setPosition( CCPoint.__sub(CCPoint(x, y), CCPoint(0,30)) ) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + menu:setPosition( cc.pSub(cc.p(x, y), cc.p(0,30)) ) end end end @@ -234,28 +233,30 @@ local function MenuLayer2() local function alignMenusV() local i = 0 for i=0, 1 do - local menu = tolua.cast(ret:getChildByTag(100+i), "CCMenu") + local menu = tolua.cast(ret:getChildByTag(100+i), "Menu") menu:setPosition( m_centeredMenu ) if i==0 then -- TIP: if no padding, padding = 5 menu:alignItemsVertically() - local x, y = menu:getPosition() - menu:setPosition( CCPoint.__add(CCPoint(x, y), CCPoint(100,0)) ) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + menu:setPosition( cc.pAdd(cc.p(x, y), cc.p(100,0)) ) else -- TIP: but padding is configurable menu:alignItemsVerticallyWithPadding(40) - local x, y = menu:getPosition() - menu:setPosition( CCPoint.__sub(CCPoint(x, y), CCPoint(100,0)) ) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + menu:setPosition( cc.pSub(cc.p(x, y), cc.p(100,0)) ) end end end local function menuCallback(sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end local function menuCallbackOpacity(tag, sender) - local menu = tolua.cast(sender:getParent(), "CCMenu") + local menu = tolua.cast(sender:getParent(), "Menu") local opacity = menu:getOpacity() if opacity == 128 then menu:setOpacity(255) @@ -276,34 +277,34 @@ local function MenuLayer2() local i = 0 for i=0, 1 do - local item1 = CCMenuItemImage:create(s_PlayNormal, s_PlaySelect) + local item1 = cc.MenuItemImage:create(s_PlayNormal, s_PlaySelect) item1:registerScriptTapHandler(menuCallback) - local item2 = CCMenuItemImage:create(s_HighNormal, s_HighSelect) + local item2 = cc.MenuItemImage:create(s_HighNormal, s_HighSelect) item2:registerScriptTapHandler(menuCallbackOpacity) - local item3 = CCMenuItemImage:create(s_AboutNormal, s_AboutSelect) + local item3 = cc.MenuItemImage:create(s_AboutNormal, s_AboutSelect) item3:registerScriptTapHandler(menuCallbackAlign) item1:setScaleX( 1.5 ) item2:setScaleX( 0.5 ) item3:setScaleX( 0.5 ) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - local s = CCDirector:getInstance():getWinSize() - menu:setPosition(CCPoint(s.width/2, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + menu:setPosition(cc.p(s.width/2, s.height/2)) menu:setTag( kTagMenu ) ret:addChild(menu, 0, 100+i) - - local x, y = menu:getPosition() - m_centeredMenu = CCPoint(x, y) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + m_centeredMenu = cc.p(x, y) end m_alignedH = true @@ -319,9 +320,9 @@ end -------------------------------------------------------------------- local function MenuLayer3() local m_disabledItem = nil - local ret = CCLayer:create() + local ret = cc.Layer:create() local function menuCallback(sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end local function menuCallback2(sender) @@ -334,58 +335,55 @@ local function MenuLayer3() cclog("MenuItemSprite clicked") end - CCMenuItemFont:setFontName("Marker Felt") - CCMenuItemFont:setFontSize(28) + cc.MenuItemFont:setFontName("Marker Felt") + cc.MenuItemFont:setFontSize(28) - local label = CCLabelBMFont:create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt") - local item1 = CCMenuItemLabel:create(label) + local label = cc.LabelBMFont:create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt") + local item1 = cc.MenuItemLabel:create(label) item1:registerScriptTapHandler(menuCallback2) - local item2 = CCMenuItemFont:create("--- Go Back ---") + local item2 = cc.MenuItemFont:create("--- Go Back ---") item2:registerScriptTapHandler(menuCallback) - local spriteNormal = CCSprite:create(s_MenuItem, CCRect(0,23*2,115,23)) - local spriteSelected = CCSprite:create(s_MenuItem, CCRect(0,23*1,115,23)) - local spriteDisabled = CCSprite:create(s_MenuItem, CCRect(0,23*0,115,23)) + local spriteNormal = cc.Sprite:create(s_MenuItem, cc.rect(0,23*2,115,23)) + local spriteSelected = cc.Sprite:create(s_MenuItem, cc.rect(0,23*1,115,23)) + local spriteDisabled = cc.Sprite:create(s_MenuItem, cc.rect(0,23*0,115,23)) - local item3 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) + local item3 = cc.MenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) item3:registerScriptTapHandler(menuCallback3) m_disabledItem = item3 item3:retain() m_disabledItem:setEnabled( false ) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition( CCPoint(0,0) ) + menu:setPosition( cc.p(0,0) ) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - item1:setPosition( CCPoint(s.width/2 - 150, s.height/2) ) - item2:setPosition( CCPoint(s.width/2 - 200, s.height/2) ) - item3:setPosition( CCPoint(s.width/2, s.height/2 - 100) ) + item1:setPosition( cc.p(s.width/2 - 150, s.height/2) ) + item2:setPosition( cc.p(s.width/2 - 200, s.height/2) ) + item3:setPosition( cc.p(s.width/2, s.height/2 - 100) ) - local jump = CCJumpBy:create(3, CCPoint(400,0), 50, 4) - local arr = CCArray:create() - arr:addObject(jump) - arr:addObject(jump:reverse()) - item2:runAction( CCRepeatForever:create(CCSequence:create( arr))) + local jump = cc.JumpBy:create(3, cc.p(400,0), 50, 4) + item2:runAction( cc.RepeatForever:create(cc.Sequence:create( jump, jump:reverse()))) - local spin1 = CCRotateBy:create(3, 360) - local spin2 = tolua.cast(spin1:clone(), "CCActionInterval") - local spin3 = tolua.cast(spin1:clone(), "CCActionInterval") + local spin1 = cc.RotateBy:create(3, 360) + local spin2 = tolua.cast(spin1:clone(), "ActionInterval") + local spin3 = tolua.cast(spin1:clone(), "ActionInterval") - item1:runAction( CCRepeatForever:create(spin1) ) - item2:runAction( CCRepeatForever:create(spin2) ) - item3:runAction( CCRepeatForever:create(spin3) ) + item1:runAction( cc.RepeatForever:create(spin1) ) + item2:runAction( cc.RepeatForever:create(spin2) ) + item3:runAction( cc.RepeatForever:create(spin3) ) ret:addChild( menu ) - menu:setPosition(CCPoint(0,0)) + menu:setPosition(cc.p(0,0)) local function onNodeEvent(event) if event == "exit" then @@ -407,70 +405,69 @@ end -- -------------------------------------------------------------------- local function MenuLayer4() - local ret = CCLayer:create() - CCMenuItemFont:setFontName("American Typewriter") - CCMenuItemFont:setFontSize(18) - local title1 = CCMenuItemFont:create("Sound") + local ret = cc.Layer:create() + cc.MenuItemFont:setFontName("American Typewriter") + cc.MenuItemFont:setFontSize(18) + local title1 = cc.MenuItemFont:create("Sound") title1:setEnabled(false) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize(34) - local item1 = CCMenuItemToggle:create(CCMenuItemFont:create( "On" )) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize(34) + local item1 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" )) local function menuCallback(tag, sender) - cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "CCMenuItemToggle"):getSelectedIndex() ) + cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "MenuItemToggle"):getSelectedIndex() ) end local function backCallback(tag, sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end item1:registerScriptTapHandler(menuCallback) - item1:addSubItem(CCMenuItemFont:create( "Off")) + item1:addSubItem(cc.MenuItemFont:create( "Off")) - CCMenuItemFont:setFontName( "American Typewriter" ) - CCMenuItemFont:setFontSize(18) - local title2 = CCMenuItemFont:create( "Music" ) + cc.MenuItemFont:setFontName( "American Typewriter" ) + cc.MenuItemFont:setFontSize(18) + local title2 = cc.MenuItemFont:create( "Music" ) title2:setEnabled(false) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize(34) - local item2 = CCMenuItemToggle:create(CCMenuItemFont:create( "On" )) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize(34) + local item2 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" )) item2:registerScriptTapHandler(menuCallback) - item2:addSubItem(CCMenuItemFont:create( "Off")) + item2:addSubItem(cc.MenuItemFont:create( "Off")) - CCMenuItemFont:setFontName( "American Typewriter" ) - CCMenuItemFont:setFontSize(18) - local title3 = CCMenuItemFont:create( "Quality" ) + cc.MenuItemFont:setFontName( "American Typewriter" ) + cc.MenuItemFont:setFontSize(18) + local title3 = cc.MenuItemFont:create( "Quality" ) title3:setEnabled( false ) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize(34) - local item3 = CCMenuItemToggle:create(CCMenuItemFont:create( "High" )) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize(34) + local item3 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "High" )) item3:registerScriptTapHandler(menuCallback) - item3:addSubItem(CCMenuItemFont:create( "Low" )) + item3:addSubItem(cc.MenuItemFont:create( "Low" )) - CCMenuItemFont:setFontName( "American Typewriter" ) - CCMenuItemFont:setFontSize(18) - local title4 = CCMenuItemFont:create( "Orientation" ) + cc.MenuItemFont:setFontName( "American Typewriter" ) + cc.MenuItemFont:setFontSize(18) + local title4 = cc.MenuItemFont:create( "Orientation" ) title4:setEnabled(false) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize(34) - local item4 = CCMenuItemToggle:create(CCMenuItemFont:create( "Off" )) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize(34) + local item4 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "Off"), + cc.MenuItemFont:create( "33%" ), + cc.MenuItemFont:create( "66%" ), + cc.MenuItemFont:create( "100%")) item4:registerScriptTapHandler(menuCallback) - item4:getSubItems():addObject( CCMenuItemFont:create( "33%" ) ) - item4:getSubItems():addObject( CCMenuItemFont:create( "66%" ) ) - item4:getSubItems():addObject( CCMenuItemFont:create( "100%" ) ) - -- you can change the one of the items by doing this item4:setSelectedIndex( 2 ) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize( 34 ) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize( 34 ) - local label = CCLabelBMFont:create( "go back", "fonts/bitmapFontTest3.fnt" ) - local back = CCMenuItemLabel:create(label) + local label = cc.LabelBMFont:create( "go back", "fonts/bitmapFontTest3.fnt" ) + local back = cc.MenuItemLabel:create(label) back:registerScriptTapHandler(backCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(title1) menu:addChild(title2) @@ -482,30 +479,24 @@ local function MenuLayer4() menu:addChild(item4 ) menu:addChild(back ) - local arr = CCArray:create() - arr:addObject(CCInteger:create(2)) - arr:addObject(CCInteger:create(2)) - arr:addObject(CCInteger:create(2)) - arr:addObject(CCInteger:create(2)) - arr:addObject(CCInteger:create(1)) - menu:alignItemsInColumnsWithArray(arr) + menu:alignItemsInColumns(2, 2, 2, 2, 1) ret:addChild(menu) - local s = CCDirector:getInstance():getWinSize() - menu:setPosition(CCPoint(s.width/2, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + menu:setPosition(cc.p(s.width/2, s.height/2)) return ret end local function MenuLayerPriorityTest() - local ret = CCLayer:create() + local ret = cc.Layer:create() local m_bPriority = false -- Testing empty menu - local m_pMenu1 = CCMenu:create() - local m_pMenu2 = CCMenu:create() + local m_pMenu1 = cc.Menu:create() + local m_pMenu2 = cc.Menu:create() local function menuCallback(tag, pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end local function enableMenuCallback() @@ -514,31 +505,28 @@ local function MenuLayerPriorityTest() local function disableMenuCallback(tag, pSender) m_pMenu1:setEnabled(false) - local wait = CCDelayTime:create(5) - local enable = CCCallFunc:create(enableMenuCallback) - local arr = CCArray:create() - arr:addObject(wait) - arr:addObject(enable) - local seq = CCSequence:create(arr) + local wait = cc.DelayTime:create(5) + local enable = cc.CallFunc:create(enableMenuCallback) + local seq = cc.Sequence:create(wait, enable) m_pMenu1:runAction(seq) end local function togglePriorityCallback(tag, pSender) if m_bPriority then - m_pMenu2:setHandlerPriority(kCCMenuHandlerPriority + 20) + m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY + 20) m_bPriority = false else - m_pMenu2:setHandlerPriority(kCCMenuHandlerPriority - 20) + m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY - 20) m_bPriority = true end end -- Menu 1 - CCMenuItemFont:setFontName("Marker Felt") - CCMenuItemFont:setFontSize(18) - local item1 = CCMenuItemFont:create("Return to Main Menu") + cc.MenuItemFont:setFontName("Marker Felt") + cc.MenuItemFont:setFontSize(18) + local item1 = cc.MenuItemFont:create("Return to Main Menu") item1:registerScriptTapHandler(menuCallback) - local item2 = CCMenuItemFont:create("Disable menu for 5 seconds") + local item2 = cc.MenuItemFont:create("Disable menu for 5 seconds") item2:registerScriptTapHandler(disableMenuCallback) m_pMenu1:addChild(item1) @@ -550,10 +538,10 @@ local function MenuLayerPriorityTest() -- Menu 2 m_bPriority = true - CCMenuItemFont:setFontSize(48) - item1 = CCMenuItemFont:create("Toggle priority") + cc.MenuItemFont:setFontSize(48) + item1 = cc.MenuItemFont:create("Toggle priority") item2:registerScriptTapHandler(togglePriorityCallback) - item1:setColor(Color3B(0,0,255)) + item1:setColor(cc.c3b(0,0,255)) m_pMenu2:addChild(item1) ret:addChild(m_pMenu2) return ret @@ -562,78 +550,78 @@ end -- BugsTest local function BugsTest() - local ret = CCLayer:create() + local ret = cc.Layer:create() local function issue1410MenuCallback(tag, pSender) - local menu = tolua.cast(pSender:getParent(), "CCMenu") + local menu = tolua.cast(pSender:getParent(), "Menu") menu:setTouchEnabled(false) menu:setTouchEnabled(true) cclog("NO CRASHES") end local function issue1410v2MenuCallback(tag, pSender) - local menu = tolua.cast(pSender:getParent(), "CCMenu") + local menu = tolua.cast(pSender:getParent(), "Menu") menu:setTouchEnabled(true) menu:setTouchEnabled(false) cclog("NO CRASHES. AND MENU SHOULD STOP WORKING") end local function backMenuCallback(tag, pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end - local issue1410 = CCMenuItemFont:create("Issue 1410") + local issue1410 = cc.MenuItemFont:create("Issue 1410") issue1410:registerScriptTapHandler(issue1410MenuCallback) - local issue1410_2 = CCMenuItemFont:create("Issue 1410 #2") + local issue1410_2 = cc.MenuItemFont:create("Issue 1410 #2") issue1410_2:registerScriptTapHandler(issue1410v2MenuCallback) - local back = CCMenuItemFont:create("Back") + local back = cc.MenuItemFont:create("Back") back:registerScriptTapHandler(backMenuCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(issue1410) menu:addChild(issue1410_2) menu:addChild(back) ret:addChild(menu) menu:alignItemsVertically() - local s = CCDirector:getInstance():getWinSize() - menu:setPosition(CCPoint(s.width/2, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + menu:setPosition(cc.p(s.width/2, s.height/2)) return ret end local function RemoveMenuItemWhenMove() - local ret = CCLayer:create() - local s = CCDirector:getInstance():getWinSize() + local ret = cc.Layer:create() + local s = cc.Director:getInstance():getWinSize() - local label = CCLabelTTF:create("click item and move, should not crash", "Arial", 20) - label:setPosition(CCPoint(s.width/2, s.height - 30)) + local label = cc.LabelTTF:create("click item and move, should not crash", "Arial", 20) + label:setPosition(cc.p(s.width/2, s.height - 30)) ret:addChild(label) - local item = CCMenuItemFont:create("item 1") + local item = cc.MenuItemFont:create("item 1") item:retain() - local back = CCMenuItemFont:create("go back") + local back = cc.MenuItemFont:create("go back") local function goBack(tag, pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end back:registerScriptTapHandler(goBack) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item) menu:addChild(back) ret:addChild(menu) menu:alignItemsVertically() - menu:setPosition(CCPoint(s.width/2, s.height/2)) + menu:setPosition(cc.p(s.width/2, s.height/2)) ret:setTouchEnabled(true) --[[ local function onNodeEvent(event) if event == "enter" then - CCDirector:getInstance():getTouchDispatcher():addTargetedDelegate(ret, -129, false) + cc.Director:getInstance():getTouchDispatcher():addTargetedDelegate(ret, -129, false) elseif event == "exit" then -- item:release() end @@ -647,7 +635,7 @@ local function RemoveMenuItemWhenMove() return true elseif eventType == "moved" then if item ~= nil then - item:removeFromParentAndCleanup(true) + item:removeFromParent(true) --item:release() --item = nil end @@ -660,7 +648,7 @@ end function MenuTestMain() cclog("MenuTestMain") - local scene = CCScene:create() + local scene = cc.Scene:create() local pLayer1 = MenuLayerMainMenu() local pLayer2 = MenuLayer2() @@ -671,17 +659,13 @@ function MenuTestMain() local pLayer6 = BugsTest() local pLayer7 = RemoveMenuItemWhenMove() - - local arr = CCArray:create() - arr:addObject(pLayer1) - arr:addObject(pLayer2) - arr:addObject(pLayer3) - arr:addObject(pLayer4) - arr:addObject(pLayer5) - arr:addObject(pLayer6) - arr:addObject(pLayer7) - - local layer = CCLayerMultiplex:createWithArray(arr) + local layer = cc.LayerMultiplex:create(pLayer1, + pLayer2, + pLayer3, + pLayer4, + pLayer5, + pLayer6, + pLayer7) scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua b/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua index b4458da4dc..60cd559053 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua @@ -3,8 +3,8 @@ local streak = nil local titleLabel = nil local subtitleLabel = nil -local s = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local s = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local firstTick = nil @@ -18,14 +18,14 @@ local function modeCallback(sender) end local function getBaseLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() - local itemMode = CCMenuItemToggle:create(CCMenuItemFont:create("Use High Quality Mode")) - itemMode:addSubItem(CCMenuItemFont:create("Use Fast Mode")) + local itemMode = cc.MenuItemToggle:create(cc.MenuItemFont:create("Use High Quality Mode")) + itemMode:addSubItem(cc.MenuItemFont:create("Use Fast Mode")) itemMode:registerScriptTapHandler(modeCallback) - local menuMode = CCMenu:create() + local menuMode = cc.Menu:create() menuMode:addChild(itemMode) - menuMode:setPosition(CCPoint(s.width / 2, s.height / 4)) + menuMode:setPosition(cc.p(s.width / 2, s.height / 4)) layer:addChild(menuMode) Helper.initWithLayer(layer) @@ -47,7 +47,7 @@ local function MotionStreakTest1_update(dt) return end - streak:setPosition(target:convertToWorldSpace(CCPoint(0, 0))) + streak:setPosition(target:convertToWorldSpace(cc.p(0, 0))) end local function MotionStreakTest1_onEnterOrExit(tag) @@ -61,32 +61,30 @@ end local function MotionStreakTest1() local layer = getBaseLayer() - root = CCSprite:create(s_pPathR1) + root = cc.Sprite:create(s_pPathR1) layer:addChild(root, 1) - root:setPosition(CCPoint(s.width / 2, s.height / 2)) + root:setPosition(cc.p(s.width / 2, s.height / 2)) - target = CCSprite:create(s_pPathR1) + target = cc.Sprite:create(s_pPathR1) root:addChild(target) - target:setPosition(CCPoint(s.width / 4, 0)) + target:setPosition(cc.p(s.width / 4, 0)) - streak = CCMotionStreak:create(2, 3, 32, Color3B(0, 255, 0), s_streak) + streak = cc.MotionStreak:create(2, 3, 32, cc.c3b(0, 255, 0), s_streak) layer:addChild(streak) - local a1 = CCRotateBy:create(2, 360) + local a1 = cc.RotateBy:create(2, 360) - local action1 = CCRepeatForever:create(a1) - local motion = CCMoveBy:create(2, CCPoint(100,0)) - root:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(motion, motion:reverse()))) + local action1 = cc.RepeatForever:create(a1) + local motion = cc.MoveBy:create(2, cc.p(100,0)) + root:runAction(cc.RepeatForever:create(cc.Sequence:create(motion, motion:reverse()))) root:runAction(action1) - local array = CCArray:create() - array:addObject(CCTintTo:create(0.2, 255, 0, 0)) - array:addObject(CCTintTo:create(0.2, 0, 255, 0)) - array:addObject(CCTintTo:create(0.2, 0, 0, 255)) - array:addObject(CCTintTo:create(0.2, 0, 255, 255)) - array:addObject(CCTintTo:create(0.2, 255, 255, 0)) - array:addObject(CCTintTo:create(0.2, 255, 255, 255)) - local colorAction = CCRepeatForever:create(CCSequence:create(array)) + local colorAction = cc.RepeatForever:create(cc.Sequence:create(cc.TintTo:create(0.2, 255, 0, 0), + cc.TintTo:create(0.2, 0, 255, 0), + cc.TintTo:create(0.2, 0, 0, 255), + cc.TintTo:create(0.2, 0, 255, 255), + cc.TintTo:create(0.2, 255, 255, 0), + cc.TintTo:create(0.2, 255, 255, 255))) streak:runAction(colorAction) @@ -103,10 +101,10 @@ end local function MotionStreakTest2() local layer = getBaseLayer() - streak = CCMotionStreak:create(3, 3, 64, Color3B(255, 255, 255), s_streak) + streak = cc.MotionStreak:create(3, 3, 64, cc.c3b(255, 255, 255), s_streak) layer:addChild(streak) - streak:setPosition(CCPoint(s.width / 2, s.height / 2)) + streak:setPosition(cc.p(s.width / 2, s.height / 2)) local function onTouchMoved(x, y) if firstTick == true then @@ -114,7 +112,7 @@ local function MotionStreakTest2() return end - streak:setPosition(CCPoint(x, y)) + streak:setPosition(cc.p(x, y)) end local function onTouch(eventType, x, y) @@ -149,7 +147,7 @@ local function Issue1358_update(dt) end fAngle = fAngle + 1.0 streak:setPosition( - CCPoint(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius)) + cc.p(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius)) end local function Issue1358_onEnterOrExit(tag) @@ -163,10 +161,10 @@ end local function Issue1358() local layer = getBaseLayer() - streak = CCMotionStreak:create(2.0, 1.0, 50.0, Color3B(255, 255, 0), "Images/Icon.png") + streak = cc.MotionStreak:create(2.0, 1.0, 50.0, cc.c3b(255, 255, 0), "Images/Icon.png") layer:addChild(streak) - center = CCPoint(s.width / 2, s.height / 2) + center = cc.p(s.width / 2, s.height / 2) fRadius = s.width / 3 fAngle = 0 @@ -179,7 +177,7 @@ local function Issue1358() end function MotionStreakTest() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { MotionStreakTest1, diff --git a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua index 22d7f28c87..54e27c2682 100644 --- a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua @@ -3,11 +3,11 @@ local kTagSprite2 = 2 local kTagSprite3 = 3 local kTagSlider = 4 -local s = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local s = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local function getBaseLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) @@ -21,50 +21,50 @@ local function CameraCenterTest() local layer = getBaseLayer() -- LEFT-TOP - local sprite = CCSprite:create("Images/white-512x512.png") + local sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 5 * 1, s.height / 5 * 1)) - sprite:setColor(Color3B(255, 0, 0)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - local orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) - -- [sprite setAnchorPoint: CCPoint(0,1)) + sprite:setPosition(cc.p(s.width / 5 * 1, s.height / 5 * 1)) + sprite:setColor(cc.c3b(255, 0, 0)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + local orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) + -- [sprite setAnchorPoint: cc.p(0,1)) -- LEFT-BOTTOM - sprite = CCSprite:create("Images/white-512x512.png") + sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPoint(s.width / 5 * 1, s.height / 5 * 4)) - sprite:setColor(Color3B(0, 0, 255)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 5 * 1, s.height / 5 * 4)) + sprite:setColor(cc.c3b(0, 0, 255)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- RIGHT-TOP - sprite = CCSprite:create("Images/white-512x512.png") + sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 5 * 4, s.height / 5 * 1)) - sprite:setColor(Color3B(255, 255, 0)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 5 * 4, s.height / 5 * 1)) + sprite:setColor(cc.c3b(255, 255, 0)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- RIGHT-BOTTOM - sprite = CCSprite:create("Images/white-512x512.png") + sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPoint(s.width / 5 * 4, s.height / 5 * 4)) - sprite:setColor(Color3B(0, 255, 0)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 5 * 4, s.height / 5 * 4)) + sprite:setColor(cc.c3b(0, 255, 0)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- CENTER - sprite = CCSprite:create("Images/white-512x512.png") + sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPoint(s.width / 2, s.height / 2)) - sprite:setColor(Color3B(255, 255, 255)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 2, s.height / 2)) + sprite:setColor(cc.c3b(255, 255, 255)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) Helper.titleLabel:setString("Camera Center test") Helper.subtitleLabel:setString("Sprites should rotate at the same speed") @@ -77,13 +77,13 @@ end local function Test2() local layer = getBaseLayer() - local sp1 = CCSprite:create(s_pPathSister1) - local sp2 = CCSprite:create(s_pPathSister2) - local sp3 = CCSprite:create(s_pPathSister1) - local sp4 = CCSprite:create(s_pPathSister2) + local sp1 = cc.Sprite:create(s_pPathSister1) + local sp2 = cc.Sprite:create(s_pPathSister2) + local sp3 = cc.Sprite:create(s_pPathSister1) + local sp4 = cc.Sprite:create(s_pPathSister2) - sp1:setPosition(CCPoint(100, s.height /2)) - sp2:setPosition(CCPoint(380, s.height /2)) + sp1:setPosition(cc.p(100, s.height /2)) + sp2:setPosition(cc.p(380, s.height /2)) layer:addChild(sp1) layer:addChild(sp2) @@ -92,22 +92,13 @@ local function Test2() sp1:addChild(sp3) sp2:addChild(sp4) - local a1 = CCRotateBy:create(2, 360) - local a2 = CCScaleBy:create(2, 2) + local a1 = cc.RotateBy:create(2, 360) + local a2 = cc.ScaleBy:create(2, 2) - local array1 = CCArray:create() - array1:addObject(a1) - array1:addObject(a2) - array1:addObject(a2:reverse()) - local action1 = CCRepeatForever:create(CCSequence:create(array1)) + local action1 = cc.RepeatForever:create(cc.Sequence:create(a1, a2, a2:reverse())) + local action2 = cc.RepeatForever:create(cc.Sequence:create(a1:clone(), a2:clone(), a2:reverse())) - local array2 = CCArray:create() - array2:addObject(a1:clone()) - array2:addObject(a2:clone()) - array2:addObject(a2:reverse()) - local action2 = CCRepeatForever:create(CCSequence:create(array2)) - - sp2:setAnchorPoint(CCPoint(0,0)) + sp2:setAnchorPoint(cc.p(0,0)) sp1:runAction(action1) sp2:runAction(action2) @@ -125,7 +116,7 @@ local Test4_delay4Entry = nil local function delay2(dt) node = Test4_layer:getChildByTag(2) - local action1 = CCRotateBy:create(1, 360) + local action1 = cc.RotateBy:create(1, 360) node:runAction(action1) end @@ -147,10 +138,10 @@ end local function Test4() Test4_layer = getBaseLayer() - local sp1 = CCSprite:create(s_pPathSister1) - local sp2 = CCSprite:create(s_pPathSister2) - sp1:setPosition(CCPoint(100, 160)) - sp2:setPosition(CCPoint(380, 160)) + local sp1 = cc.Sprite:create(s_pPathSister1) + local sp2 = cc.Sprite:create(s_pPathSister2) + sp1:setPosition(cc.p(100, 160)) + sp2:setPosition(cc.p(380, 160)) Test4_layer:addChild(sp1, 0, 2) Test4_layer:addChild(sp2, 0, 3) @@ -195,19 +186,19 @@ end local function Test5() Test5_layer = getBaseLayer() - local sp1 = CCSprite:create(s_pPathSister1) - local sp2 = CCSprite:create(s_pPathSister2) + local sp1 = cc.Sprite:create(s_pPathSister1) + local sp2 = cc.Sprite:create(s_pPathSister2) - sp1:setPosition(CCPoint(100, 160)) - sp2:setPosition(CCPoint(380, 160)) + sp1:setPosition(cc.p(100, 160)) + sp2:setPosition(cc.p(380, 160)) - local rot = CCRotateBy:create(2, 360) + local rot = cc.RotateBy:create(2, 360) local rot_back = rot:reverse() - local forever = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot_back)) + local forever = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back)) - local rot2 = CCRotateBy:create(2, 360) + local rot2 = cc.RotateBy:create(2, 360) local rot2_back = rot2:reverse() - local forever2 = CCRepeatForever:create(CCSequence:createWithTwoActions(rot2, rot2_back)) + local forever2 = cc.RepeatForever:create(cc.Sequence:create(rot2, rot2_back)) forever:setTag(101) forever2:setTag(102) @@ -258,22 +249,22 @@ end local function Test6() Test6_layer = getBaseLayer() - local sp1 = CCSprite:create(s_pPathSister1) - local sp11 = CCSprite:create(s_pPathSister1) + local sp1 = cc.Sprite:create(s_pPathSister1) + local sp11 = cc.Sprite:create(s_pPathSister1) - local sp2 = CCSprite:create(s_pPathSister2) - local sp21 = CCSprite:create(s_pPathSister2) + local sp2 = cc.Sprite:create(s_pPathSister2) + local sp21 = cc.Sprite:create(s_pPathSister2) - sp1:setPosition(CCPoint(100, 160)) - sp2:setPosition(CCPoint(380, 160)) + sp1:setPosition(cc.p(100, 160)) + sp2:setPosition(cc.p(380, 160)) - local rot = CCRotateBy:create(2, 360) + local rot = cc.RotateBy:create(2, 360) local rot_back = rot:reverse() - local forever1 = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot_back)) - local forever11 = tolua.cast(forever1:clone(), "CCRepeatForever") + local forever1 = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back)) + local forever11 = tolua.cast(forever1:clone(), "RepeatForever") - local forever2 = tolua.cast(forever1:clone(), "CCRepeatForever") - local forever21 = tolua.cast(forever1:clone(), "CCRepeatForever") + local forever2 = tolua.cast(forever1:clone(), "RepeatForever") + local forever21 = tolua.cast(forever1:clone(), "RepeatForever") Test6_layer:addChild(sp1, 0, kTagSprite1) sp1:addChild(sp11) @@ -307,14 +298,14 @@ local function shouldNotCrash(dt) scheduler:unscheduleScriptEntry(StressTest1_entry) -- if the node has timers, it crashes - local explosion = CCParticleSun:create() - explosion:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) + local explosion = cc.ParticleSun:create() + explosion:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) explosion:setPosition(s.width / 2, s.height / 2) - StressTest1_layer:setAnchorPoint(CCPoint(0, 0)) - local callFunc = CCCallFunc:create(removeMe) - StressTest1_layer:runAction(CCSequence:createWithTwoActions(CCRotateBy:create(2, 360), callFunc)) + StressTest1_layer:setAnchorPoint(cc.p(0, 0)) + local callFunc = cc.CallFunc:create(removeMe) + StressTest1_layer:runAction(cc.Sequence:create(cc.RotateBy:create(2, 360), callFunc)) StressTest1_layer:addChild(explosion) end @@ -330,10 +321,10 @@ end local function StressTest1() StressTest1_layer = getBaseLayer() - sp1 = CCSprite:create(s_pPathSister1) + sp1 = cc.Sprite:create(s_pPathSister1) StressTest1_layer:addChild(sp1, 0, kTagSprite1) - sp1:setPosition(CCPoint(s.width / 2, s.height / 2)) + sp1:setPosition(cc.p(s.width / 2, s.height / 2)) StressTest1_layer:registerScriptHandler(StressTest1_onEnterOrExit) @@ -365,25 +356,25 @@ end local function StressTest2() StressTest2_layer = getBaseLayer() - sublayer = CCLayer:create() + sublayer = cc.Layer:create() - local sp1 = CCSprite:create(s_pPathSister1) - sp1:setPosition(CCPoint(80, s.height / 2)) + local sp1 = cc.Sprite:create(s_pPathSister1) + sp1:setPosition(cc.p(80, s.height / 2)) - local move = CCMoveBy:create(3, CCPoint(350, 0)) - local move_ease_inout3 = CCEaseInOut:create(CCMoveBy:create(3, CCPoint(350, 0)), 2.0) + local move = cc.MoveBy:create(3, cc.p(350, 0)) + local move_ease_inout3 = cc.EaseInOut:create(cc.MoveBy:create(3, cc.p(350, 0)), 2.0) local move_ease_inout_back3 = move_ease_inout3:reverse() - local seq3 = CCSequence:createWithTwoActions(move_ease_inout3, move_ease_inout_back3) - sp1:runAction(CCRepeatForever:create(seq3)) + local seq3 = cc.Sequence:create(move_ease_inout3, move_ease_inout_back3) + sp1:runAction(cc.RepeatForever:create(seq3)) sublayer:addChild(sp1, 1) - local fire = CCParticleFire:create() - fire:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) - fire = tolua.cast(fire, "CCNode") + local fire = cc.ParticleFire:create() + fire:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) + fire = tolua.cast(fire, "Node") fire:setPosition(80, s.height / 2 - 50) - local copy_seq3 = tolua.cast(seq3:clone(), "CCSequence") - fire:runAction(CCRepeatForever:create(copy_seq3)) + local copy_seq3 = tolua.cast(seq3:clone(), "Sequence") + fire:runAction(cc.RepeatForever:create(copy_seq3)) sublayer:addChild(fire, 2) StressTest2_layer:registerScriptHandler(StressTest2_onEnterOrExit) @@ -404,26 +395,26 @@ local function NodeToWorld() -- - It tests different anchor Points -- - It tests different children anchor points - local back = CCSprite:create(s_back3) + local back = cc.Sprite:create(s_back3) layer:addChild(back, -10) - back:setAnchorPoint(CCPoint(0, 0)) + back:setAnchorPoint(cc.p(0, 0)) local backSize = back:getContentSize() - local item = CCMenuItemImage:create(s_PlayNormal, s_PlaySelect) - local menu = CCMenu:create() + local item = cc.MenuItemImage:create(s_PlayNormal, s_PlaySelect) + local menu = cc.Menu:create() menu:addChild(item) menu:alignItemsVertically() - menu:setPosition(CCPoint(backSize.width / 2, backSize.height / 2)) + menu:setPosition(cc.p(backSize.width / 2, backSize.height / 2)) back:addChild(menu) - local rot = CCRotateBy:create(5, 360) - local fe = CCRepeatForever:create(rot) + local rot = cc.RotateBy:create(5, 360) + local fe = cc.RepeatForever:create(rot) item:runAction(fe) - local move = CCMoveBy:create(3, CCPoint(200, 0)) + local move = cc.MoveBy:create(3, cc.p(200, 0)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - local fe2 = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(move, move_back) + local fe2 = cc.RepeatForever:create(seq) back:runAction(fe2) Helper.titleLabel:setString("nodeToParent transform") @@ -435,50 +426,50 @@ end ----------------------------------- local function CameraOrbitTest_onEnterOrExit(tag) if tag == "enter" then - CCDirector:getInstance():setProjection(kCCDirectorProjection3D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION3_D) elseif tag == "exit" then - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D) end end local function CameraOrbitTest() local layer = getBaseLayer() - local p = CCSprite:create(s_back3) + local p = cc.Sprite:create(s_back3) layer:addChild(p, 0) - p:setPosition(CCPoint(s.width / 2, s.height / 2)) + p:setPosition(cc.p(s.width / 2, s.height / 2)) p:setOpacity(128) -- LEFT local s = p:getContentSize() - local sprite = CCSprite:create(s_pPathGrossini) + local sprite = cc.Sprite:create(s_pPathGrossini) sprite:setScale(0.5) p:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 4 * 1, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 1, s.height / 2)) local cam = sprite:getCamera() - local orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + local orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- CENTER - sprite = CCSprite:create(s_pPathGrossini) + sprite = cc.Sprite:create(s_pPathGrossini) sprite:setScale(1.0) p:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 4 * 2, s.height / 2)) - orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 45, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 4 * 2, s.height / 2)) + orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 45, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- RIGHT - sprite = CCSprite:create(s_pPathGrossini) + sprite = cc.Sprite:create(s_pPathGrossini) sprite:setScale(2.0) p:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 4 * 3, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 3, s.height / 2)) local ss = sprite:getContentSize() - orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 90, -45) - sprite:runAction(CCRepeatForever:create(orbit)) + orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 90, -45) + sprite:runAction(cc.RepeatForever:create(orbit)) -- PARENT - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 90) - p:runAction(CCRepeatForever:create(orbit)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 90) + p:runAction(cc.RepeatForever:create(orbit)) layer:setScale(1) @@ -498,19 +489,19 @@ local function CameraZoomTest_update(dt) local sprite = CameraZoomTest_layer:getChildByTag(20) local cam = sprite:getCamera() - cam:setEyeXYZ(0, 0, z) + cam:setEye(0, 0, z) sprite = CameraZoomTest_layer:getChildByTag(40) cam = sprite:getCamera() - cam:setEyeXYZ(0, 0, -z) + cam:setEye(0, 0, -z) end local function CameraZoomTest_onEnterOrExit(tag) if tag == "enter" then - CCDirector:getInstance():setProjection(kCCDirectorProjection3D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION3_D) CameraZoomTest_entry = scheduler:scheduleScriptFunc(CameraZoomTest_update, 0.0, false) elseif tag == "exit" then - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D) scheduler:unscheduleScriptEntry(CameraZoomTest_entry) end end @@ -521,22 +512,22 @@ local function CameraZoomTest() z = 0 -- LEFT - local sprite = CCSprite:create(s_pPathGrossini) + local sprite = cc.Sprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 4 * 1, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 1, s.height / 2)) local cam = sprite:getCamera() - cam:setEyeXYZ(0, 0, 415 / 2) - cam:setCenterXYZ(0, 0, 0) + cam:setEye(0, 0, 415 / 2) + cam:setCenter(0, 0, 0) -- CENTER - sprite = CCSprite:create(s_pPathGrossini) + sprite = cc.Sprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPoint(s.width / 4 * 2, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 2, s.height / 2)) -- RIGHT - sprite = CCSprite:create(s_pPathGrossini) + sprite = cc.Sprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0, 20) - sprite:setPosition(CCPoint(s.width / 4 * 3, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 3, s.height / 2)) CameraZoomTest_layer:scheduleUpdateWithPriorityLua(CameraZoomTest_update, 0) CameraZoomTest_layer:registerScriptHandler(CameraZoomTest_onEnterOrExit) @@ -553,28 +544,28 @@ local ConvertToNode_layer = nil local function ConvertToNode() ConvertToNode_layer = getBaseLayer() - local rotate = CCRotateBy:create(10, 360) - local action = CCRepeatForever:create(rotate) + local rotate = cc.RotateBy:create(10, 360) + local action = cc.RepeatForever:create(rotate) for i = 0, 2 do - local sprite = CCSprite:create("Images/grossini.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:create("Images/grossini.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) ConvertToNode_layer:addChild(point, 10, 100 + i) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1,1)) + sprite:setAnchorPoint(cc.p(1,1)) end point:setPosition(sprite:getPosition()) - local copy = tolua.cast(action:clone(), "CCRepeatForever") + local copy = tolua.cast(action:clone(), "RepeatForever") sprite:runAction(copy) ConvertToNode_layer:addChild(sprite, i) end @@ -583,8 +574,8 @@ local function ConvertToNode() for i = 0, 2 do local node = ConvertToNode_layer:getChildByTag(100 + i) local p1, p2 - p1 = node:convertToNodeSpaceAR(CCPoint(x, y)) - p2 = node:convertToNodeSpace(CCPoint(x, y)) + p1 = node:convertToNodeSpaceAR(cc.p(x, y)) + p2 = node:convertToNodeSpace(cc.p(x, y)) cclog("AR: x=" .. p1.x .. ", y=" .. p1.y .. " -- Not AR: x=" .. p2.x .. ", y=" .. p2.y) end @@ -613,12 +604,9 @@ local function NodeOpaqueTest() local layer = getBaseLayer() for i = 0, 49 do - local background = CCSprite:create("Images/background1.png") - local blendFunc = BlendFunc:new() - blendFunc.src = GL_ONE - blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA - background:setBlendFunc(blendFunc) - background:setAnchorPoint(CCPoint(0, 0)) + local background = cc.Sprite:create("Images/background1.png") + background:setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) + background:setAnchorPoint(cc.p(0, 0)) layer:addChild(background) end @@ -634,12 +622,9 @@ local function NodeNonOpaqueTest() local layer = getBaseLayer() for i = 0, 49 do - background = CCSprite:create("Images/background1.jpg") - local blendFunc = BlendFunc:new() - blendFunc.src = GL_ONE - blendFunc.dst = GL_ZERO - background:setBlendFunc(blendFunc) - background:setAnchorPoint(CCPoint(0, 0)) + background = cc.Sprite:create("Images/background1.jpg") + background:setBlendFunc(gl.ONE, gl.ZERO) + background:setAnchorPoint(cc.p(0, 0)) layer:addChild(background) end Helper.titleLabel:setString("Node Non Opaque Test") @@ -648,7 +633,7 @@ local function NodeNonOpaqueTest() end function CocosNodeTest() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { CameraCenterTest, diff --git a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua index 460fac980e..a840ccd203 100644 --- a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua @@ -8,7 +8,7 @@ local function OpenGLTestMainLayer() local curCase = 0 local accum = 0 local labelBMFont = nil - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() local curLayer = nil local schedulEntry = nil local function OrderCallbackMenu() @@ -30,23 +30,23 @@ local function OpenGLTestMainLayer() ShowCurrentTest() end - local ordercallbackmenu = CCMenu:create() - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local ordercallbackmenu = cc.Menu:create() + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) ordercallbackmenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) ordercallbackmenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) ordercallbackmenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - ordercallbackmenu:setPosition(CCPoint(0, 0)) + ordercallbackmenu:setPosition(cc.p(0, 0)) return ordercallbackmenu end @@ -125,14 +125,14 @@ local function OpenGLTestMainLayer() local function InitTitle(layer) --Title - local lableTitle = CCLabelTTF:create(GetTitle(), "Arial", 40) + local lableTitle = cc.LabelTTF:create(GetTitle(), "Arial", 40) layer:addChild(lableTitle, 15) - lableTitle:setPosition(CCPoint(size.width/2, size.height-32)) - lableTitle:setColor(Color3B(255,255,40)) + lableTitle:setPosition(cc.p(size.width/2, size.height-32)) + lableTitle:setColor(cc.c3b(255,255,40)) --SubTitle - local subLabelTitle = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16) + local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) layer:addChild(subLabelTitle, 15) - subLabelTitle:setPosition(CCPoint(size.width/2, size.height-80)) + subLabelTitle:setPosition(cc.p(size.width/2, size.height-80)) end local function updateRetroEffect(fTime) @@ -145,10 +145,11 @@ local function OpenGLTestMainLayer() return end local i = 0 - local len = children:count() + local len = table.getn(children) for i= 0 ,len - 1 do - local child = tolua.cast(children:objectAtIndex(i), "CCSprite") - local oldPosX,oldPosY = child:getPosition() + local child = tolua.cast(children[i + 1], "Sprite") + local oldPos = child:getPosition() + local oldPosX,oldPosY = oldPos.x, oldPos.y child:setPosition(oldPosX,math.sin(accum * 2 + i / 2.0) * 20) local scaleY = math.sin(accum * 2 + i / 2.0 + 0.707) child:setScaleY(scaleY) @@ -156,15 +157,15 @@ local function OpenGLTestMainLayer() end local function createShaderRetroEffect() - local RetroEffectlayer = CCLayer:create() + local RetroEffectlayer = cc.Layer:create() InitTitle(RetroEffectlayer) - local program = CCGLProgram:create("Shaders/example_ColorBars.vsh", "Shaders/example_ColorBars.fsh") - program:addAttribute(CCConstants.ATTRIBUTE_NAME_POSITION, CCConstants.VERTEX_ATTRIB_POSITION) - program:addAttribute(CCConstants.ATTRIBUTE_NAME_TEX_COORD, CCConstants.VERTEX_ATTRIB_TEX_COORDS) + local program = cc.GLProgram:create("Shaders/example_ColorBars.vsh", "Shaders/example_ColorBars.fsh") + program:addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION) + program:addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS) program:link() program:updateUniforms() - label = CCLabelBMFont:create("RETRO EFFECT","fonts/west_england-64.fnt") + label = cc.LabelBMFont:create("RETRO EFFECT","fonts/west_england-64.fnt") label:setShaderProgram( program ) label:setPosition(size.width/2, size.height/2) @@ -179,21 +180,21 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local majorLayer = CCLayer:create() + local majorLayer = cc.Layer:create() InitTitle(majorLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh") + local shader = cc.GLProgram:create("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh") - shader:addAttribute("aVertex", CCConstants.VERTEX_ATTRIB_POSITION) + shader:addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION) shader:link() shader:updateUniforms() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -215,14 +216,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) - gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_POSITION) + gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -241,11 +242,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local mandelbrotLayer = CCLayer:create() + local mandelbrotLayer = cc.Layer:create() InitTitle(mandelbrotLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh") + local shader = cc.GLProgram:create("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -254,8 +255,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -277,14 +278,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -303,11 +304,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local heartLayer = CCLayer:create() + local heartLayer = cc.Layer:create() InitTitle(heartLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh") + local shader = cc.GLProgram:create("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -316,8 +317,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -339,14 +340,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -365,11 +366,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local plasmaLayer = CCLayer:create() + local plasmaLayer = cc.Layer:create() InitTitle(plasmaLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh") + local shader = cc.GLProgram:create("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -378,8 +379,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -401,14 +402,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -427,11 +428,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local flowerLayer = CCLayer:create() + local flowerLayer = cc.Layer:create() InitTitle(flowerLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh") + local shader = cc.GLProgram:create("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -440,8 +441,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -463,14 +464,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -489,11 +490,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local juliaLayer = CCLayer:create() + local juliaLayer = cc.Layer:create() InitTitle(juliaLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh") + local shader = cc.GLProgram:create("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -502,8 +503,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -525,14 +526,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -547,18 +548,18 @@ local function OpenGLTestMainLayer() end local function createGLGetActiveTest() - local glGetActiveLayer = CCLayer:create() + local glGetActiveLayer = cc.Layer:create() InitTitle(glGetActiveLayer) - local sprite = CCSprite:create("Images/grossini.png") + local sprite = cc.Sprite:create("Images/grossini.png") sprite:setPosition( size.width/2, size.height/2) glGetActiveLayer:addChild(sprite) local glNode = gl.glNodeCreate() glGetActiveLayer:addChild(glNode,-10) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() local function getCurrentResult() local var = {} - local glProgam = tolua.cast(sprite:getShaderProgram(),"CCGLProgram") + local glProgam = tolua.cast(sprite:getShaderProgram(),"GLProgram") if nil ~= glProgam then local p = glProgam:getProgram() local aaSize,aaType,aaName = gl.getActiveAttrib(p,0) @@ -597,14 +598,14 @@ local function OpenGLTestMainLayer() local texture = {} local squareVertexPositionBuffer = {} local squareVertexTextureBuffer = {} - local texImage2dLayer = CCLayer:create() + local texImage2dLayer = cc.Layer:create() InitTitle(texImage2dLayer) local glNode = gl.glNodeCreate() texImage2dLayer:addChild(glNode, 10) glNode:setPosition(size.width/2, size.height/2) - glNode:setContentSize(CCSize(128,128)) - glNode:setAnchorPoint(CCPoint(0.5,0.5)) - local shaderCache = CCShaderCache:getInstance() + glNode:setContentSize(cc.size(128,128)) + glNode:setAnchorPoint(cc.p(0.5,0.5)) + local shaderCache = cc.ShaderCache:getInstance() local shader = shaderCache:getProgram("ShaderPositionTexture") local function initGL() texture.texture_id = gl.createTexture() @@ -646,14 +647,14 @@ local function OpenGLTestMainLayer() shader:setUniformsForBuiltins() gl.bindTexture(gl.TEXTURE_2D, texture.texture_id) - gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_TEX_COORDS or CCConstants.VERTEX_ATTRIB_FLAG_POSITION) + gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_TEX_COORDS or cc.VERTEX_ATTRIB_FLAG_POSITION) gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION,2,gl.FLOAT,false,0,0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,gl.FLOAT,false,0,0) gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexTextureBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_TEX_COORDS,2,gl.FLOAT,false,0,0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,gl.FLOAT,false,0,0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) @@ -668,7 +669,7 @@ local function OpenGLTestMainLayer() end local function CreateSupportedExtensionsLayer() - local extensionsLayer = CCLayer:create() + local extensionsLayer = cc.Layer:create() InitTitle(extensionsLayer) local glNode = gl.glNodeCreate() extensionsLayer:addChild(glNode,-10) @@ -687,7 +688,7 @@ local function OpenGLTestMainLayer() end local function CreateReadPixelsTest() - local readPixelsLayer = CCLayer:create() + local readPixelsLayer = cc.Layer:create() InitTitle(readPixelsLayer) local glNode = gl.glNodeCreate() readPixelsLayer:addChild(glNode,-10) @@ -695,10 +696,10 @@ local function OpenGLTestMainLayer() local x = size.width local y = size.height - local blue = CCLayerColor:create(Color4B(0, 0, 255, 255)) - local red = CCLayerColor:create(Color4B(255, 0, 0, 255)) - local green = CCLayerColor:create(Color4B(0, 255, 0, 255)) - local white = CCLayerColor:create(Color4B(255, 255, 255, 255)) + local blue = cc.LayerColor:create(cc.c4b(0, 0, 255, 255)) + local red = cc.LayerColor:create(cc.c4b(255, 0, 0, 255)) + local green = cc.LayerColor:create(cc.c4b(0, 255, 0, 255)) + local white = cc.LayerColor:create(cc.c4b(255, 255, 255, 255)) blue:setScale(0.5) blue:setPosition(-x / 4, -y / 4) @@ -717,7 +718,7 @@ local function OpenGLTestMainLayer() readPixelsLayer:addChild(green,12) readPixelsLayer:addChild(red,13) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() local function getCurrentResult() local x = size.width @@ -773,16 +774,16 @@ local function OpenGLTestMainLayer() end local function createClearTest() - local clearLayer = CCLayer:create() + local clearLayer = cc.Layer:create() InitTitle(clearLayer) - local blue = CCLayerColor:create(Color4B(0, 0, 255, 255)) + local blue = cc.LayerColor:create(cc.c4b(0, 0, 255, 255)) clearLayer:addChild( blue, 1 ) local glNode = gl.glNodeCreate() clearLayer:addChild(glNode,10) --gl.init() - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() local function clearDraw() gl.clear(gl.COLOR_BUFFER_BIT) @@ -813,7 +814,7 @@ local function OpenGLTestMainLayer() end local function createNodeWebGLAPITest() - local nodeWebGLAPILayer = CCLayer:create() + local nodeWebGLAPILayer = cc.Layer:create() InitTitle(nodeWebGLAPILayer) local glNode = gl.glNodeCreate() nodeWebGLAPILayer:addChild(glNode,10) @@ -971,11 +972,11 @@ local function OpenGLTestMainLayer() end local function createGLNodeCCAPITest() - local nodeCCAPILayer = CCLayer:create() + local nodeCCAPILayer = cc.Layer:create() InitTitle(nodeCCAPILayer) local glNode = gl.glNodeCreate() nodeCCAPILayer:addChild(glNode,10) - local shader = CCShaderCache:getInstance():getProgram("ShaderPositionColor") + local shader = cc.ShaderCache:getInstance():getProgram("ShaderPositionColor") local triangleVertexPositionBuffer = {} local triangleVertexColorBuffer = {} local squareVertexPositionBuffer = {} @@ -1026,22 +1027,22 @@ local function OpenGLTestMainLayer() local function GLNodeCCAPIDraw() shader:use() shader:setUniformsForBuiltins() - gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_COLOR or CCConstants.VERTEX_ATTRIB_FLAG_POSITION) + gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_COLOR or cc.VERTEX_ATTRIB_FLAG_POSITION) -- gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexColorBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4) gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexColorBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3) @@ -1056,7 +1057,7 @@ local function OpenGLTestMainLayer() end local function createGLTexParamterTest() - local glTexParamLayer = CCLayer:create() + local glTexParamLayer = cc.Layer:create() InitTitle(glTexParamLayer) local glNode = gl.glNodeCreate() glTexParamLayer:addChild(glNode,10) @@ -1079,14 +1080,14 @@ local function OpenGLTestMainLayer() end local function createGetUniformTest() - local getUniformLayer = CCLayer:create() + local getUniformLayer = cc.Layer:create() InitTitle(getUniformLayer) local glNode = gl.glNodeCreate() getUniformLayer:addChild(glNode,10) local pMatrix = {1,2,3,4, 4,3,2,1, 1,2,4,8, 1.1,1.2,1.3,1.4} local function runTest() - local shader = CCShaderCache:getInstance():getProgram("ShaderPositionTextureColor") + local shader = cc.ShaderCache:getInstance():getProgram("ShaderPositionTextureColor") local program = shader:getProgram() shader:use() @@ -1147,10 +1148,10 @@ local function OpenGLTestMainLayer() end function ShowCurrentTest() - local curScene = CCScene:create() + local curScene = cc.Scene:create() if nil ~= curScene then if nil ~= curLayer then - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if nil ~= schedulEntry then scheduler:unscheduleScriptEntry(schedulEntry) end @@ -1160,7 +1161,7 @@ local function OpenGLTestMainLayer() curScene:addChild(curLayer) curLayer:addChild(OrderCallbackMenu(),15) curScene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(curScene) + cc.Director:getInstance():replaceScene(curScene) end end end @@ -1170,7 +1171,7 @@ local function OpenGLTestMainLayer() end function OpenGLTestMain() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(OpenGLTestMainLayer()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua b/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua index df34149294..24f5405368 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua @@ -2,7 +2,7 @@ local kTagNode = 0 local kTagGrossini = 1 local function createParallaxLayer(title, subtitle) - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) local titleStr = title == nil and "No title" or title local subTitleStr = subtitle == nil and "" or subtitle @@ -20,61 +20,56 @@ end local function Parallax1() local ret = createParallaxLayer("Parallax: parent and 3 children") -- Top Layer, a simple image - local cocosImage = CCSprite:create(s_Power) + local cocosImage = cc.Sprite:create(s_Power) -- scale the image (optional) cocosImage:setScale( 2.5 ) -- change the transform anchor point to 0,0 (optional) - cocosImage:setAnchorPoint( CCPoint(0,0) ) + cocosImage:setAnchorPoint( cc.p(0,0) ) -- Middle layer: a Tile map atlas - local tilemap = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) + local tilemap = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) tilemap:releaseMap() -- change the transform anchor to 0,0 (optional) - tilemap:setAnchorPoint( CCPoint(0, 0) ) + tilemap:setAnchorPoint( cc.p(0, 0) ) -- Anti Aliased images tilemap:getTexture():setAntiAliasTexParameters() -- background layer: another image - local background = CCSprite:create(s_back) + local background = cc.Sprite:create(s_back) -- scale the image (optional) background:setScale( 1.5 ) -- change the transform anchor point (optional) - background:setAnchorPoint( CCPoint(0,0) ) + background:setAnchorPoint( cc.p(0,0) ) -- create a void node, a parent node - local voidNode = CCParallaxNode:create() + local voidNode = cc.ParallaxNode:create() -- NOW add the 3 layers to the 'void' node -- background image is moved at a ratio of 0.4x, 0.5y - voidNode:addChild(background, -1, CCPoint(0.4,0.5), CCPoint(0,0)) + voidNode:addChild(background, -1, cc.p(0.4,0.5), cc.p(0,0)) -- tiles are moved at a ratio of 2.2x, 1.0y - voidNode:addChild(tilemap, 1, CCPoint(2.2,1.0), CCPoint(0,-200) ) + voidNode:addChild(tilemap, 1, cc.p(2.2,1.0), cc.p(0,-200) ) -- top image is moved at a ratio of 3.0x, 2.5y - voidNode:addChild(cocosImage, 2, CCPoint(3.0,2.5), CCPoint(200,800) ) + voidNode:addChild(cocosImage, 2, cc.p(3.0,2.5), cc.p(200,800) ) -- now create some actions that will move the 'void' node -- and the children of the 'void' node will move at different -- speed, thus, simulation the 3D environment - local goUp = CCMoveBy:create(4, CCPoint(0,-500) ) + local goUp = cc.MoveBy:create(4, cc.p(0,-500) ) local goDown = goUp:reverse() - local go = CCMoveBy:create(8, CCPoint(-1000,0) ) + local go = cc.MoveBy:create(8, cc.p(-1000,0) ) local goBack = go:reverse() - local arr = CCArray:create() - arr:addObject(goUp) - arr:addObject(go) - arr:addObject(goDown) - arr:addObject(goBack) - local seq = CCSequence:create(arr) - voidNode:runAction( (CCRepeatForever:create(seq) )) + local seq = cc.Sequence:create(goUp, go, goDown, goBack) + voidNode:runAction( (cc.RepeatForever:create(seq) )) ret:addChild( voidNode ) return ret @@ -91,45 +86,45 @@ local function Parallax2() ret:setTouchEnabled( true ) -- Top Layer, a simple image - local cocosImage = CCSprite:create(s_Power) + local cocosImage = cc.Sprite:create(s_Power) -- scale the image (optional) cocosImage:setScale( 2.5 ) -- change the transform anchor point to 0,0 (optional) - cocosImage:setAnchorPoint( CCPoint(0,0) ) + cocosImage:setAnchorPoint( cc.p(0,0) ) -- Middle layer: a Tile map atlas - local tilemap = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) + local tilemap = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) tilemap:releaseMap() -- change the transform anchor to 0,0 (optional) - tilemap:setAnchorPoint( CCPoint(0, 0) ) + tilemap:setAnchorPoint( cc.p(0, 0) ) -- Anti Aliased images tilemap:getTexture():setAntiAliasTexParameters() -- background layer: another image - local background = CCSprite:create(s_back) + local background = cc.Sprite:create(s_back) -- scale the image (optional) background:setScale( 1.5 ) -- change the transform anchor point (optional) - background:setAnchorPoint( CCPoint(0,0) ) + background:setAnchorPoint( cc.p(0,0) ) -- create a void node, a parent node - local voidNode = CCParallaxNode:create() + local voidNode = cc.ParallaxNode:create() -- NOW add the 3 layers to the 'void' node -- background image is moved at a ratio of 0.4x, 0.5y - voidNode:addChild(background, -1, CCPoint(0.4,0.5), CCPoint(0, 0)) + voidNode:addChild(background, -1, cc.p(0.4,0.5), cc.p(0, 0)) -- tiles are moved at a ratio of 1.0, 1.0y - voidNode:addChild(tilemap, 1, CCPoint(1.0,1.0), CCPoint(0,-200) ) + voidNode:addChild(tilemap, 1, cc.p(1.0,1.0), cc.p(0,-200) ) -- top image is moved at a ratio of 3.0x, 2.5y - voidNode:addChild( cocosImage, 2, CCPoint(3.0,2.5), CCPoint(200,1000) ) + voidNode:addChild( cocosImage, 2, cc.p(3.0,2.5), cc.p(200,1000) ) ret:addChild(voidNode, 0, kTagNode) local prev = {x = 0, y = 0} local function onTouchEvent(eventType, x, y) @@ -144,7 +139,7 @@ local function Parallax2() local diffX = x - prev.x local diffY = y - prev.y - node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) ) + node:setPosition( cc.pAdd(cc.p(newX, newY), cc.p(diffX, diffY)) ) prev.x = x prev.y = y end @@ -157,8 +152,8 @@ end function ParallaxTestMain() cclog("ParallaxMain") Helper.index = 1 - CCDirector:getInstance():setDepthTest(true) - local scene = CCScene:create() + cc.Director:getInstance():setDepthTest(true) + local scene = cc.Scene:create() Helper.createFunctionTable = { Parallax1, diff --git a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua index 4bdc7c1a45..ad3f22d36b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua @@ -10,7 +10,7 @@ local titleLabel = nil local subtitleLabel = nil local baseLayer_entry = nil -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() local function backAction() SceneIdx = SceneIdx - 1 @@ -33,40 +33,40 @@ local function nextAction() end local function backCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(backAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function restartCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(restartAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function nextCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(nextAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function toggleCallback(sender) if emitter ~= nil then - if emitter:getPositionType() == kCCPositionTypeGrouped then - emitter:setPositionType(kCCPositionTypeFree) - elseif emitter:getPositionType() == kCCPositionTypeFree then - emitter:setPositionType(kCCPositionTypeRelative) - elseif emitter:getPositionType() == kCCPositionTypeRelative then - emitter:setPositionType(kCCPositionTypeGrouped) + if emitter:getPositionType() == cc.POSITION_TYPE_GROUPED then + emitter:setPositionType(cc.POSITION_TYPE_FREE) + elseif emitter:getPositionType() == cc.POSITION_TYPE_FREE then + emitter:setPositionType(cc.POSITION_TYPE_RELATIVE) + elseif emitter:getPositionType() == cc.POSITION_TYPE_RELATIVE then + emitter:setPositionType(cc.POSITION_TYPE_GROUPED) end end end @@ -85,7 +85,7 @@ local function update(dt) end local function baseLayer_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then baseLayer_entry = scheduler:scheduleScriptFunc(update, 0, false) elseif tag == "exit" then @@ -94,67 +94,67 @@ local function baseLayer_onEnterOrExit(tag) end local function getBaseLayer() - local layer = CCLayerColor:create(Color4B(127,127,127,255)) + local layer = cc.LayerColor:create(cc.c4b(127,127,127,255)) emitter = nil - titleLabel = CCLabelTTF:create("", "Arial", 28) + titleLabel = cc.LabelTTF:create("", "Arial", 28) layer:addChild(titleLabel, 100, 1000) titleLabel:setPosition(s.width / 2, s.height - 50) - subtitleLabel = CCLabelTTF:create("", "Arial", 16) + subtitleLabel = cc.LabelTTF:create("", "Arial", 16) layer:addChild(subtitleLabel, 100) subtitleLabel:setPosition(s.width / 2, s.height - 80) - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) - local item4 = CCMenuItemToggle:create(CCMenuItemFont:create("Free Movement")) - item4:addSubItem(CCMenuItemFont:create("Relative Movement")) - item4:addSubItem(CCMenuItemFont:create("Grouped Movement")) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) + local item4 = cc.MenuItemToggle:create(cc.MenuItemFont:create("Free Movement")) + item4:addSubItem(cc.MenuItemFont:create("Relative Movement")) + item4:addSubItem(cc.MenuItemFont:create("Grouped Movement")) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) item4:registerScriptTapHandler(toggleCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) menu:addChild(item4) - menu:setPosition(CCPoint(0, 0)) - item1:setPosition(CCPoint(s.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(s.width/2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(s.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item4:setPosition(CCPoint(0, 100)) - item4:setAnchorPoint(CCPoint(0, 0)) + menu:setPosition(cc.p(0, 0)) + item1:setPosition(cc.p(s.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(s.width/2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(s.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item4:setPosition(cc.p(0, 100)) + item4:setAnchorPoint(cc.p(0, 0)) layer:addChild(menu, 100) - labelAtlas = CCLabelAtlas:create("0000", "fps_images.png", 12, 32, string.byte('.')) + labelAtlas = cc.LabelAtlas:_create("0000", "fps_images.png", 12, 32, string.byte('.')) layer:addChild(labelAtlas, 100) - labelAtlas:setPosition(CCPoint(s.width - 66, 50)) + labelAtlas:setPosition(cc.p(s.width - 66, 50)) -- moving background - background = CCSprite:create(s_back3) + background = cc.Sprite:create(s_back3) layer:addChild(background, 5) - background:setPosition(CCPoint(s.width / 2, s.height - 180)) + background:setPosition(cc.p(s.width / 2, s.height - 180)) - local move = CCMoveBy:create(4, CCPoint(300, 0)) + local move = cc.MoveBy:create(4, cc.p(300, 0)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - background:runAction(CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(move, move_back) + background:runAction(cc.RepeatForever:create(seq)) local function onTouchEnded(x, y) - local pos = CCPoint(0, 0) + local pos = cc.p(0, 0) if background ~= nil then - pos = background:convertToWorldSpace(CCPoint(0, 0)) + pos = background:convertToWorldSpace(cc.p(0, 0)) end if emitter ~= nil then - local newPos = CCPoint.__sub(CCPoint(x, y), pos) + local newPos = cc.pSub(cc.p(x, y), pos) emitter:setPosition(newPos.x, newPos.y) end end @@ -211,7 +211,7 @@ local function reorderParticles(dt) end local function ParticleReorder_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then ParticleReorder_entry = scheduler:scheduleScriptFunc(reorderParticles, 1.0, false) elseif tag == "exit" then @@ -223,13 +223,13 @@ local function ParticleReorder() ParticleReorder_layer = getBaseLayer() ParticleReorder_Order = 0 - ParticleReorder_layer:setColor(Color3B(0, 0, 0)) + ParticleReorder_layer:setColor(cc.c3b(0, 0, 0)) ParticleReorder_layer:removeChild(background, true) background = nil - local ignore = CCParticleSystemQuad:create("Particles/SmallSun.plist") - local parent1 = CCNode:create() - local parent2 = CCParticleBatchNode:createWithTexture(ignore:getTexture()) + local ignore = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + local parent1 = cc.Node:create() + local parent2 = cc.ParticleBatchNode:createWithTexture(ignore:getTexture()) ignore:unscheduleUpdate() for i = 0, 1 do @@ -240,14 +240,14 @@ local function ParticleReorder() parent = parent2 end - local emitter1 = CCParticleSystemQuad:create("Particles/SmallSun.plist") - emitter1:setStartColor(Color4F(1,0,0,1)) + local emitter1 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + emitter1:setStartColor(cc.c4f(1,0,0,1)) emitter1:setBlendAdditive(false) - local emitter2 = CCParticleSystemQuad:create("Particles/SmallSun.plist") - emitter2:setStartColor(Color4F(0,1,0,1)) + local emitter2 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + emitter2:setStartColor(cc.c4f(0,1,0,1)) emitter2:setBlendAdditive(false) - local emitter3 = CCParticleSystemQuad:create("Particles/SmallSun.plist") - emitter3:setStartColor(Color4F(0,0,1,1)) + local emitter3 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + emitter3:setStartColor(cc.c4f(0,0,1,1)) emitter3:setBlendAdditive(false) local neg = nil @@ -257,9 +257,9 @@ local function ParticleReorder() neg = -1 end - emitter1:setPosition(CCPoint( s.width / 2 - 30, s.height / 2 + 60 * neg)) - emitter2:setPosition(CCPoint( s.width / 2, s.height / 2 + 60 * neg)) - emitter3:setPosition(CCPoint( s.width / 2 + 30, s.height / 2 + 60 * neg)) + emitter1:setPosition(cc.p( s.width / 2 - 30, s.height / 2 + 60 * neg)) + emitter2:setPosition(cc.p( s.width / 2, s.height / 2 + 60 * neg)) + emitter3:setPosition(cc.p( s.width / 2 + 30, s.height / 2 + 60 * neg)) parent:addChild(emitter1, 0, 1) parent:addChild(emitter2, 0, 2) @@ -286,22 +286,22 @@ local function switchRender(dt) update(dt) local cond = (emitter:getBatchNode() ~= nil) - emitter:removeFromParentAndCleanup(false) + emitter:removeFromParent(false) local str = "Particle: Using new parent: " local newParent = nil if cond == true then newParent = ParticleBatchHybrid_parent2 - str = str .. "CCNode" + str = str .. "Node" else newParent = ParticleBatchHybrid_parent1 - str = str .. "CCParticleBatchNode" + str = str .. "ParticleBatchNode" end newParent:addChild(emitter) cclog(str) end local function ParticleBatchHybrid_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then ParticleBatchHybrid_entry = scheduler:scheduleScriptFunc(switchRender, 2.0, false) elseif tag == "exit" then @@ -313,17 +313,17 @@ end local function ParticleBatchHybrid() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:create("Particles/LavaFlow.plist") + emitter = cc.ParticleSystemQuad:create("Particles/LavaFlow.plist") ---- emitter:retain() - local batch = CCParticleBatchNode:createWithTexture(emitter:getTexture()) + local batch = cc.ParticleBatchNode:createWithTexture(emitter:getTexture()) batch:addChild(emitter) layer:addChild(batch, 10) - local node = CCNode:create() + local node = cc.Node:create() layer:addChild(node) ParticleBatchHybrid_parent1 = batch ParticleBatchHybrid_parent2 = node @@ -341,22 +341,22 @@ end local function ParticleBatchMultipleEmitters() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - local emitter1 = CCParticleSystemQuad:create("Particles/LavaFlow.plist") - emitter1:setStartColor(Color4F(1,0,0,1)) - local emitter2 = CCParticleSystemQuad:create("Particles/LavaFlow.plist") - emitter2:setStartColor(Color4F(0,1,0,1)) - local emitter3 = CCParticleSystemQuad:create("Particles/LavaFlow.plist") - emitter3:setStartColor(Color4F(0,0,1,1)) + local emitter1 = cc.ParticleSystemQuad:create("Particles/LavaFlow.plist") + emitter1:setStartColor(cc.c4f(1,0,0,1)) + local emitter2 = cc.ParticleSystemQuad:create("Particles/LavaFlow.plist") + emitter2:setStartColor(cc.c4f(0,1,0,1)) + local emitter3 = cc.ParticleSystemQuad:create("Particles/LavaFlow.plist") + emitter3:setStartColor(cc.c4f(0,0,1,1)) - emitter1:setPosition(CCPoint(s.width / 1.25, s.height / 1.25)) - emitter2:setPosition(CCPoint(s.width / 2, s.height / 2)) - emitter3:setPosition(CCPoint(s.width / 4, s.height / 4)) + emitter1:setPosition(cc.p(s.width / 1.25, s.height / 1.25)) + emitter2:setPosition(cc.p(s.width / 2, s.height / 2)) + emitter3:setPosition(cc.p(s.width / 4, s.height / 4)) - local batch = CCParticleBatchNode:createWithTexture(emitter1:getTexture()) + local batch = cc.ParticleBatchNode:createWithTexture(emitter1:getTexture()) batch:addChild(emitter1, 0) batch:addChild(emitter2, 0) @@ -375,10 +375,10 @@ end local function DemoFlower() local layer = getBaseLayer() - emitter = CCParticleFlower:create() + emitter = cc.ParticleFlower:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars1)) setEmitterPosition() @@ -392,11 +392,11 @@ end local function DemoGalaxy() local layer = getBaseLayer() - emitter = CCParticleGalaxy:create() + emitter = cc.ParticleGalaxy:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -410,11 +410,11 @@ end local function DemoFirework() local layer = getBaseLayer() - emitter = CCParticleFireworks:create() + emitter = cc.ParticleFireworks:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars1)) setEmitterPosition() @@ -428,11 +428,11 @@ end local function DemoSpiral() local layer = getBaseLayer() - emitter = CCParticleSpiral:create() + emitter = cc.ParticleSpiral:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -446,11 +446,11 @@ end local function DemoSun() local layer = getBaseLayer() - emitter = CCParticleSun:create() + emitter = cc.ParticleSun:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -464,11 +464,11 @@ end local function DemoMeteor() local layer = getBaseLayer() - emitter = CCParticleMeteor:create() + emitter = cc.ParticleMeteor:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -482,12 +482,13 @@ end local function DemoFire() local layer = getBaseLayer() - emitter = CCParticleFire:create() + emitter = cc.ParticleFire:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) - local pos_x, pos_y = emitter:getPosition() + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) + local pos = emitter:getPosition() + local pos_x, pos_y = pos.x, pos.y emitter:setPosition(pos_x, 100) titleLabel:setString("ParticleFire") @@ -500,12 +501,12 @@ end local function DemoSmoke() local layer = getBaseLayer() - emitter = CCParticleSmoke:create() + emitter = cc.ParticleSmoke:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) - - local pos_x, pos_y = emitter:getPosition() + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) + local pos = emitter:getPosition() + local pos_x, pos_y = pos.x, pos.y emitter:setPosition(pos_x, 100) setEmitterPosition() @@ -520,11 +521,11 @@ end local function DemoExplosion() local layer = getBaseLayer() - emitter = CCParticleExplosion:create() + emitter = cc.ParticleExplosion:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars1)) emitter:setAutoRemoveOnFinish(true) @@ -540,17 +541,17 @@ end local function DemoSnow() local layer = getBaseLayer() - emitter = CCParticleSnow:create() + emitter = cc.ParticleSnow:create() -- emitter:retain() background:addChild(emitter, 10) - - local pos_x, pos_y = emitter:getPosition() + local pos = emitter:getPosition() + local pos_x, pos_y = pos.x, pos.y emitter:setPosition(pos_x, pos_y - 110) emitter:setLife(3) emitter:setLifeVar(1) -- gravity - emitter:setGravity(CCPoint(0, -10)) + emitter:setGravity(cc.p(0, -10)) -- speed of particles emitter:setSpeed(130) @@ -568,7 +569,7 @@ local function DemoSnow() emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_snow)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_snow)) setEmitterPosition() @@ -582,15 +583,15 @@ end local function DemoRain() local layer = getBaseLayer() - emitter = CCParticleRain:create() + emitter = cc.ParticleRain:create() -- emitter:retain() background:addChild(emitter, 10) - - local pos_x, pos_y = emitter:getPosition() + local pos = emitter:getPosition() + local pos_x, pos_y = pos.x, pos.y emitter:setPosition(pos_x, pos_y - 100) emitter:setLife(4) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -604,17 +605,15 @@ end local function DemoBigFlower() local layer = getBaseLayer() - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(50) - emitter:autorelease() + emitter = cc.ParticleSystemQuad:createWithTotalParticles(50) background:addChild(emitter, 10) ----emitter:release() -- win32 : use this line or remove this line and use autorelease() - emitter:setTexture( CCTextureCache:getInstance():addImage(s_stars1) ) + emitter:setTexture( cc.TextureCache:getInstance():addImage(s_stars1) ) emitter:setDuration(-1) -- gravity - emitter:setGravity(CCPoint(0, 0)) + emitter:setGravity(cc.p(0, 0)) -- angle emitter:setAngle(90) @@ -634,7 +633,7 @@ local function DemoBigFlower() -- emitter position emitter:setPosition(160, 240) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(4) @@ -647,15 +646,15 @@ local function DemoBigFlower() emitter:setEndSpinVar(0) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(80.0) emitter:setStartSizeVar(40.0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE ) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -675,19 +674,17 @@ end local function DemoRotFlower() local layer = getBaseLayer() - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(300) - emitter:autorelease() + emitter = cc.ParticleSystemQuad:createWithTotalParticles(300) background:addChild(emitter, 10) ----emitter:release() -- win32 : Remove this line - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars2)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars2)) -- duration emitter:setDuration(-1) -- gravity - emitter:setGravity(CCPoint(0, 0)) + emitter:setGravity(cc.p(0, 0)) -- angle emitter:setAngle(90) @@ -707,7 +704,7 @@ local function DemoRotFlower() -- emitter position emitter:setPosition(160, 240) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(3) @@ -720,15 +717,15 @@ local function DemoRotFlower() emitter:setEndSpinVar(2000) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(30.0) emitter:setStartSizeVar(0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE ) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -748,9 +745,7 @@ end local function DemoModernArt() local layer = getBaseLayer() - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(1000) - emitter:autorelease() + emitter = cc.ParticleSystemQuad:createWithTotalParticles(1000) background:addChild(emitter, 10) ----emitter:release() @@ -759,7 +754,7 @@ local function DemoModernArt() emitter:setDuration(-1) -- gravity - emitter:setGravity(CCPoint(0,0)) + emitter:setGravity(cc.p(0,0)) -- angle emitter:setAngle(0) @@ -779,7 +774,7 @@ local function DemoModernArt() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(2.0) @@ -789,10 +784,10 @@ local function DemoModernArt() emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(1.0) @@ -801,7 +796,7 @@ local function DemoModernArt() emitter:setEndSizeVar(8.0) -- texture - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) -- additive emitter:setBlendAdditive(false) @@ -818,12 +813,12 @@ end local function DemoRing() local layer = getBaseLayer() - emitter = CCParticleFlower:create() + emitter = cc.ParticleFlower:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars1)) emitter:setLifeVar(0) emitter:setLife(10) emitter:setSpeed(100) @@ -845,30 +840,30 @@ local function ParallaxParticle() background:getParent():removeChild(background, true) background = nil - local p = CCParallaxNode:create() + local p = cc.ParallaxNode:create() layer:addChild(p, 5) - local p1 = CCSprite:create(s_back3) - local p2 = CCSprite:create(s_back3) + local p1 = cc.Sprite:create(s_back3) + local p2 = cc.Sprite:create(s_back3) - p:addChild(p1, 1, CCPoint(0.5, 1), CCPoint(0, 250)) - p:addChild(p2, 2, CCPoint(1.5, 1), CCPoint(0, 50)) + p:addChild(p1, 1, cc.p(0.5, 1), cc.p(0, 250)) + p:addChild(p2, 2, cc.p(1.5, 1), cc.p(0, 50)) - emitter = CCParticleFlower:create() + emitter = cc.ParticleFlower:create() -- emitter:retain() - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) p1:addChild(emitter, 10) emitter:setPosition(250, 200) - local par = CCParticleSun:create() + local par = cc.ParticleSun:create() p2:addChild(par, 10) - par:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + par:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) - local move = CCMoveBy:create(4, CCPoint(300,0)) + local move = cc.MoveBy:create(4, cc.p(300,0)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - p:runAction(CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(move, move_back) + p:runAction(cc.RepeatForever:create(seq)) titleLabel:setString("Parallax + Particles") return layer @@ -880,14 +875,12 @@ end local function DemoParticleFromFile(name) local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:new() - emitter:autorelease() local filename = "Particles/" .. name .. ".plist" - emitter:initWithFile(filename) + emitter = cc.ParticleSystemQuad:create(filename) layer:addChild(emitter, 10) setEmitterPosition() @@ -902,20 +895,19 @@ end local function RadiusMode1() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(200) + emitter = cc.ParticleSystemQuad:createWithTotalParticles(200) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage("Images/stars-grayscale.png")) + emitter:setTexture(cc.TextureCache:getInstance():addImage("Images/stars-grayscale.png")) -- duration - emitter:setDuration(kCCParticleDurationInfinity) + emitter:setDuration(cc.PARTICLE_DURATION_INFINITY) -- radius mode - emitter:setEmitterMode(kCCParticleModeRadius) + emitter:setEmitterMode(cc.PARTICLE_MODE_RADIUS) -- radius mode: start and end radius in pixels emitter:setStartRadius(0) @@ -934,7 +926,7 @@ local function RadiusMode1() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(5) @@ -947,15 +939,15 @@ local function RadiusMode1() emitter:setEndSpinVar(0) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(32) emitter:setStartSizeVar(0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE ) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -973,25 +965,24 @@ end local function RadiusMode2() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(200) + emitter = cc.ParticleSystemQuad:createWithTotalParticles(200) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage("Images/stars-grayscale.png")) + emitter:setTexture(cc.TextureCache:getInstance():addImage("Images/stars-grayscale.png")) -- duration - emitter:setDuration(kCCParticleDurationInfinity) + emitter:setDuration(cc.PARTICLE_DURATION_INFINITY ) -- radius mode - emitter:setEmitterMode(kCCParticleModeRadius) + emitter:setEmitterMode(cc.PARTICLE_MODE_RADIUS) -- radius mode: start and end radius in pixels emitter:setStartRadius(100) emitter:setStartRadiusVar(0) - emitter:setEndRadius(kCCParticleStartRadiusEqualToEndRadius) + emitter:setEndRadius(cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS) emitter:setEndRadiusVar(0) -- radius mode: degrees per second @@ -1004,7 +995,7 @@ local function RadiusMode2() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(4) @@ -1017,15 +1008,15 @@ local function RadiusMode2() emitter:setEndSpinVar(0) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(32) emitter:setStartSizeVar(0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -1043,25 +1034,24 @@ end local function Issue704() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(100) + emitter = cc.ParticleSystemQuad:createWithTotalParticles(100) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) + emitter:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) -- duration - emitter:setDuration(kCCParticleDurationInfinity) + emitter:setDuration(cc.PARTICLE_DURATION_INFINITY) -- radius mode - emitter:setEmitterMode(kCCParticleModeRadius) + emitter:setEmitterMode(cc.PARTICLE_MODE_RADIUS) -- radius mode: start and end radius in pixels emitter:setStartRadius(50) emitter:setStartRadiusVar(0) - emitter:setEndRadius(kCCParticleStartRadiusEqualToEndRadius) + emitter:setEndRadius(cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS ) emitter:setEndRadiusVar(0) -- radius mode: degrees per second @@ -1075,7 +1065,7 @@ local function Issue704() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(5) @@ -1088,15 +1078,15 @@ local function Issue704() emitter:setEndSpinVar(0) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(16) emitter:setStartSizeVar(0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -1104,8 +1094,8 @@ local function Issue704() -- additive emitter:setBlendAdditive(false) - local rot = CCRotateBy:create(16, 360) - emitter:runAction(CCRepeatForever:create(rot)) + local rot = cc.RotateBy:create(16, 360) + emitter:runAction(cc.RepeatForever:create(rot)) titleLabel:setString("Issue 704. Free + Rot") subtitleLabel:setString("Emitted particles should not rotate") @@ -1122,12 +1112,12 @@ local function updateQuads(dt) update(dt) Issue870_index = math.mod(Issue870_index + 1, 4) - local rect = CCRect(Issue870_index * 32, 0, 32, 32) + local rect = cc.rect(Issue870_index * 32, 0, 32, 32) emitter:setTextureWithRect(emitter:getTexture(), rect) end local function Issue870_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then Issue870_entry = scheduler:scheduleScriptFunc(updateQuads, 2.0, false) elseif tag == "exit" then @@ -1138,13 +1128,12 @@ end local function Issue870() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - local system = CCParticleSystemQuad:new() - system:initWithFile("Particles/SpinningPeas.plist") - system:setTextureWithRect(CCTextureCache:getInstance():addImage("Images/particles.png"), CCRect(0,0,32,32)) + local system = cc.ParticleSystemQuad:create("Particles/SpinningPeas.plist") + system:setTextureWithRect(cc.TextureCache:getInstance():addImage("Images/particles.png"), cc.rect(0,0,32,32)) layer:addChild(system, 10) emitter = system @@ -1162,16 +1151,16 @@ end local function MultipleParticleSystems() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - CCTextureCache:getInstance():addImage("Images/particles.png") + cc.TextureCache:getInstance():addImage("Images/particles.png") for i = 0, 4 do - local particleSystem = CCParticleSystemQuad:create("Particles/SpinningPeas.plist") + local particleSystem = cc.ParticleSystemQuad:create("Particles/SpinningPeas.plist") particleSystem:setPosition(i * 50, i * 50) - particleSystem:setPositionType(kCCPositionTypeGrouped) + particleSystem:setPositionType(cc.POSITION_TYPE_GROUPED ) layer:addChild(particleSystem) end @@ -1188,16 +1177,16 @@ end local function MultipleParticleSystemsBatched() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - local batchNode = CCParticleBatchNode:createWithTexture(nil, 3000) + local batchNode = cc.ParticleBatchNode:createWithTexture(nil, 3000) layer:addChild(batchNode, 1, 2) for i = 0, 4 do - local particleSystem = CCParticleSystemQuad:create("Particles/SpinningPeas.plist") - particleSystem:setPositionType(kCCPositionTypeGrouped) + local particleSystem = cc.ParticleSystemQuad:create("Particles/SpinningPeas.plist") + particleSystem:setPositionType(cc.POSITION_TYPE_GROUPED ) particleSystem:setPosition(i * 50, i * 50) batchNode:setTexture(particleSystem:getTexture()) batchNode:addChild(particleSystem) @@ -1219,15 +1208,15 @@ local AddAndDeleteParticleSystems_batchNode = nil local function removeSystem(dt) update(dt) - local ChildrenCount = AddAndDeleteParticleSystems_batchNode:getChildren():count() + local ChildrenCount = table.getn(AddAndDeleteParticleSystems_batchNode:getChildren()) if ChildrenCount > 0 then cclog("remove random system") local rand = math.mod(math.random(1, 999999), ChildrenCount - 1) - AddAndDeleteParticleSystems_batchNode:removeChild(AddAndDeleteParticleSystems_batchNode:getChildren():objectAtIndex(rand), true) + AddAndDeleteParticleSystems_batchNode:removeChild(AddAndDeleteParticleSystems_batchNode:getChildren()[(rand)], true) --add new - local particleSystem = CCParticleSystemQuad:create("Particles/Spiral.plist") - particleSystem:setPositionType(kCCPositionTypeGrouped) + local particleSystem = cc.ParticleSystemQuad:create("Particles/Spiral.plist") + particleSystem:setPositionType(cc.POSITION_TYPE_GROUPED ) particleSystem:setTotalParticles(200) particleSystem:setPosition(math.mod(math.random(1, 999999), 300) ,math.mod(math.random(1, 999999), 400)) @@ -1239,7 +1228,7 @@ local function removeSystem(dt) end local function AddAndDeleteParticleSystems_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then AddAndDeleteParticleSystems_entry = scheduler:scheduleScriptFunc(removeSystem, 2.0, false) elseif tag == "exit" then @@ -1250,20 +1239,20 @@ end local function AddAndDeleteParticleSystems() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil --adds the texture inside the plist to the texture cache - AddAndDeleteParticleSystems_batchNode = CCParticleBatchNode:createWithTexture(nil, 16000) + AddAndDeleteParticleSystems_batchNode = cc.ParticleBatchNode:createWithTexture(nil, 16000) layer:addChild(AddAndDeleteParticleSystems_batchNode, 1, 2) for i = 0, 5 do - local particleSystem = CCParticleSystemQuad:create("Particles/Spiral.plist") + local particleSystem = cc.ParticleSystemQuad:create("Particles/Spiral.plist") AddAndDeleteParticleSystems_batchNode:setTexture(particleSystem:getTexture()) - particleSystem:setPositionType(kCCPositionTypeGrouped) + particleSystem:setPositionType(cc.POSITION_TYPE_GROUPED ) particleSystem:setTotalParticles(200) particleSystem:setPosition(i * 15 + 100, i * 15 + 100) @@ -1290,14 +1279,16 @@ local ReorderParticleSystems_batchNode = nil local function reorderSystem(dt) update(dt) - local child = ReorderParticleSystems_batchNode:getChildren():randomObject() - -- problem: there's no getZOrder() for CCObject + local childArray = ReorderParticleSystems_batchNode:getChildren() + local random = math.random(1,table.getn(childArray)) + local child = childArray[random] + -- problem: there's no getZOrder() for cc.Object -- ReorderParticleSystems_batchNode:reorderChild(child, child:getZOrder() - 1) ReorderParticleSystems_batchNode:reorderChild(child, math.random(0, 99999)) end local function ReorderParticleSystems_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then ReorderParticleSystems_entry = scheduler:scheduleScriptFunc(reorderSystem, 2.0, false) elseif tag == "exit" then @@ -1308,29 +1299,28 @@ end local function ReorderParticleSystems() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background ,true) background = nil - ReorderParticleSystems_batchNode = CCParticleBatchNode:create("Images/stars-grayscale.png", 3000) + ReorderParticleSystems_batchNode = cc.ParticleBatchNode:create("Images/stars-grayscale.png", 3000) layer:addChild(ReorderParticleSystems_batchNode, 1, 2) for i = 0, 2 do - local particleSystem = CCParticleSystemQuad:new() - particleSystem:initWithTotalParticles(200) + local particleSystem = cc.ParticleSystemQuad:createWithTotalParticles(200) particleSystem:setTexture(ReorderParticleSystems_batchNode:getTexture()) -- duration - particleSystem:setDuration(kCCParticleDurationInfinity) + particleSystem:setDuration(cc.PARTICLE_DURATION_INFINITY) -- radius mode - particleSystem:setEmitterMode(kCCParticleModeRadius) + particleSystem:setEmitterMode(cc.PARTICLE_MODE_RADIUS) -- radius mode: 100 pixels from center particleSystem:setStartRadius(100) particleSystem:setStartRadiusVar(0) - particleSystem:setEndRadius(kCCParticleStartRadiusEqualToEndRadius) + particleSystem:setEndRadius(cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS ) particleSystem:setEndRadiusVar(0) -- not used when start == end -- radius mode: degrees per second @@ -1344,7 +1334,7 @@ local function ReorderParticleSystems() particleSystem:setAngleVar(0) -- emitter position - particleSystem:setPosVar(CCPoint(0, 0)) + particleSystem:setPosVar(cc.p(0, 0)) -- life of particles particleSystem:setLife(4) @@ -1357,27 +1347,23 @@ local function ReorderParticleSystems() particleSystem:setEndSpinVar(0) -- color of particles - local startColor = Color4F:new() - startColor.r = 0 - startColor.g = 0 - startColor.b = 0 - startColor.a = 1 + local startColor = cc.c4f(0, 0, 0, 1) if i == 0 then startColor.r = 1 elseif i == 1 then startColor.g = 1 elseif i == 2 then startColor.b = 1 end particleSystem:setStartColor(startColor) - particleSystem:setStartColorVar(Color4F(0, 0, 0, 0)) + particleSystem:setStartColorVar(cc.c4f(0, 0, 0, 0)) local endColor = startColor particleSystem:setEndColor(endColor) - particleSystem:setEndColorVar(Color4F(0, 0, 0, 0)) + particleSystem:setEndColorVar(cc.c4f(0, 0, 0, 0)) -- size, in pixels particleSystem:setStartSize(32) particleSystem:setStartSizeVar(0) - particleSystem:setEndSize(kCCParticleStartSizeEqualToEndSize) + particleSystem:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE) -- emits per second particleSystem:setEmissionRate(particleSystem:getTotalParticles() / particleSystem:getLife()) @@ -1386,9 +1372,9 @@ local function ReorderParticleSystems() particleSystem:setPosition(i * 10 + 120, 200) ReorderParticleSystems_batchNode:addChild(particleSystem) - particleSystem:setPositionType(kCCPositionTypeFree) + particleSystem:setPositionType(cc.POSITION_TYPE_FREE ) - particleSystem:release() + --particleSystem:release() end layer:registerScriptHandler(ReorderParticleSystems_onEnterOrExit) @@ -1405,23 +1391,20 @@ end local function PremultipliedAlphaTest() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 255)) + layer:setColor(cc.c3b(0, 0, 255)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:create("Particles/BoilingFoam.plist") + emitter = cc.ParticleSystemQuad:create("Particles/BoilingFoam.plist") - local tBlendFunc = BlendFunc:new() - tBlendFunc.src = 1 --GL_ONE - tBlendFunc.dst = 0x0303 --GL_ONE_MINUS_SRC_ALPHA - emitter:setBlendFunc(tBlendFunc) + emitter:setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) --assert(emitter:getOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless") - emitter:setStartColor(Color4F(1, 1, 1, 1)) - emitter:setEndColor(Color4F(1, 1, 1, 0)) - emitter:setStartColorVar(Color4F(0, 0, 0, 0)) - emitter:setEndColorVar(Color4F(0, 0, 0, 0)) + emitter:setStartColor(cc.c4f(1, 1, 1, 1)) + emitter:setEndColor(cc.c4f(1, 1, 1, 0)) + emitter:setStartColorVar(cc.c4f(0, 0, 0, 0)) + emitter:setEndColorVar(cc.c4f(0, 0, 0, 0)) layer:addChild(emitter, 10) @@ -1436,11 +1419,11 @@ end local function PremultipliedAlphaTest2() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:create("Particles/TestPremultipliedAlpha.plist") + emitter = cc.ParticleSystemQuad:create("Particles/TestPremultipliedAlpha.plist") layer:addChild(emitter ,10) titleLabel:setString("premultiplied alpha 2") @@ -1502,7 +1485,7 @@ end function ParticleTest() cclog("ParticleTest") - local scene = CCScene:create() + local scene = cc.Scene:create() SceneIdx = -1 scene:addChild(nextAction()) diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua index a2fba1bb9d..acf5a59927 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua @@ -3,68 +3,68 @@ local kBasicZOrder = 10 local kNodesIncrease = 250 local TEST_COUNT = 7 -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() ----------------------------------- -- For test functions ----------------------------------- local function performanceActions(sprite) - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 - local rot = CCRotateBy:create(period, 360.0 * math.random()) - local rot = CCRotateBy:create(period, 360.0 * math.random()) - local permanentRotation = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot:reverse())) + local rot = cc.RotateBy:create(period, 360.0 * math.random()) + local rot = cc.RotateBy:create(period, 360.0 * math.random()) + local permanentRotation = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(rot, rot:reverse())) sprite:runAction(permanentRotation) local growDuration = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 - local grow = CCScaleBy:create(growDuration, 0.5, 0.5) - local permanentScaleLoop = CCRepeatForever:create(CCSequence:createWithTwoActions(grow, grow:reverse())) + local grow = cc.ScaleBy:create(growDuration, 0.5, 0.5) + local permanentScaleLoop = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(grow, grow:reverse())) sprite:runAction(permanentScaleLoop) end local function performanceActions20(sprite) if math.random() < 0.2 then - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) else - sprite:setPosition(CCPoint(-1000, -1000)) + sprite:setPosition(cc.p(-1000, -1000)) end local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 - local rot = CCRotateBy:create(period, 360.0 * math.random()) - local permanentRotation = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot:reverse())) + local rot = cc.RotateBy:create(period, 360.0 * math.random()) + local permanentRotation = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(rot, rot:reverse())) sprite:runAction(permanentRotation) local growDuration = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 - local grow = CCScaleBy:create(growDuration, 0.5, 0.5) - local permanentScaleLoop = CCRepeatForever:create(CCSequence:createWithTwoActions(grow, grow:reverse())) + local grow = cc.ScaleBy:create(growDuration, 0.5, 0.5) + local permanentScaleLoop = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(grow, grow:reverse())) sprite:runAction(permanentScaleLoop) end local function performanceRotationScale(sprite) - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) sprite:setRotation(math.random() * 360) sprite:setScale(math.random() * 2) end local function performancePosition(sprite) - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) end local function performanceout20(sprite) if math.random() < 0.2 then - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) else - sprite:setPosition(CCPoint(-1000, -1000)) + sprite:setPosition(cc.p(-1000, -1000)) end end local function performanceOut100(sprite) - sprite:setPosition(CCPoint( -1000, -1000)) + sprite:setPosition(cc.p( -1000, -1000)) end local function performanceScale(sprite) - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) sprite:setScale(math.random() * 100 / 50) end @@ -72,43 +72,43 @@ end -- Subtest ----------------------------------- local subtestNumber = 1 -local batchNode = nil -- CCSpriteBatchNode -local parent = nil -- CCNode +local batchNode = nil -- cc.SpriteBatchNode +local parent = nil -- cc.Node local function initWithSubTest(nSubTest, p) subtestNumber = nSubTest parent = p batchNode = nil - local mgr = CCTextureCache:getInstance() + local mgr = cc.TextureCache:getInstance() -- remove all texture mgr:removeTexture(mgr:addImage("Images/grossinis_sister1.png")) mgr:removeTexture(mgr:addImage("Images/grossini_dance_atlas.png")) mgr:removeTexture(mgr:addImage("Images/spritesheet1.png")) if subtestNumber == 2 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - batchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + batchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 3 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - batchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + batchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 5 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - batchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + batchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 6 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - batchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + batchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 8 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - batchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + batchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 9 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - batchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + batchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) p:addChild(batchNode, 0) end @@ -117,21 +117,21 @@ local function initWithSubTest(nSubTest, p) batchNode:retain() end - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT) end local function createSpriteWithTag(tag) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) local sprite = nil if subtestNumber == 1 then - sprite = CCSprite:create("Images/grossinis_sister1.png") + sprite = cc.Sprite:create("Images/grossinis_sister1.png") parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 2 then - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(0, 0, 52, 139)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(0, 0, 52, 139)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 3 then - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(0, 0, 52, 139)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(0, 0, 52, 139)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 4 then local idx = math.floor((math.random() * 1400 / 100)) + 1 @@ -142,7 +142,7 @@ local function createSpriteWithTag(tag) num = idx end local str = "Images/grossini_dance_" .. num .. ".png" - sprite = CCSprite:create(str) + sprite = cc.Sprite:create(str) parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 5 then local y, x @@ -151,7 +151,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 5) x = x * 85 y = y * 121 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 85, 121)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 85, 121)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 6 then local y, x @@ -160,7 +160,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 5) x = x * 85 y = y * 121 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 85, 121)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 85, 121)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 7 then local y, x @@ -168,7 +168,7 @@ local function createSpriteWithTag(tag) y = math.floor(r / 8) x = math.mod(r, 8) local str = "Images/sprites_test/sprite-"..x.."-"..y..".png" - sprite = CCSprite:create(str) + sprite = cc.Sprite:create(str) parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 8 then local y, x @@ -177,7 +177,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 8) x = x * 32 y = y * 32 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 32, 32)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 32, 32)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 9 then local y, x @@ -186,11 +186,11 @@ local function createSpriteWithTag(tag) x = math.mod(r, 8) x = x * 32 y = y * 32 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 32, 32)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 32, 32)) batchNode:addChild(sprite, 0, tag + 100) end - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT) return sprite end @@ -215,7 +215,7 @@ local maxCases = 7 local function showThisTest() local scene = CreateSpriteTestScene() - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function backCallback(sender) @@ -240,23 +240,23 @@ local function nextCallback(sender) end local function toPerformanceMainLayer(sender) - CCDirector:getInstance():replaceScene(PerformanceTest()) + cc.Director:getInstance():replaceScene(PerformanceTest()) end local function initWithLayer(layer, controlMenuVisible) - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local mainItem = CCMenuItemFont:create("Back") + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local mainItem = cc.MenuItemFont:create("Back") mainItem:registerScriptTapHandler(toPerformanceMainLayer) mainItem:setPosition(s.width - 50, 25) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(mainItem) - menu:setPosition(CCPoint(0, 0)) + menu:setPosition(cc.p(0, 0)) if controlMenuVisible == true then - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) @@ -342,56 +342,56 @@ local function initWithMainTest(scene, asubtest, nNodes) lastRenderedCount = 0 quantityNodes = 0 - CCMenuItemFont:setFontSize(65) - local decrease = CCMenuItemFont:create(" - ") + cc.MenuItemFont:setFontSize(65) + local decrease = cc.MenuItemFont:create(" - ") decrease:registerScriptTapHandler(onDecrease) - decrease:setColor(Color3B(0, 200, 20)) - local increase = CCMenuItemFont:create(" + ") + decrease:setColor(cc.c3b(0, 200, 20)) + local increase = cc.MenuItemFont:create(" + ") increase:registerScriptTapHandler(onIncrease) - increase:setColor(Color3B(0, 200, 20)) + increase:setColor(cc.c3b(0, 200, 20)) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(decrease) menu:addChild(increase) menu:alignItemsHorizontally() menu:setPosition(s.width / 2, s.height - 65) scene:addChild(menu, 1) - infoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) - infoLabel:setColor(Color3B(0, 200, 20)) + infoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + infoLabel:setColor(cc.c3b(0, 200, 20)) infoLabel:setPosition(s.width / 2, s.height - 90) scene:addChild(infoLabel, 1) maxCases = TEST_COUNT -- Sub Tests - CCMenuItemFont:setFontSize(32) - subMenu = CCMenu:create() + cc.MenuItemFont:setFontSize(32) + subMenu = cc.Menu:create() for i = 1, 9 do local str = i .. " " - local itemFont = CCMenuItemFont:create(str) + local itemFont = cc.MenuItemFont:create(str) itemFont:registerScriptTapHandler(testNCallback) --itemFont:setTag(i) subMenu:addChild(itemFont, kBasicZOrder + i, kBasicZOrder + i) if i <= 3 then - itemFont:setColor(Color3B(200, 20, 20)) + itemFont:setColor(cc.c3b(200, 20, 20)) elseif i <= 6 then - itemFont:setColor(Color3B(0, 200, 20)) + itemFont:setColor(cc.c3b(0, 200, 20)) else - itemFont:setColor(Color3B(0, 20, 200)) + itemFont:setColor(cc.c3b(0, 20, 200)) end end subMenu:alignItemsHorizontally() - subMenu:setPosition(CCPoint(s.width / 2, 80)) + subMenu:setPosition(cc.p(s.width / 2, 80)) scene:addChild(subMenu, 1) -- add title label - titleLabel = CCLabelTTF:create("No title", "Arial", 40) + titleLabel = cc.LabelTTF:create("No title", "Arial", 40) scene:addChild(titleLabel, 1) titleLabel:setPosition(s.width / 2, s.height - 32) - titleLabel:setColor(Color3B(255, 255, 40)) + titleLabel:setColor(cc.c3b(255, 255, 40)) while quantityNodes < nNodes do onIncrease() @@ -406,7 +406,7 @@ function doPerformSpriteTest1(sprite) end local function SpriteTestLayer1() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "A (" .. subtestNumber .. ") position" @@ -423,7 +423,7 @@ function doPerformSpriteTest2(sprite) end local function SpriteTestLayer2() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "B (" .. subtestNumber .. ") scale" @@ -440,7 +440,7 @@ function doPerformSpriteTest3(sprite) end local function SpriteTestLayer3() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "C (" .. subtestNumber .. ") scale + rot" @@ -457,7 +457,7 @@ function doPerformSpriteTest4(sprite) end local function SpriteTestLayer4() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "D (" .. subtestNumber .. ") 100% out" @@ -474,7 +474,7 @@ function doPerformSpriteTest5(sprite) end local function SpriteTestLayer5() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "E (" .. subtestNumber .. ") 80% out" @@ -491,7 +491,7 @@ function doPerformSpriteTest6(sprite) end local function SpriteTestLayer6() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "F (" .. subtestNumber .. ") actions" @@ -508,7 +508,7 @@ function doPerformSpriteTest7(sprite) end local function SpriteTestLayer7() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "G (" .. subtestNumber .. ") actions 80% out" @@ -521,7 +521,7 @@ end -- PerformanceSpriteTest ----------------------------------- function CreateSpriteTestScene() - local scene = CCScene:create() + local scene = cc.Scene:create() initWithMainTest(scene, subtestNumber, kNodesIncrease) if curCase == 0 then diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua index f0527c93ad..6673fc8d67 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua @@ -13,7 +13,7 @@ local testsName = "PerformanceTouchesTest" } -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() --Create toMainLayr MenuItem function CreatePerfomBasicLayerMenu(pMenu) @@ -23,14 +23,14 @@ function CreatePerfomBasicLayerMenu(pMenu) local function toMainLayer() local pScene = PerformanceTestMain() if pScene ~= nil then - CCDirector:getInstance():replaceScene(pScene) + cc.Director:getInstance():replaceScene(pScene) end end --Create BackMneu - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local pMenuItemFont = cc.MenuItemFont:create("Back") + pMenuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end @@ -62,7 +62,7 @@ local function runNodeChildrenTest() local nMaxCases = 0 local nCurCase = 0 - local pNewscene = CCScene:create() + local pNewscene = cc.Scene:create() local function GetTitle() if 0 == nCurCase then @@ -125,21 +125,21 @@ local function runNodeChildrenTest() ShowCurrentTest() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -147,7 +147,7 @@ local function runNodeChildrenTest() local function updateQuantityLabel() if nQuantityOfNodes ~= nLastRenderedCount then -- local pInfoLabel = pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer) - local pInfoLabel = tolua.cast(pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "CCLabelTTF") + local pInfoLabel = tolua.cast(pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "LabelTTF") local strNode = nQuantityOfNodes.." nodes" pInfoLabel:setString(strNode) nLastRenderedCount = nQuantityOfNodes @@ -164,9 +164,9 @@ local function runNodeChildrenTest() return end local i = 0 - local len = pChildren:count() + local len = table.getn(pChildren) for i = 0, len - 1, 1 do - local child = tolua.cast(pChildren:objectAtIndex(i), "CCSprite") + local child = tolua.cast(pChildren[i + 1], "Sprite") child:setVisible(false) end end @@ -180,16 +180,16 @@ local function runNodeChildrenTest() local nTotalToAdd = nCurrentQuantityOfNodes * 0.15 local zs = {} if nTotalToAdd > 0 then - local pSprites = CCArray:createWithCapacity(nTotalToAdd) + local pSprites = {} local i = 0 for i = 0 , nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) - pSprites:addObject(pSprite) + local pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0,0,32,32)) + pSprites[i + 1] = pSprite zs[i] = math.random(-1,1) * 50 end for i = 0 , nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites:objectAtIndex(i),"CCNode") + local pChild = tolua.cast(pSprites[i + 1],"Node") pBatchNode:addChild(pChild, zs[i], NodeChildrenTestParam.kTagBase + i) end @@ -207,17 +207,16 @@ local function runNodeChildrenTest() end local nTotalToAdd = nCurrentQuantityOfNodes * 0.15 if nTotalToAdd > 0 then - local pSprites = CCArray:createWithCapacity(nTotalToAdd) - + local pSprites = {} -- Don't include the sprite creation time as part of the profiling local i = 0 for i = 0, nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) - pSprites:addObject(pSprite) + local pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0,0,32,32)) + pSprites[i + 1] = pSprite end -- add them with random Z (very important!) for i=0, nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites:objectAtIndex(i),"CCNode") + local pChild = tolua.cast(pSprites[i + 1],"Node") pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i) end @@ -235,18 +234,17 @@ local function runNodeChildrenTest() local nTotalToAdd = nCurrentQuantityOfNodes * 0.15 if nTotalToAdd > 0 then - local pSprites = CCArray:createWithCapacity(nTotalToAdd) - + local pSprites = {} -- Don't include the sprite creation time as part of the profiling local i = 0 for i = 0,nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) - pSprites:addObject(pSprite) + local pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0,0,32,32)) + pSprites[i + 1] = pSprite end --dd them with random Z (very important!) for i = 0, nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites:objectAtIndex(i),"CCNode") + local pChild = tolua.cast(pSprites[i + 1] ,"Node") pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i) end @@ -254,7 +252,7 @@ local function runNodeChildrenTest() -- reorder them for i = 0, nTotalToAdd - 1 do - local pNode = tolua.cast(pBatchNode:getChildren():objectAtIndex(i),"CCNode") + local pNode = tolua.cast(pSprites[i + 1],"Node") pBatchNode:reorderChild(pNode, math.random(-1,1) * 50) end pBatchNode:sortAllChildren() @@ -278,14 +276,14 @@ local function runNodeChildrenTest() end local function updateQuantityOfNodes() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() --increase nodes if( nCurrentQuantityOfNodes < nQuantityOfNodes ) then local i = 0 for i = 0,nQuantityOfNodes - nCurrentQuantityOfNodes - 1 do - local sprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0, 0, 32, 32)) + local sprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0, 0, 32, 32)) pBatchNode:addChild(sprite) - sprite:setPosition(CCPoint( math.random() * s.width, math.random() * s.height)) + sprite:setPosition(cc.p( math.random() * s.width, math.random() * s.height)) if 0 ~= nCurCase then sprite:setVisible(false) end @@ -325,29 +323,29 @@ local function runNodeChildrenTest() local function SpecialInitWithQuantityOfNodes() -- if 0 == nCurCase then - pBatchNode = CCSpriteBatchNode:create("Images/spritesheet1.png") + pBatchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png") pNewscene:addChild(pBatchNode) --[[ else - pBatchNode = CCSpriteBatchNode:create("Images/spritesheet1.png") + pBatchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png") pNewscene:addChild(pBatchNode) end ]]-- end local function MainSceneInitWithQuantityOfNodes(nNodes) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() --Title - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pNewscene:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + 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 = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16) + local pSubLabel = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) pNewscene:addChild(pSubLabel, 1) - pSubLabel:setPosition(CCPoint(s.width/2, s.height-80)) + pSubLabel:setPosition(cc.p(s.width/2, s.height-80)) end nLastRenderedCount = 0 @@ -355,33 +353,33 @@ local function runNodeChildrenTest() nQuantityOfNodes = nNodes --"+","-" Menu - CCMenuItemFont:setFontSize(65) - local pDecrease = CCMenuItemFont:create(" - ") + cc.MenuItemFont:setFontSize(65) + local pDecrease = cc.MenuItemFont:create(" - ") pDecrease:registerScriptTapHandler(onDecrease) - pDecrease:setColor(Color3B(0,200,20)) - local pIncrease = CCMenuItemFont:create(" + ") + pDecrease:setColor(cc.c3b(0,200,20)) + local pIncrease = cc.MenuItemFont:create(" + ") pIncrease:registerScriptTapHandler(onIncrease) - pIncrease:setColor(Color3B(0,200,20)) + pIncrease:setColor(cc.c3b(0,200,20)) - local pMenuAddOrSub = CCMenu:create() + local pMenuAddOrSub = cc.Menu:create() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewscene:addChild(pMenuAddOrSub,1) --InfoLayer - local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) - pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(CCPoint(s.width/2, s.height/2-15)) + local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setPosition(cc.p(s.width/2, s.height/2-15)) pNewscene:addChild(pInfoLabel, 1, NodeChildrenTestParam.kTagInfoLayer) --NodeChildrenMenuLayer - local pNodeChildrenMenuLayer = CCLayer:create() - local pNodeChildrenMenuMenu = CCMenu:create() + local pNodeChildrenMenuLayer = cc.Layer:create() + local pNodeChildrenMenuMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pNodeChildrenMenuMenu) CreateBasicLayerMenuItem(pNodeChildrenMenuMenu,true,NodeChildrenTestParam.TEST_COUNT,nCurCase) - pNodeChildrenMenuMenu:setPosition(CCPoint(0, 0)) + pNodeChildrenMenuMenu:setPosition(cc.p(0, 0)) pNodeChildrenMenuLayer:addChild(pNodeChildrenMenuMenu) pNewscene:addChild(pNodeChildrenMenuLayer) @@ -395,13 +393,13 @@ local function runNodeChildrenTest() pNewscene:unscheduleUpdate() end - pNewscene = CCScene:create() + pNewscene = cc.Scene:create() if nil ~= pNewscene then SpecialInitWithQuantityOfNodes() MainSceneInitWithQuantityOfNodes(nQuantityOfNodes) -- pNewscene:registerScriptHandler(onNodeEvent) NodeChildrenScheduleUpdate() - CCDirector:getInstance():replaceScene(pNewscene) + cc.Director:getInstance():replaceScene(pNewscene) end end @@ -442,7 +440,7 @@ local function runParticleTest() local ScheduleSelector = nil - local pNewScene = CCScene:create() + local pNewScene = cc.Scene:create() local function GetTitle() local strTitle = nil @@ -483,21 +481,21 @@ local function runParticleTest() ShowCurrentTest() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -510,7 +508,7 @@ local function runParticleTest() local function UpdateQuantityLabel() if nQuantityParticles ~= nLastRenderedCount then - local pInfoLabel = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagInfoLayer), "CCLabelTTF") + local pInfoLabel = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagInfoLayer), "LabelTTF") local strInfo = string.format("%u particles", nQuantityParticles) pInfoLabel:setString(strInfo) @@ -519,8 +517,8 @@ local function runParticleTest() end local function doTest() - local s = CCDirector:getInstance():getWinSize() - local pParticleSystem = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"CCParticleSystem") + local s = cc.Director:getInstance():getWinSize() + local pParticleSystem = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"ParticleSystem") if nil == pParticleSystem then return end @@ -529,7 +527,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(CCPoint(0,-90)) + pParticleSystem:setGravity(cc.p(0,-90)) --angle pParticleSystem:setAngle(90) @@ -544,8 +542,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(CCPoint(s.width/2, 100)) - pParticleSystem:setPosVar(CCPoint(s.width/2,0)) + pParticleSystem:setPosition(cc.p(s.width/2, 100)) + pParticleSystem:setPosVar(cc.p(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -555,13 +553,13 @@ local function runParticleTest() pParticleSystem:setEmissionRate(pParticleSystem:getTotalParticles() / pParticleSystem:getLife()) --color of particles - pParticleSystem:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setStartColorVar( Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColorVar( cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) - pParticleSystem:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels pParticleSystem:setEndSize(4.0) @@ -577,7 +575,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(CCPoint(0,-90)) + pParticleSystem:setGravity(cc.p(0,-90)) --angle pParticleSystem:setAngle(90) @@ -592,8 +590,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(CCPoint(s.width/2, 100)) - pParticleSystem:setPosVar(CCPoint(s.width/2,0)) + pParticleSystem:setPosition(cc.p(s.width/2, 100)) + pParticleSystem:setPosVar(cc.p(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -603,13 +601,13 @@ local function runParticleTest() pParticleSystem:setEmissionRate(pParticleSystem:getTotalParticles() / pParticleSystem:getLife()) --color of particles - pParticleSystem:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setStartColorVar( Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColorVar( cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) - pParticleSystem:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels pParticleSystem:setEndSize(8.0) @@ -624,7 +622,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(CCPoint(0,-90)) + pParticleSystem:setGravity(cc.p(0,-90)) --angle pParticleSystem:setAngle(90) @@ -639,8 +637,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(CCPoint(s.width/2, 100)) - pParticleSystem:setPosVar(CCPoint(s.width/2,0)) + pParticleSystem:setPosition(cc.p(s.width/2, 100)) + pParticleSystem:setPosVar(cc.p(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -650,13 +648,13 @@ local function runParticleTest() pParticleSystem:setEmissionRate(pParticleSystem:getTotalParticles() / pParticleSystem:getLife()) --color of particles - pParticleSystem:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setStartColorVar( Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColorVar( cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) - pParticleSystem:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels pParticleSystem:setEndSize(32.0) @@ -671,7 +669,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(CCPoint(0,-90)) + pParticleSystem:setGravity(cc.p(0,-90)) --angle pParticleSystem:setAngle(90) @@ -686,8 +684,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(CCPoint(s.width/2, 100)) - pParticleSystem:setPosVar(CCPoint(s.width/2,0)) + pParticleSystem:setPosition(cc.p(s.width/2, 100)) + pParticleSystem:setPosVar(cc.p(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -697,13 +695,13 @@ local function runParticleTest() pParticleSystem:setEmissionRate(pParticleSystem:getTotalParticles() / pParticleSystem:getLife()) --color of particles - pParticleSystem:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setStartColorVar( Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColorVar( cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) - pParticleSystem:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels pParticleSystem:setEndSize(64.0) @@ -733,21 +731,21 @@ local function runParticleTest() pNewScene:removeChildByTag(ParticleTestParam.kTagParticleSystem, true) --remove the "fire.png" from the TextureCache cache. - local pTexture = CCTextureCache:getInstance():addImage("Images/fire.png") - CCTextureCache:getInstance():removeTexture(pTexture) - local pParticleSystem = CCParticleSystemQuad:new() + local pTexture = cc.TextureCache:getInstance():addImage("Images/fire.png") + cc.TextureCache:getInstance():removeTexture(pTexture) + local pParticleSystem = cc.ParticleSystemQuad:new() if 1 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) elseif 2 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) elseif 3 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_A8) elseif 4 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) elseif 5 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) elseif 6 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_A8) else pParticleSystem = nil print("Shall not happen!") @@ -755,26 +753,26 @@ local function runParticleTest() if nil ~= pParticleSystem then pParticleSystem:initWithTotalParticles(nQuantityParticles) - pParticleSystem:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) + pParticleSystem:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) end pNewScene:addChild(pParticleSystem, 0, ParticleTestParam.kTagParticleSystem) doTest() --restore the default pixel format - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) end local function step(t) - local pAtlas = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagLabelAtlas),"CCLabelAtlas") - local pEmitter = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"CCParticleSystem") + local pAtlas = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagLabelAtlas),"LabelAtlas") + local pEmitter = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"ParticleSystem") local strInfo = string.format("%4d",pEmitter:getParticleCount()) pAtlas:setString(strInfo) end local function ScheduleFuncion() local function OnEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then ScheduleSelector = scheduler:scheduleScriptFunc(step,0,false) elseif tag == "exit" then @@ -806,69 +804,69 @@ local function runParticleTest() local function InitWithSubTest(nSubtest,nParticles) nSubtestNumber = nSubtest - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() nLastRenderedCount = 0 nQuantityParticles = nParticles --"+","-" Menu - CCMenuItemFont:setFontSize(65) - local pDecrease = CCMenuItemFont:create(" - ") + cc.MenuItemFont:setFontSize(65) + local pDecrease = cc.MenuItemFont:create(" - ") pDecrease:registerScriptTapHandler(onDecrease) - pDecrease:setColor(Color3B(0,200,20)) - local pIncrease = CCMenuItemFont:create(" + ") + pDecrease:setColor(cc.c3b(0,200,20)) + local pIncrease = cc.MenuItemFont:create(" + ") pIncrease:registerScriptTapHandler(onIncrease) - pIncrease:setColor(Color3B(0,200,20)) + pIncrease:setColor(cc.c3b(0,200,20)) - local pMenuAddOrSub = CCMenu:create() + local pMenuAddOrSub = cc.Menu:create() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) - local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) - pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(CCPoint(s.width/2, s.height - 90)) + local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setPosition(cc.p(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, ParticleTestParam.kTagInfoLayer) --particles on stage - local pLabelAtlas = CCLabelAtlas:create("0000", "fps_images.png", 12, 32, string.byte('.')) + local pLabelAtlas = cc.LabelAtlas:_create("0000", "fps_images.png", 12, 32, string.byte('.')) pNewScene:addChild(pLabelAtlas, 0, ParticleTestParam.kTagLabelAtlas) - pLabelAtlas:setPosition(CCPoint(s.width-66,50)) + pLabelAtlas:setPosition(cc.p(s.width-66,50)) --ParticleTestMenuLayer - local pParticleMenuLayer = CCLayer:create() - local pParticleMenu = CCMenu:create() + local pParticleMenuLayer = cc.Layer:create() + local pParticleMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pParticleMenu) CreateBasicLayerMenuItem(pParticleMenu,true,ParticleTestParam.TEST_COUNT,nCurCase) - pParticleMenu:setPosition(CCPoint(0, 0)) + pParticleMenu:setPosition(cc.p(0, 0)) pParticleMenuLayer:addChild(pParticleMenu) pNewScene:addChild(pParticleMenuLayer) --Sub Tests - CCMenuItemFont:setFontSize(40) - local pSubMenu = CCMenu:create() + cc.MenuItemFont:setFontSize(40) + local pSubMenu = cc.Menu:create() local i = 1 for i = 1, 6 do local strNum = string.format("%d ",i) - local pItemFont = CCMenuItemFont:create(strNum) + local pItemFont = cc.MenuItemFont:create(strNum) pItemFont:registerScriptTapHandler(TestNCallback) pSubMenu:addChild(pItemFont, i + ParticleTestParam.kSubMenuBasicZOrder) if i <= 3 then - pItemFont:setColor(Color3B(200,20,20)) + pItemFont:setColor(cc.c3b(200,20,20)) else - pItemFont:setColor(Color3B(0,200,20)) + pItemFont:setColor(cc.c3b(0,200,20)) end end pSubMenu:alignItemsHorizontally() - pSubMenu:setPosition(CCPoint(s.width/2, 80)) + pSubMenu:setPosition(cc.p(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pNewScene:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) UpdateQuantityLabel() CreateParticleSystem() @@ -877,11 +875,11 @@ local function runParticleTest() function ShowCurrentTest() if nil ~= pNewScene then - CCDirector:getInstance():getScheduler():unscheduleScriptEntry(ScheduleSelector) + cc.Director:getInstance():getScheduler():unscheduleScriptEntry(ScheduleSelector) end - pNewScene = CCScene:create() + pNewScene = cc.Scene:create() InitWithSubTest(nSubtestNumber,nQuantityParticles) - CCDirector:getInstance():replaceScene(pNewScene) + cc.Director:getInstance():replaceScene(pNewScene) end @@ -944,7 +942,7 @@ local function runSpriteTest() return strTitle end - local pNewScene = CCScene:create() + local pNewScene = cc.Scene:create() local function CreateBasicLayerMenuItem(pMenu,bMenuVisible,nMaxCasesNum,nCurCaseIndex) if nil ~= pMenu then @@ -971,28 +969,28 @@ local function runSpriteTest() ShowCurrentTest() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end local function UpdateNodes() if nQuantityNodes ~= nLastRenderedCount then - local pInfoLabel = tolua.cast(pNewScene:getChildByTag(SpriteTestParam.kTagInfoLayer), "CCLabelTTF") + local pInfoLabel = tolua.cast(pNewScene:getChildByTag(SpriteTestParam.kTagInfoLayer), "LabelTTF") local strInfo = string.format("%u nodes", nQuantityNodes) pInfoLabel:setString(strInfo) nLastRenderedCount = nQuantityNodes @@ -1000,99 +998,90 @@ local function runSpriteTest() end local function PerformancePosition(pSprite) - local size = CCDirector:getInstance():getWinSize() - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = cc.Director:getInstance():getWinSize() + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) end local function PerformanceScale(pSprite) - local size = CCDirector:getInstance():getWinSize() - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = cc.Director:getInstance():getWinSize() + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) pSprite:setScale(math.random() * 100 / 50) end local function PerformanceRotationScale(pSprite) - local size = CCDirector:getInstance():getWinSize() - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = cc.Director:getInstance():getWinSize() + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) pSprite:setRotation(math.random() * 360) pSprite:setScale(math.random() * 2) end local function PerformanceOut100(pSprite) - pSprite:setPosition(CCPoint( -1000, -1000)) + pSprite:setPosition(cc.p( -1000, -1000)) end local function Performanceout20(pSprite) - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() if math.random() < 0.2 then - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) else - pSprite:setPosition(CCPoint( -1000, -1000)) + pSprite:setPosition(cc.p( -1000, -1000)) end end local function PerformanceActions(pSprite) - local size = CCDirector:getInstance():getWinSize() - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = cc.Director:getInstance():getWinSize() + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) local fPeriod = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 - local pRot = CCRotateBy:create(fPeriod, 360.0 * math.random() ) + local pRot = cc.RotateBy:create(fPeriod, 360.0 * math.random() ) local pRot_back = pRot:reverse() - local arrRot = CCArray:create() - arrRot:addObject(pRot) - arrRot:addObject(pRot_back) - local pPermanentRotation = CCRepeatForever:create(CCSequence:create(arrRot)) + local pPermanentRotation = cc.RepeatForever:create(cc.Sequence:create(pRot, pRot_back)) pSprite:runAction(pPermanentRotation) local fGrowDuration = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 - local pGrow = CCScaleBy:create(fGrowDuration, 0.5, 0.5) - local arrGrow = CCArray:create() - arrGrow:addObject(pGrow) - arrGrow:addObject(pGrow:reverse()) - local pPermanentScaleLoop = CCRepeatForever:create(CCSequence:create(arrGrow)) + local pGrow = cc.ScaleBy:create(fGrowDuration, 0.5, 0.5) + local pPermanentScaleLoop = cc.RepeatForever:create(cc.Sequence:create(pGrow, pGrow:reverse())) pSprite:runAction(pPermanentScaleLoop) end local function PerformanceActions20(pSprite) - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() if math.random() < 0.2 then - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) else - pSprite:setPosition(CCPoint( -1000, -1000)) + pSprite:setPosition(cc.p( -1000, -1000)) end local pPeriod = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 - local pRot = CCRotateBy:create(pPeriod, 360.0 * math.random()) + local pRot = cc.RotateBy:create(pPeriod, 360.0 * math.random()) local pRot_back = pRot:reverse() - local arrRot = CCArray:create() - arrRot:addObject(pRot) - arrRot:addObject(pRot_back) - local pPermanentRotation = CCRepeatForever:create(CCSequence:create(arrRot)) + local pPermanentRotation = cc.RepeatForever:create(cc.Sequence:create(pRot, pRot_back)) pSprite:runAction(pPermanentRotation) local fGrowDuration = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 - local pGrow = CCScaleBy:create(fGrowDuration, 0.5, 0.5) - local pPermanentScaleLoop = CCRepeatForever:create(CCSequence:createWithTwoActions(pGrow, pGrow:reverse())) + local pGrow = cc.ScaleBy:create(fGrowDuration, 0.5, 0.5) + local pPermanentScaleLoop = cc.RepeatForever:create(cc.Sequence:create(pGrow, pGrow:reverse())) pSprite:runAction(pPermanentScaleLoop) end local function CreateSpriteWithTag(nTag) --create - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) local pSprite = nil if 1 == nSubtestNumber then - pSprite = CCSprite:create("Images/grossinis_sister1.png") + pSprite = cc.Sprite:create("Images/grossinis_sister1.png") pNewScene:addChild(pSprite, 0, nTag+100) elseif 2 == nSubtestNumber or 3 == nSubtestNumber then - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0, 0, 52, 139)) + pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0, 0, 52, 139)) pBatchNode:addChild(pSprite, 0, nTag+100) elseif 4 == nSubtestNumber then local nIndex = math.floor((math.random() * 1400 / 100)) + 1 local strPath = string.format("Images/grossini_dance_%02d.png", nIndex) - pSprite = CCSprite:create(strPath) + pSprite = cc.Sprite:create(strPath) pNewScene:addChild(pSprite, 0, nTag+100) elseif 5 == nSubtestNumber or 6 == nSubtestNumber then local nY = 0 @@ -1104,7 +1093,7 @@ local function runSpriteTest() nX = nX * 85 nY = nY * 121 - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(nX,nY,85,121)) + pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(nX,nY,85,121)) pBatchNode:addChild(pSprite, 0, nTag+100) elseif 7 == nSubtestNumber then local nX = 0 @@ -1115,7 +1104,7 @@ local function runSpriteTest() nY = math.floor(nR / 8) local strPath = string.format("Images/sprites_test/sprite-%d-%d.png", nX, nY) - pSprite = CCSprite:create(strPath) + pSprite = cc.Sprite:create(strPath) pNewScene:addChild(pSprite, 0, nTag+100) elseif 8 == nSubtestNumber or 9 == nSubtestNumber then local nX = 0 @@ -1127,10 +1116,10 @@ local function runSpriteTest() nX = nX * 32 nY = nY * 32 - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(nX,nY,32,32)) + pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(nX,nY,32,32)) pBatchNode:addChild(pSprite, 0, nTag+100) end - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT ) return pSprite end @@ -1215,7 +1204,7 @@ local function runSpriteTest() *12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each ]]-- --purge textures - local pMgr = CCTextureCache:getInstance() + local pMgr = cc.TextureCache:getInstance() --[mgr removeAllTextures] pMgr:removeTexture(pMgr:addImage("Images/grossinis_sister1.png")) pMgr:removeTexture(pMgr:addImage("Images/grossini_dance_atlas.png")) @@ -1223,28 +1212,28 @@ local function runSpriteTest() if 1 == nSubTest or 4 == nSubTest or 7 == nSubTest then elseif 2 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - pBatchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + pBatchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 3 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - pBatchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + pBatchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 5 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - pBatchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + pBatchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 6 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - pBatchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + pBatchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 8 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - pBatchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + pBatchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 9 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - pBatchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + pBatchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) pNewScene:addChild(pBatchNode, 0) end @@ -1252,85 +1241,85 @@ local function runSpriteTest() pBatchNode:retain() end - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT ) end local function InitWithSpriteTest(nSubtest,nNodes) nSubtestNumber = nSubtest --about create subset InitWithSubTest(nSubtest) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() nLastRenderedCount = 0 nQuantityNodes = 0 --"+","-" Menu - CCMenuItemFont:setFontSize(65) - local pDecrease = CCMenuItemFont:create(" - ") + cc.MenuItemFont:setFontSize(65) + local pDecrease = cc.MenuItemFont:create(" - ") pDecrease:registerScriptTapHandler(onDecrease) - pDecrease:setColor(Color3B(0,200,20)) - local pIncrease = CCMenuItemFont:create(" + ") + pDecrease:setColor(cc.c3b(0,200,20)) + local pIncrease = cc.MenuItemFont:create(" + ") pIncrease:registerScriptTapHandler(onIncrease) - pIncrease:setColor(Color3B(0,200,20)) + pIncrease:setColor(cc.c3b(0,200,20)) - local pMenuAddOrSub = CCMenu:create() + local pMenuAddOrSub = cc.Menu:create() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) - local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) - pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(CCPoint(s.width/2, s.height - 90)) + local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setPosition(cc.p(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, SpriteTestParam.kTagInfoLayer) --SpriteTestMenuLayer - local pSpriteMenuLayer = CCLayer:create() - local pSpriteMenu = CCMenu:create() + local pSpriteMenuLayer = cc.Layer:create() + local pSpriteMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pSpriteMenu) CreateBasicLayerMenuItem(pSpriteMenu,true,SpriteTestParam.TEST_COUNT,nCurCase) - pSpriteMenu:setPosition(CCPoint(0, 0)) + pSpriteMenu:setPosition(cc.p(0, 0)) pSpriteMenuLayer:addChild(pSpriteMenu) pNewScene:addChild(pSpriteMenuLayer,1,SpriteTestParam.kTagMenuLayer) --Sub Tests - CCMenuItemFont:setFontSize(40) - local pSubMenu = CCMenu:create() + cc.MenuItemFont:setFontSize(40) + local pSubMenu = cc.Menu:create() local i = 1 for i = 1, 9 do local strNum = string.format("%d ",i) - local pItemFont = CCMenuItemFont:create(strNum) + local pItemFont = cc.MenuItemFont:create(strNum) pItemFont:registerScriptTapHandler(TestNCallback) pSubMenu:addChild(pItemFont, i + SpriteTestParam.kSubMenuBasicZOrder) if i <= 3 then - pItemFont:setColor(Color3B(200,20,20)) + pItemFont:setColor(cc.c3b(200,20,20)) elseif i <= 6 then - pItemFont:setColor(Color3B(0,200,20)) + pItemFont:setColor(cc.c3b(0,200,20)) else - pItemFont:setColor(Color3B(0,20,200)) + pItemFont:setColor(cc.c3b(0,20,200)) end end pSubMenu:alignItemsHorizontally() - pSubMenu:setPosition(CCPoint(s.width/2, 80)) + pSubMenu:setPosition(cc.p(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pNewScene:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) while nQuantityNodes < nNodes do onIncrease() end end function ShowCurrentTest() - pNewScene = CCScene:create() + pNewScene = cc.Scene:create() InitWithSpriteTest(nSubtestNumber,nQuantityNodes) - CCDirector:getInstance():replaceScene(pNewScene) + cc.Director:getInstance():replaceScene(pNewScene) end InitWithSpriteTest(1,SpriteTestParam.kInitNodes) @@ -1357,16 +1346,16 @@ local function runTextureTest() end local nTexCurCase = 0 - local pNewscene = CCScene:create() - local pLayer = CCLayer:create() - local s = CCDirector:getInstance():getWinSize() + local pNewscene = cc.Scene:create() + local pLayer = cc.Layer:create() + local s = cc.Director:getInstance():getWinSize() local function PerformTestsPNG(strFileName) local time local pTexture = nil - local pCache = CCTextureCache:getInstance() + local pCache = cc.TextureCache:getInstance() print("RGBA 8888") - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then --os.time()--get secs,not micr sec @@ -1377,7 +1366,7 @@ local function runTextureTest() pCache:removeTexture(pTexture) print("RGBA 4444") - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) --gettimeofday(&now, NULL) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then @@ -1388,7 +1377,7 @@ local function runTextureTest() pCache:removeTexture(pTexture) print("RGBA 5551") - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB5A1) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1) --gettimeofday(&now, NULL) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then @@ -1399,7 +1388,7 @@ local function runTextureTest() pCache:removeTexture(pTexture) print("RGB 565") - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB565) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565) -- gettimeofday(&now, NULL) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then @@ -1437,20 +1426,20 @@ local function runTextureTest() end --Title - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pLayer:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) --Subtitle - local pSubLabel = CCLabelTTF:create(GetSubtitle(), "Thonburi", 16) + local pSubLabel = cc.LabelTTF:create(GetSubtitle(), "Thonburi", 16) pLayer:addChild(pSubLabel, 1) - pSubLabel:setPosition(CCPoint(s.width/2, s.height-80)) + pSubLabel:setPosition(cc.p(s.width/2, s.height-80)) --menu - local pMenu = CCMenu:create() + local pMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pMenu) - pMenu:setPosition(CCPoint(0, 0)) + pMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pMenu) PerformTests() @@ -1481,9 +1470,9 @@ local function runTouchesTest() local nNumberOfTouchesC = 0 local fElapsedTime = 0.0 - local s = CCDirector:getInstance():getWinSize() - local pNewscene = CCScene:create() - local pLayer = CCLayer:create() + local s = cc.Director:getInstance():getWinSize() + local pNewscene = cc.Scene:create() + local pLayer = cc.Layer:create() local function GetTitle() if 0 == nCurCase then @@ -1518,21 +1507,21 @@ local function runTouchesTest() ShowCurrentTest() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -1606,22 +1595,22 @@ local function runTouchesTest() local function InitLayer() --menu - local pTouchesTestMenu = CCMenu:create() + local pTouchesTestMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pTouchesTestMenu) CreateBasicLayerMenuItem(pTouchesTestMenu,true,TouchesTestParam.TEST_COUNT,nCurCase) - pTouchesTestMenu:setPosition(CCPoint(0, 0)) + pTouchesTestMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pTouchesTestMenu) --Title - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pLayer:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) pLayer:scheduleUpdateWithPriorityLua(update,0) - pClassLabel = CCLabelBMFont:create("00.0", "fonts/arial16.fnt") - pClassLabel:setPosition(CCPoint(s.width/2, s.height/2)) + pClassLabel = cc.LabelBMFont:create("00.0", "fonts/arial16.fnt") + pClassLabel:setPosition(cc.p(s.width/2, s.height/2)) pLayer:addChild(pClassLabel) fElapsedTime = 0.0 @@ -1639,13 +1628,13 @@ local function runTouchesTest() pLayer:unscheduleUpdate() end - pNewscene = CCScene:create() + pNewscene = cc.Scene:create() if nil ~= pNewscene then - pLayer = CCLayer:create() + pLayer = cc.Layer:create() InitLayer() pNewscene:addChild(pLayer) - CCDirector:getInstance():replaceScene(pNewscene) + cc.Director:getInstance():replaceScene(pNewscene) end end @@ -1676,19 +1665,19 @@ local function menuCallback(tag, pMenuItem) local nIdx = pMenuItem:getZOrder() - kItemTagBasic local PerformanceTestScene = CreatePerformancesTestScene(nIdx) if nil ~= PerformanceTestScene then - CCDirector:getInstance():replaceScene(PerformanceTestScene) + cc.Director:getInstance():replaceScene(PerformanceTestScene) end end local function PerformanceMainLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() - local menu = CCMenu:create() - menu:setPosition(CCPoint(0, 0)) - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) + local menu = cc.Menu:create() + menu:setPosition(cc.p(0, 0)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) for i = 1, MAX_COUNT do - local item = CCMenuItemFont:create(testsName[i]) + local item = cc.MenuItemFont:create(testsName[i]) item:registerScriptTapHandler(menuCallback) item:setPosition(s.width / 2, s.height - (i + 1) * LINE_SPACE) menu:addChild(item, kItemTagBasic + i) @@ -1703,7 +1692,7 @@ end -- Performance Test ------------------------------------- function PerformanceTestMain() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(PerformanceMainLayer()) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua b/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua index aa8686027f..4fe937a42d 100644 --- a/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua @@ -7,7 +7,7 @@ local function RenderTextureSave() local ret = createTestLayer("Touch the screen", "Press 'Save Image' to create an snapshot of the render texture") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local m_pTarget = nil local m_pBrush = nil local m_pTarget = nil @@ -20,20 +20,20 @@ local function RenderTextureSave() local png = string.format("image-%d.png", counter) local jpg = string.format("image-%d.jpg", counter) - m_pTarget:saveToFile(png, kCCImageFormatPNG) - m_pTarget:saveToFile(jpg, kCCImageFormatJPEG) + m_pTarget:saveToFile(png, cc.IMAGE_FORMAT_PNG) + m_pTarget:saveToFile(jpg, cc.IMAGE_FORMAT_JPEG) - local pImage = m_pTarget:newCCImage() + local pImage = m_pTarget:newImage() - local tex = CCTextureCache:getInstance():addUIImage(pImage, png) + local tex = cc.TextureCache:getInstance():addUIImage(pImage, png) pImage:release() - local sprite = CCSprite:createWithTexture(tex) + local sprite = cc.Sprite:createWithTexture(tex) sprite:setScale(0.3) ret:addChild(sprite) - sprite:setPosition(CCPoint(40, 40)) + sprite:setPosition(cc.p(40, 40)) sprite:setRotation(counter * 3) cclog("Image saved %s and %s", png, jpg) @@ -44,25 +44,25 @@ local function RenderTextureSave() if event == "exit" then m_pBrush:release() m_pTarget:release() - CCTextureCache:getInstance():removeUnusedTextures() + cc.TextureCache:getInstance():removeUnusedTextures() end end ret:registerScriptHandler(onNodeEvent) -- create a render texture, this is what we are going to draw into - m_pTarget = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888) + m_pTarget = cc.RenderTexture:create(s.width, s.height, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) m_pTarget:retain() - m_pTarget:setPosition(CCPoint(s.width / 2, s.height / 2)) + m_pTarget:setPosition(cc.p(s.width / 2, s.height / 2)) - -- note that the render texture is a CCNode, and contains a sprite of its texture for convience, - -- so we can just parent it to the scene like any other CCNode + -- note that the render texture is a cc.Node, and contains a sprite of its texture for convience, + -- so we can just parent it to the scene like any other cc.Node ret:addChild(m_pTarget, -1) -- create a brush image to draw into the texture with - m_pBrush = CCSprite:create("Images/fire.png") + m_pBrush = cc.Sprite:create("Images/fire.png") m_pBrush:retain() - m_pBrush:setColor(Color3B(255, 0, 0)) + m_pBrush:setColor(cc.c3b(255, 0, 0)) m_pBrush:setOpacity(20) @@ -76,15 +76,15 @@ local function RenderTextureSave() local diffX = x - prev.x local diffY = y - prev.y - local startP = CCPoint(x, y) - local endP = CCPoint(prev.x, prev.y) + local startP = cc.p(x, y) + local endP = cc.p(prev.x, prev.y) -- begin drawing to the render texture m_pTarget:begin() -- for extra points, we'll draw this smoothly from the last position and vary the sprite's -- scale/rotation/offset - local distance = startP:getDistance(endP) + local distance = cc.pGetDistance(startP, endP) if distance > 1 then local d = distance local i = 0 @@ -92,13 +92,13 @@ local function RenderTextureSave() local difx = endP.x - startP.x local dify = endP.y - startP.y local delta = i / distance - m_pBrush:setPosition(CCPoint(startP.x + (difx * delta), startP.y + (dify * delta))) + m_pBrush:setPosition(cc.p(startP.x + (difx * delta), startP.y + (dify * delta))) m_pBrush:setRotation(math.random(0, 359)) local r = math.random(0, 49) / 50.0 + 0.25 m_pBrush:setScale(r) - -- Use CCRANDOM_0_1() will cause error when loading libtests.so on android, I don't know why. - m_pBrush:setColor(Color3B(math.random(0, 126) + 128, 255, 255)) + -- Use cc.RANDOM_0_1() will cause error when loading libtests.so on android, I don't know why. + m_pBrush:setColor(cc.c3b(math.random(0, 126) + 128, 255, 255)) -- Call visit to draw the brush, don't call draw.. m_pBrush:visit() end @@ -115,18 +115,15 @@ local function RenderTextureSave() ret:setTouchEnabled(true) ret:registerScriptTouchHandler(onTouchEvent) -- Save Image menu - CCMenuItemFont:setFontSize(16) - local item1 = CCMenuItemFont:create("Save Image") + cc.MenuItemFont:setFontSize(16) + local item1 = cc.MenuItemFont:create("Save Image") item1:registerScriptTapHandler(saveImage) - local item2 = CCMenuItemFont:create("Clear") + local item2 = cc.MenuItemFont:create("Clear") item2:registerScriptTapHandler(clearImage) - local arr = CCArray:create() - arr:addObject(item1) - arr:addObject(item2) - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item1, item2) ret:addChild(menu) menu:alignItemsVertically() - menu:setPosition(CCPoint(VisibleRect:rightTop().x - 80, VisibleRect:rightTop().y - 30)) + menu:setPosition(cc.p(VisibleRect:rightTop().x - 80, VisibleRect:rightTop().y - 30)) return ret end @@ -150,20 +147,20 @@ end -- * B1: non-premulti sprite -- * B2: non-premulti render -- */ --- local background = CCLayerColor:create(Color4B(200,200,200,255)) +-- local background = cc.LayerColor:create(cc.c4b(200,200,200,255)) -- addChild(background) --- local spr_premulti = CCSprite:create("Images/fire.png") --- spr_premulti:setPosition(CCPoint(16,48)) +-- local spr_premulti = cc.Sprite:create("Images/fire.png") +-- spr_premulti:setPosition(cc.p(16,48)) --- local spr_nonpremulti = CCSprite:create("Images/fire.png") --- spr_nonpremulti:setPosition(CCPoint(16,16)) +-- local spr_nonpremulti = cc.Sprite:create("Images/fire.png") +-- spr_nonpremulti:setPosition(cc.p(16,16)) -- /* A2 & B2 setup */ --- local rend = CCRenderTexture:create(32, 64, kCCTexture2DPixelFormat_RGBA8888) +-- local rend = cc.RenderTexture:create(32, 64, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) -- if (NULL == rend) @@ -178,14 +175,14 @@ end -- spr_nonpremulti:visit() -- rend:end() --- local s = CCDirector:getInstance():getWinSize() +-- local s = cc.Director:getInstance():getWinSize() -- --/* A1: setup */ --- spr_premulti:setPosition(CCPoint(s.width/2-16, s.height/2+16)) +-- spr_premulti:setPosition(cc.p(s.width/2-16, s.height/2+16)) -- --/* B1: setup */ --- spr_nonpremulti:setPosition(CCPoint(s.width/2-16, s.height/2-16)) +-- spr_nonpremulti:setPosition(cc.p(s.width/2-16, s.height/2-16)) --- rend:setPosition(CCPoint(s.width/2+16, s.height/2)) +-- rend:setPosition(cc.p(s.width/2+16, s.height/2)) -- addChild(spr_nonpremulti) -- addChild(spr_premulti) @@ -207,7 +204,7 @@ end -- local pLayer = nextTestCase() -- addChild(pLayer) --- CCDirector:getInstance():replaceScene(this) +-- cc.Director:getInstance():replaceScene(this) -- end -- --/** @@ -217,35 +214,35 @@ end -- local function RenderTextureZbuffer() -- this:setTouchEnabled(true) --- local size = CCDirector:getInstance():getWinSize() --- local label = CCLabelTTF:create("vertexZ = 50", "Marker Felt", 64) --- label:setPosition(CCPoint(size.width / 2, size.height * 0.25)) +-- local size = cc.Director:getInstance():getWinSize() +-- local label = cc.LabelTTF:create("vertexZ = 50", "Marker Felt", 64) +-- label:setPosition(cc.p(size.width / 2, size.height * 0.25)) -- this:addChild(label) --- local label2 = CCLabelTTF:create("vertexZ = 0", "Marker Felt", 64) --- label2:setPosition(CCPoint(size.width / 2, size.height * 0.5)) +-- local label2 = cc.LabelTTF:create("vertexZ = 0", "Marker Felt", 64) +-- label2:setPosition(cc.p(size.width / 2, size.height * 0.5)) -- this:addChild(label2) --- local label3 = CCLabelTTF:create("vertexZ = -50", "Marker Felt", 64) --- label3:setPosition(CCPoint(size.width / 2, size.height * 0.75)) +-- local label3 = cc.LabelTTF:create("vertexZ = -50", "Marker Felt", 64) +-- label3:setPosition(cc.p(size.width / 2, size.height * 0.75)) -- this:addChild(label3) -- label:setVertexZ(50) -- label2:setVertexZ(0) -- label3:setVertexZ(-50) --- CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("Images/bugs/circle.plist") --- mgr = CCSpriteBatchNode:create("Images/bugs/circle.png", 9) +-- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("Images/bugs/circle.plist") +-- mgr = cc.SpriteBatchNode:create("Images/bugs/circle.png", 9) -- this:addChild(mgr) --- sp1 = CCSprite:createWithSpriteFrameName("circle.png") --- sp2 = CCSprite:createWithSpriteFrameName("circle.png") --- sp3 = CCSprite:createWithSpriteFrameName("circle.png") --- sp4 = CCSprite:createWithSpriteFrameName("circle.png") --- sp5 = CCSprite:createWithSpriteFrameName("circle.png") --- sp6 = CCSprite:createWithSpriteFrameName("circle.png") --- sp7 = CCSprite:createWithSpriteFrameName("circle.png") --- sp8 = CCSprite:createWithSpriteFrameName("circle.png") --- sp9 = CCSprite:createWithSpriteFrameName("circle.png") +-- sp1 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp2 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp3 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp4 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp5 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp6 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp7 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp8 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp9 = cc.Sprite:createWithSpriteFrameName("circle.png") -- mgr:addChild(sp1, 9) -- mgr:addChild(sp2, 8) @@ -268,7 +265,7 @@ end -- sp9:setVertexZ(-400) -- sp9:setScale(2) --- sp9:setColor(Color3B::YELLOW) +-- sp9:setColor(cc.c3b::YELLOW) -- end -- local function title() @@ -281,13 +278,13 @@ end -- return "Touch screen. It should be green" -- end --- local function ccTouchesBegan(cocos2d:CCSet *touches, cocos2d:CCEvent *event) +-- local function ccTouchesBegan(cocos2d:cc.Set *touches, cocos2d:cc.Event *event) --- CCSetIterator iter --- CCTouch *touch +-- cc.SetIterator iter +-- cc.Touch *touch -- for (iter = touches:begin() iter != touches:end() ++iter) --- touch = (CCTouch *)(*iter) +-- touch = (cc.Touch *)(*iter) -- local location = touch:getLocation() -- sp1:setPosition(location) @@ -302,13 +299,13 @@ end -- end -- end --- local function ccTouchesMoved(CCSet* touches, CCEvent* event) +-- local function ccTouchesMoved(cc.Set* touches, cc.Event* event) --- CCSetIterator iter --- CCTouch *touch +-- cc.SetIterator iter +-- cc.Touch *touch -- for (iter = touches:begin() iter != touches:end() ++iter) --- touch = (CCTouch *)(*iter) +-- touch = (cc.Touch *)(*iter) -- local location = touch:getLocation() -- sp1:setPosition(location) @@ -323,35 +320,35 @@ end -- end -- end --- local function ccTouchesEnded(CCSet* touches, CCEvent* event) +-- local function ccTouchesEnded(cc.Set* touches, cc.Event* event) -- this:renderScreenShot() -- end -- local function renderScreenShot() --- local texture = CCRenderTexture:create(512, 512) +-- local texture = cc.RenderTexture:create(512, 512) -- if (NULL == texture) -- return -- end --- texture:setAnchorPoint(CCPoint(0, 0)) +-- texture:setAnchorPoint(cc.p(0, 0)) -- texture:begin() -- this:visit() -- texture:end() --- local sprite = CCSprite:createWithTexture(texture:getSprite():getTexture()) +-- local sprite = cc.Sprite:createWithTexture(texture:getSprite():getTexture()) --- sprite:setPosition(CCPoint(256, 256)) +-- sprite:setPosition(cc.p(256, 256)) -- sprite:setOpacity(182) -- sprite:setFlipY(1) -- this:addChild(sprite, 999999) --- sprite:setColor(Color3B::GREEN) +-- sprite:setColor(cc.c3b::GREEN) --- sprite:runAction(CCSequence:create(CCFadeTo:create(2, 0), --- CCHide:create(), +-- sprite:runAction(cc.Sequence:create(cc.FadeTo:create(2, 0), +-- cc.Hide:create(), -- NULL)) -- end @@ -359,12 +356,12 @@ end -- local function RenderTextureTestDepthStencil() --- local s = CCDirector:getInstance():getWinSize() +-- local s = cc.Director:getInstance():getWinSize() --- local sprite = CCSprite:create("Images/fire.png") --- sprite:setPosition(CCPoint(s.width * 0.25, 0)) +-- local sprite = cc.Sprite:create("Images/fire.png") +-- sprite:setPosition(cc.p(s.width * 0.25, 0)) -- sprite:setScale(10) --- local rend = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8) +-- local rend = cc.RenderTexture:create(s.width, s.height, kcc.Texture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8) -- glStencilMask(0xFF) -- rend:beginWithClear(0, 0, 0, 0, 0, 0) @@ -377,7 +374,7 @@ end -- sprite:visit() -- --! move sprite half width and height, and draw only where not marked --- sprite:setPosition(CCPoint.__add(sprite:getPosition(), CCPoint.__mul(CCPoint(sprite:getContentSize().width * sprite:getScale(), sprite:getContentSize().height * sprite:getScale()), 0.5))) +-- sprite:setPosition(cc.p__add(sprite:getPosition(), cc.p__mul(cc.p(sprite:getContentSize().width * sprite:getScale(), sprite:getContentSize().height * sprite:getScale()), 0.5))) -- glStencilFunc(GL_NOTEQUAL, 1, 0xFF) -- glColorMask(1, 1, 1, 1) -- sprite:visit() @@ -386,7 +383,7 @@ end -- glDisable(GL_STENCIL_TEST) --- rend:setPosition(CCPoint(s.width * 0.5, s.height * 0.5)) +-- rend:setPosition(cc.p(s.width * 0.5, s.height * 0.5)) -- this:addChild(rend) -- end @@ -416,29 +413,29 @@ end -- * B1: non-premulti sprite -- * B2: non-premulti render -- */ --- local background = CCLayerColor:create(Color4B(40,40,40,255)) +-- local background = cc.LayerColor:create(cc.c4b(40,40,40,255)) -- addChild(background) -- -- sprite 1 --- sprite1 = CCSprite:create("Images/fire.png") +-- sprite1 = cc.Sprite:create("Images/fire.png") -- -- sprite 2 --- sprite2 = CCSprite:create("Images/fire_rgba8888.pvr") +-- sprite2 = cc.Sprite:create("Images/fire_rgba8888.pvr") --- local s = CCDirector:getInstance():getWinSize() +-- local s = cc.Director:getInstance():getWinSize() -- /* Create the render texture */ --- local renderTexture = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444) +-- local renderTexture = cc.RenderTexture:create(s.width, s.height, kcc.Texture2DPixelFormat_RGBA4444) -- this:renderTexture = renderTexture --- renderTexture:setPosition(CCPoint(s.width/2, s.height/2)) --- -- [renderTexture setPosition:CCPoint(s.width, s.height)] +-- renderTexture:setPosition(cc.p(s.width/2, s.height/2)) +-- -- [renderTexture setPosition:cc.p(s.width, s.height)] -- -- renderTexture.scale = 2 -- /* add the sprites to the render texture */ -- renderTexture:addChild(sprite1) -- renderTexture:addChild(sprite2) --- renderTexture:setClearColor(Color4F(0, 0, 0, 0)) +-- renderTexture:setClearColor(cc.c4f(0, 0, 0, 0)) -- renderTexture:setClearFlags(GL_COLOR_BUFFER_BIT) -- /* add the render texture to the scene */ @@ -449,14 +446,14 @@ end -- scheduleUpdate() -- -- Toggle clear on / off --- local item = CCMenuItemFont:create("Clear On/Off", this, menu_selector(RenderTextureTargetNode:touched)) --- local menu = CCMenu:create(item, NULL) +-- local item = cc.MenuItemFont:create("Clear On/Off", this, menu_selector(RenderTextureTargetNode:touched)) +-- local menu = cc.Menu:create(item, NULL) -- addChild(menu) --- menu:setPosition(CCPoint(s.width/2, s.height/2)) +-- menu:setPosition(cc.p(s.width/2, s.height/2)) -- end --- local function touched(CCObject* sender) +-- local function touched(cc.Object* sender) -- if (renderTexture:getClearFlags() == 0) @@ -465,7 +462,7 @@ end -- else -- renderTexture:setClearFlags(0) --- renderTexture:setClearColor(Color4F( CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)) +-- renderTexture:setClearColor(cc.c4f( cc.RANDOM_0_1(), cc.RANDOM_0_1(), cc.RANDOM_0_1(), 1)) -- end -- end @@ -473,8 +470,8 @@ end -- static float time = 0 -- float r = 80 --- sprite1:setPosition(CCPoint(cosf(time * 2) * r, sinf(time * 2) * r)) --- sprite2:setPosition(CCPoint(sinf(time * 2) * r, cosf(time * 2) * r)) +-- sprite1:setPosition(cc.p(cosf(time * 2) * r, sinf(time * 2) * r)) +-- sprite2:setPosition(cc.p(sinf(time * 2) * r, cosf(time * 2) * r)) -- time += dt -- end @@ -493,7 +490,7 @@ end -- local function SimpleSprite() : rt(NULL) {} --- local function SimpleSprite* SpriteRenderTextureBug:SimpleSprite:create(const char* filename, const CCRect &rect) +-- local function SimpleSprite* SpriteRenderTextureBug:SimpleSprite:create(const char* filename, const cc.rect &rect) -- SimpleSprite *sprite = new SimpleSprite() -- if (sprite && sprite:initWithFile(filename, rect)) @@ -502,7 +499,7 @@ end -- end -- else --- CC_SAFE_DELETE(sprite) +-- cc._SAFE_DELETE(sprite) -- end -- return sprite @@ -512,14 +509,14 @@ end -- if (rt == NULL) --- local s = CCDirector:getInstance():getWinSize() --- rt = new CCRenderTexture() --- rt:initWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888) +-- local s = cc.Director:getInstance():getWinSize() +-- rt = new cc.RenderTexture() +-- rt:initWithWidthAndHeight(s.width, s.height, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) -- end -- rt:beginWithClear(0.0, 0.0, 0.0, 1.0) -- rt:end() --- CC_NODE_DRAW_SETUP() +-- cc._NODE_DRAW_SETUP() -- BlendFunc blend = getBlendFunc() -- ccGLBlendFunc(blend.src, blend.dst) @@ -530,22 +527,22 @@ end -- -- Attributes -- -- --- ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex) +-- ccGLEnableVertexAttribs(kcc.VertexAttribFlag_PosColorTex) -- #define kQuadSize sizeof(m_sQuad.bl) -- long offset = (long)&m_sQuad -- -- vertex -- int diff = offsetof( V3F_C4B_T2F, vertices) --- glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)) +-- glVertexAttribPointer(kcc.VertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)) -- -- texCoods -- diff = offsetof( V3F_C4B_T2F, texCoords) --- glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)) +-- glVertexAttribPointer(kcc.VertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)) -- -- color -- diff = offsetof( V3F_C4B_T2F, colors) --- glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)) +-- glVertexAttribPointer(kcc.VertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)) -- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) -- end @@ -554,51 +551,51 @@ end -- setTouchEnabled(true) --- local s = CCDirector:getInstance():getWinSize() --- addNewSpriteWithCoords(CCPoint(s.width/2, s.height/2)) +-- local s = cc.Director:getInstance():getWinSize() +-- addNewSpriteWithCoords(cc.p(s.width/2, s.height/2)) -- end --- local function SimpleSprite* SpriteRenderTextureBug:addNewSpriteWithCoords(const CCPoint& p) +-- local function SimpleSprite* SpriteRenderTextureBug:addNewSpriteWithCoords(const cc.p& p) --- int idx = CCRANDOM_0_1() * 1400 / 100 +-- int idx = cc.RANDOM_0_1() * 1400 / 100 -- int x = (idx%5) * 85 -- int y = (idx/5) * 121 -- SpriteRenderTextureBug:SimpleSprite *sprite = SpriteRenderTextureBug:SimpleSprite:create("Images/grossini_dance_atlas.png", --- CCRect(x,y,85,121)) +-- cc.rect(x,y,85,121)) -- addChild(sprite) -- sprite:setPosition(p) -- local action = NULL --- float rd = CCRANDOM_0_1() +-- float rd = cc.RANDOM_0_1() -- if (rd < 0.20) --- action = CCScaleBy:create(3, 2) +-- action = cc.ScaleBy:create(3, 2) -- else if (rd < 0.40) --- action = CCRotateBy:create(3, 360) +-- action = cc.RotateBy:create(3, 360) -- else if (rd < 0.60) --- action = CCBlink:create(1, 3) +-- action = cc.Blink:create(1, 3) -- else if (rd < 0.8 ) --- action = CCTintBy:create(2, 0, -255, -255) +-- action = cc.TintBy:create(2, 0, -255, -255) -- else --- action = CCFadeOut:create(2) +-- action = cc.FadeOut:create(2) -- local action_back = action:reverse() --- local seq = CCSequence:create(action, action_back, NULL) +-- local seq = cc.Sequence:create(action, action_back, NULL) --- sprite:runAction(CCRepeatForever:create(seq)) +-- sprite:runAction(cc.RepeatForever:create(seq)) -- --return sprite -- return NULL -- end --- local function ccTouchesEnded(CCSet* touches, CCEvent* event) +-- local function ccTouchesEnded(cc.Set* touches, cc.Event* event) --- CCSetIterator iter = touches:begin() +-- cc.SetIterator iter = touches:begin() -- for( iter != touches:end() ++iter) --- local location = ((CCTouch*)(*iter)):getLocation() +-- local location = ((cc.Touch*)(*iter)):getLocation() -- addNewSpriteWithCoords(location) -- end -- end @@ -616,7 +613,7 @@ end function RenderTextureTestMain() cclog("RenderTextureTestMain") Helper.index = 1 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { RenderTextureSave, diff --git a/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua b/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua index 1c43ed7d0c..e196832723 100644 --- a/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua @@ -1,60 +1,60 @@ -local size = CCDirector:getInstance():getWinSize() +local size = cc.Director:getInstance():getWinSize() local function CreateSpriteLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y x = size.width y = size.height - local sprite = CCSprite:create(s_pPathGrossini) - local spriteSister1 = CCSprite:create(s_pPathSister1) - local spriteSister2 = CCSprite:create(s_pPathSister2) + local sprite = cc.Sprite:create(s_pPathGrossini) + local spriteSister1 = cc.Sprite:create(s_pPathSister1) + local spriteSister2 = cc.Sprite:create(s_pPathSister2) sprite:setScale(1.5) spriteSister1:setScale(1.5) spriteSister2:setScale(1.5) - sprite:setPosition(CCPoint(x / 2, y / 2)) - spriteSister1:setPosition(CCPoint(40, y / 2)) - spriteSister2:setPosition(CCPoint(x - 40, y / 2)) + sprite:setPosition(cc.p(x / 2, y / 2)) + spriteSister1:setPosition(cc.p(40, y / 2)) + spriteSister2:setPosition(cc.p(x - 40, y / 2)) layer:addChild(sprite) layer:addChild(spriteSister1) layer:addChild(spriteSister2) - local rot = CCRotateBy:create(16, -3600) + local rot = cc.RotateBy:create(16, -3600) sprite:runAction(rot) - local jump1 = CCJumpBy:create(4, CCPoint(-400, 0), 100, 4) + local jump1 = cc.JumpBy:create(4, cc.p(-400, 0), 100, 4) local jump2 = jump1:reverse() - local rot1 = CCRotateBy:create(4, 360 * 2) + local rot1 = cc.RotateBy:create(4, 360 * 2) local rot2 = rot1:reverse() - local jump3 = CCJumpBy:create(4, CCPoint(-400, 0), 100, 4) + local jump3 = cc.JumpBy:create(4, cc.p(-400, 0), 100, 4) local jump4 = jump3:reverse() - local rot3 = CCRotateBy:create(4, 360 * 2) + local rot3 = cc.RotateBy:create(4, 360 * 2) local rot4 = rot3:reverse() - spriteSister1:runAction(CCRepeat:create(CCSequence:createWithTwoActions(jump2, jump1), 5)) - spriteSister2:runAction(CCRepeat:create(CCSequence:createWithTwoActions(jump3, jump4), 5)) + spriteSister1:runAction(cc.Repeat:create(cc.Sequence:create(jump2, jump1), 5)) + spriteSister2:runAction(cc.Repeat:create(cc.Sequence:create(jump3, jump4), 5)) - spriteSister1:runAction(CCRepeat:create(CCSequence:createWithTwoActions(rot1, rot2), 5)) - spriteSister2:runAction(CCRepeat:create(CCSequence:createWithTwoActions(rot4, rot3), 5)) + spriteSister1:runAction(cc.Repeat:create(cc.Sequence:create(rot1, rot2), 5)) + spriteSister2:runAction(cc.Repeat:create(cc.Sequence:create(rot4, rot3), 5)) return layer end local function CreateTestLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y x = size.width y = size.height - local label = CCLabelTTF:create("cocos2d", "Tahoma", 64) + local label = cc.LabelTTF:create("cocos2d", "Tahoma", 64) label:setPosition(x / 2, y / 2) layer:addChild(label) @@ -62,42 +62,42 @@ local function CreateTestLayer() end local function CreateRotateWorldLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y x = size.width y = size.height - local blue = CCLayerColor:create(Color4B(0,0,255,255)) - local red = CCLayerColor:create(Color4B(255,0,0,255)) - local green = CCLayerColor:create(Color4B(0,255,0,255)) - local white = CCLayerColor:create(Color4B(255,255,255,255)) + local blue = cc.LayerColor:create(cc.c4b(0,0,255,255)) + local red = cc.LayerColor:create(cc.c4b(255,0,0,255)) + local green = cc.LayerColor:create(cc.c4b(0,255,0,255)) + local white = cc.LayerColor:create(cc.c4b(255,255,255,255)) blue:setScale(0.5) - blue:setPosition(CCPoint(- x / 4, - y / 4)) + blue:setPosition(cc.p(- x / 4, - y / 4)) blue:addChild(CreateSpriteLayer()) red:setScale(0.5) - red:setPosition(CCPoint(x / 4, - y / 4)) + red:setPosition(cc.p(x / 4, - y / 4)) green:setScale(0.5) - green:setPosition(CCPoint(- x / 4, y / 4)) + green:setPosition(cc.p(- x / 4, y / 4)) green:addChild(CreateTestLayer()) white:setScale(0.5) - white:setPosition(CCPoint(x / 4, y / 4)) + white:setPosition(cc.p(x / 4, y / 4)) white:ignoreAnchorPointForPosition(false) - white:setPosition(CCPoint(x / 4 * 3, y / 4 * 3)) + white:setPosition(cc.p(x / 4 * 3, y / 4 * 3)) layer:addChild(blue, -1) layer:addChild(white) layer:addChild(green) layer:addChild(red) - local rot = CCRotateBy:create(8, 720) - local rot1 = CCRotateBy:create(8, 720) - local rot2 = CCRotateBy:create(8, 720) - local rot3 = CCRotateBy:create(8, 720) + local rot = cc.RotateBy:create(8, 720) + local rot1 = cc.RotateBy:create(8, 720) + local rot2 = cc.RotateBy:create(8, 720) + local rot3 = cc.RotateBy:create(8, 720) blue:runAction(rot) red:runAction(rot1) @@ -112,12 +112,12 @@ end -------------------------------- function RotateWorldTest() cclog("RotateWorldTest") - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = CreateRotateWorldLayer() scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - scene:runAction(CCRotateBy:create(4, -360)) + scene:runAction(cc.RotateBy:create(4, -360)) return scene end diff --git a/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua index 0212a1a90f..6621cc1797 100644 --- a/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua @@ -16,22 +16,22 @@ local SceneTestLayer3 = nil -------------------------------------------------------------------- SceneTestLayer1 = function() - local ret = CCLayer:create() + local ret = cc.Layer:create() local function onPushScene(tag, pSender) - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer2() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene( scene ) + cc.Director:getInstance():pushScene( scene ) end local function onPushSceneTran(tag, pSender) - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer2() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene( CCTransitionSlideInT:create(1, scene) ) + cc.Director:getInstance():pushScene( cc.TransitionSlideInT:create(1, scene) ) end @@ -39,28 +39,24 @@ SceneTestLayer1 = function() cclog("onQuit") end - local item1 = CCMenuItemFont:create( "Test pushScene") + local item1 = cc.MenuItemFont:create( "Test pushScene") item1:registerScriptTapHandler(onPushScene) - local item2 = CCMenuItemFont:create( "Test pushScene w/transition") + local item2 = cc.MenuItemFont:create( "Test pushScene w/transition") item2:registerScriptTapHandler(onPushSceneTran) - local item3 = CCMenuItemFont:create( "Quit") + local item3 = cc.MenuItemFont:create( "Quit") item3:registerScriptTapHandler(onQuit) - local arr = CCArray:create() - arr:addObject(item1) - arr:addObject(item2) - arr:addObject(item3) - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item1, item2, item3) menu:alignItemsVertically() ret:addChild( menu ) - local s = CCDirector:getInstance():getWinSize() - local sprite = CCSprite:create(s_pPathGrossini) + local s = cc.Director:getInstance():getWinSize() + local sprite = cc.Sprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( CCPoint(s.width-40, s.height/2) ) - local rotate = CCRotateBy:create(2, 360) - local repeatAction = CCRepeatForever:create(rotate) + sprite:setPosition( cc.p(s.width-40, s.height/2) ) + local rotate = cc.RotateBy:create(2, 360) + local repeatAction = cc.RepeatForever:create(rotate) sprite:runAction(repeatAction) local function onNodeEvent(event) @@ -82,51 +78,47 @@ end -------------------------------------------------------------------- SceneTestLayer2 = function() - local ret = CCLayer:create() + local ret = cc.Layer:create() local m_timeCounter = 0 local function onGoBack(tag, pSender) - CCDirector:getInstance():popScene() + cc.Director:getInstance():popScene() end local function onReplaceScene(tag, pSender) - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer3() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene( scene ) + cc.Director:getInstance():replaceScene( scene ) end local function onReplaceSceneTran(tag, pSender) - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer3() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene( CCTransitionFlipX:create(2, scene) ) + cc.Director:getInstance():replaceScene( cc.TransitionFlipX:create(2, scene) ) end - local item1 = CCMenuItemFont:create( "replaceScene") + local item1 = cc.MenuItemFont:create( "replaceScene") item1:registerScriptTapHandler(onReplaceScene) - local item2 = CCMenuItemFont:create( "replaceScene w/transition") + local item2 = cc.MenuItemFont:create( "replaceScene w/transition") item2:registerScriptTapHandler(onReplaceSceneTran) - local item3 = CCMenuItemFont:create( "Go Back") + local item3 = cc.MenuItemFont:create( "Go Back") item3:registerScriptTapHandler(onGoBack) - local arr = CCArray:create() - arr:addObject(item1) - arr:addObject(item2) - arr:addObject(item3) - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item1, item2, item3) menu:alignItemsVertically() ret:addChild( menu ) - local s = CCDirector:getInstance():getWinSize() - local sprite = CCSprite:create(s_pPathGrossini) + local s = cc.Director:getInstance():getWinSize() + local sprite = cc.Sprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( CCPoint(s.width-40, s.height/2) ) - local rotate = CCRotateBy:create(2, 360) - local repeat_action = CCRepeatForever:create(rotate) + sprite:setPosition( cc.p(s.width-40, s.height/2) ) + local rotate = cc.RotateBy:create(2, 360) + local repeat_action = cc.RepeatForever:create(rotate) sprite:runAction(repeat_action) return ret @@ -139,44 +131,39 @@ end -------------------------------------------------------------------- SceneTestLayer3 = function() - local ret = CCLayerColor:create(Color4B(0,0,255,255)) - local s = CCDirector:getInstance():getWinSize() + local ret = cc.LayerColor:create(cc.c4b(0,0,255,255)) + local s = cc.Director:getInstance():getWinSize() local function item0Clicked(tag, pSender) - local newScene = CCScene:create() + local newScene = cc.Scene:create() newScene:addChild(SceneTestLayer3()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, newScene, Color3B(0,255,255))) + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, newScene, cc.c3b(0,255,255))) end local function item1Clicked(tag, pSender) - CCDirector:getInstance():popScene() + cc.Director:getInstance():popScene() end local function item2Clicked(tag, pSender) - CCDirector:getInstance():popToRootScene() + cc.Director:getInstance():popToRootScene() end - local item0 = CCMenuItemFont:create("Touch to pushScene (self)") + local item0 = cc.MenuItemFont:create("Touch to pushScene (self)") item0:registerScriptTapHandler(item0Clicked) - local item1 = CCMenuItemFont:create("Touch to popScene") + local item1 = cc.MenuItemFont:create("Touch to popScene") item1:registerScriptTapHandler(item1Clicked) - local item2 = CCMenuItemFont:create("Touch to popToRootScene") + local item2 = cc.MenuItemFont:create("Touch to popToRootScene") item2:registerScriptTapHandler(item2Clicked) - local arr = CCArray:create() - arr:addObject(item0) - arr:addObject(item1) - arr:addObject(item2) - - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item0, item1, item2) ret:addChild(menu) menu:alignItemsVertically() - local sprite = CCSprite:create(s_pPathGrossini) + local sprite = cc.Sprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( CCPoint(s.width/2, 40) ) - local rotate = CCRotateBy:create(2, 360) - local repeatAction = CCRepeatForever:create(rotate) + sprite:setPosition( cc.p(s.width/2, 40) ) + local rotate = cc.RotateBy:create(2, 360) + local repeatAction = cc.RepeatForever:create(rotate) sprite:runAction(repeatAction) return ret end @@ -185,7 +172,7 @@ end function SceneTestMain() cclog("SceneTestMain") - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer1() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua b/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua index 7ec8dd09a9..c6e9c6dd7b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua @@ -1,4 +1,4 @@ -local size = CCDirector:getInstance():getWinSize() +local size = cc.Director:getInstance():getWinSize() local kTagTileMap = 1 local kTagSpriteBatchNode = 1 local kTagNode = 2 @@ -29,46 +29,46 @@ function Sprite1.addNewSpriteWithCoords(layer, point) local x = math.floor(math.mod(idx,5) * 85) local y = math.floor(idx / 5 * 121) - local sprite = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(x,y,85,121) ) + local sprite = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(x,y,85,121) ) layer:addChild( sprite ) - sprite:setPosition( CCPoint(point.x, point.y) ) + sprite:setPosition( cc.p(point.x, point.y) ) local action = nil local random = math.random() cclog("random = " .. random) if( random < 0.20 ) then - action = CCScaleBy:create(3, 2) + action = cc.ScaleBy:create(3, 2) elseif(random < 0.40) then - action = CCRotateBy:create(3, 360) + action = cc.RotateBy:create(3, 360) elseif( random < 0.60) then - action = CCBlink:create(1, 3) + action = cc.Blink:create(1, 3) elseif( random < 0.8 ) then - action = CCTintBy:create(2, 0, -255, -255) + action = cc.TintBy:create(2, 0, -255, -255) else - action = CCFadeOut:create(2) + action = cc.FadeOut:create(2) end local action_back = action:reverse() - local seq = CCSequence:createWithTwoActions( action, action_back) + local seq = cc.Sequence:create( action, action_back) - sprite:runAction( CCRepeatForever:create(seq) ) + sprite:runAction( cc.RepeatForever:create(seq) ) end function Sprite1.onTouch(event, x, y) if event == "began" then return true elseif event == "ended" then - Sprite1.addNewSpriteWithCoords(Helper.currentLayer, CCPoint(x,y)) + Sprite1.addNewSpriteWithCoords(Helper.currentLayer, cc.p(x,y)) return true end end function Sprite1.create() cclog("sprite1") - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - Sprite1.addNewSpriteWithCoords(layer, CCPoint(size.width/2, size.height/2)) + Sprite1.addNewSpriteWithCoords(layer, cc.p(size.width/2, size.height/2)) layer:setTouchEnabled(true) layer:registerScriptTouchHandler(Sprite1.onTouch) @@ -89,48 +89,48 @@ function SpriteBatchNode1.addNewSpriteWithCoords(layer, point) local x = math.floor(math.mod(idx,5) * 85) local y = math.floor(idx / 5 * 121) - local sprite = CCSprite:createWithTexture(BatchNode:getTexture(), CCRect(x,y,85,121) ) + local sprite = cc.Sprite:createWithTexture(BatchNode:getTexture(), cc.rect(x,y,85,121) ) layer:addChild( sprite ) - sprite:setPosition( CCPoint(point.x, point.y) ) + sprite:setPosition( cc.p(point.x, point.y) ) local action = nil local random = math.random() cclog("random = " .. random) if( random < 0.20 ) then - action = CCScaleBy:create(3, 2) + action = cc.ScaleBy:create(3, 2) elseif(random < 0.40) then - action = CCRotateBy:create(3, 360) + action = cc.RotateBy:create(3, 360) elseif( random < 0.60) then - action = CCBlink:create(1, 3) + action = cc.Blink:create(1, 3) elseif( random < 0.8 ) then - action = CCTintBy:create(2, 0, -255, -255) + action = cc.TintBy:create(2, 0, -255, -255) else - action = CCFadeOut:create(2) + action = cc.FadeOut:create(2) end local action_back = action:reverse() - local seq = CCSequence:createWithTwoActions( action, action_back) + local seq = cc.Sequence:create( action, action_back) - sprite:runAction( CCRepeatForever:create(seq) ) + sprite:runAction( cc.RepeatForever:create(seq) ) end function SpriteBatchNode1.onTouch(event, x, y) if event == "began" then return true elseif event == "ended" then - SpriteBatchNode1.addNewSpriteWithCoords(Helper.currentLayer, CCPoint(x,y)) + SpriteBatchNode1.addNewSpriteWithCoords(Helper.currentLayer, cc.p(x,y)) return true end end function SpriteBatchNode1.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local BatchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 50) + local BatchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 50) layer:addChild(BatchNode, 0, kTagSpriteBatchNode) - SpriteBatchNode1.addNewSpriteWithCoords(layer, CCPoint(size.width/2, size.height/2)) + SpriteBatchNode1.addNewSpriteWithCoords(layer, cc.p(size.width/2, size.height/2)) layer:setTouchEnabled(true) layer:registerScriptTouchHandler(SpriteBatchNode1.onTouch) @@ -148,41 +148,41 @@ SpriteColorOpacity.__index = SpriteColorOpacity SpriteColorOpacity.entry = nil function SpriteColorOpacity.setLayerSprite(layer) - local sprite1 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*0, 121*1, 85, 121)) - local sprite2 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*1, 121*1, 85, 121)) - local sprite3 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*2, 121*1, 85, 121)) - local sprite4 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*3, 121*1, 85, 121)) + local sprite1 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*0, 121*1, 85, 121)) + local sprite2 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*1, 121*1, 85, 121)) + local sprite3 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*2, 121*1, 85, 121)) + local sprite4 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*3, 121*1, 85, 121)) - local sprite5 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*0, 121*1, 85, 121)) - local sprite6 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*1, 121*1, 85, 121)) - local sprite7 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*2, 121*1, 85, 121)) - local sprite8 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*3, 121*1, 85, 121)) + local sprite5 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*0, 121*1, 85, 121)) + local sprite6 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*1, 121*1, 85, 121)) + local sprite7 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*2, 121*1, 85, 121)) + local sprite8 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*3, 121*1, 85, 121)) - local s = CCDirector:getInstance():getWinSize() - sprite1:setPosition( CCPoint( (s.width/5)*1, (s.height/3)*1) ) - sprite2:setPosition( CCPoint( (s.width/5)*2, (s.height/3)*1) ) - sprite3:setPosition( CCPoint( (s.width/5)*3, (s.height/3)*1) ) - sprite4:setPosition( CCPoint( (s.width/5)*4, (s.height/3)*1) ) - sprite5:setPosition( CCPoint( (s.width/5)*1, (s.height/3)*2) ) - sprite6:setPosition( CCPoint( (s.width/5)*2, (s.height/3)*2) ) - sprite7:setPosition( CCPoint( (s.width/5)*3, (s.height/3)*2) ) - sprite8:setPosition( CCPoint( (s.width/5)*4, (s.height/3)*2) ) + local s = cc.Director:getInstance():getWinSize() + sprite1:setPosition( cc.p( (s.width/5)*1, (s.height/3)*1) ) + sprite2:setPosition( cc.p( (s.width/5)*2, (s.height/3)*1) ) + sprite3:setPosition( cc.p( (s.width/5)*3, (s.height/3)*1) ) + sprite4:setPosition( cc.p( (s.width/5)*4, (s.height/3)*1) ) + sprite5:setPosition( cc.p( (s.width/5)*1, (s.height/3)*2) ) + sprite6:setPosition( cc.p( (s.width/5)*2, (s.height/3)*2) ) + sprite7:setPosition( cc.p( (s.width/5)*3, (s.height/3)*2) ) + sprite8:setPosition( cc.p( (s.width/5)*4, (s.height/3)*2) ) - local action = CCFadeIn:create(2) + local action = cc.FadeIn:create(2) local action_back = action:reverse() - local fade = CCRepeatForever:create( CCSequence:createWithTwoActions( action, action_back) ) + local fade = cc.RepeatForever:create( cc.Sequence:create( action, action_back) ) - local tintred = CCTintBy:create(2, 0, -255, -255) + local tintred = cc.TintBy:create(2, 0, -255, -255) local tintred_back = tintred:reverse() - local red = CCRepeatForever:create( CCSequence:createWithTwoActions( tintred, tintred_back) ) + local red = cc.RepeatForever:create( cc.Sequence:create( tintred, tintred_back) ) - local tintgreen = CCTintBy:create(2, -255, 0, -255) + local tintgreen = cc.TintBy:create(2, -255, 0, -255) local tintgreen_back = tintgreen:reverse() - local green = CCRepeatForever:create( CCSequence:createWithTwoActions( tintgreen, tintgreen_back) ) + local green = cc.RepeatForever:create( cc.Sequence:create( tintgreen, tintgreen_back) ) - local tintblue = CCTintBy:create(2, -255, -255, 0) + local tintblue = cc.TintBy:create(2, -255, -255, 0) local tintblue_back = tintblue:reverse() - local blue = CCRepeatForever:create( CCSequence:createWithTwoActions( tintblue, tintblue_back) ) + local blue = cc.RepeatForever:create( cc.Sequence:create( tintblue, tintblue_back) ) sprite5:runAction(red) sprite6:runAction(green) @@ -220,7 +220,7 @@ function SpriteColorOpacity.removeAndAddSprite(dt) end function SpriteColorOpacity.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) SpriteColorOpacity.setLayerSprite(layer) layer:registerScriptHandler(SpriteColorOpacity.onEnterOrExit) @@ -240,51 +240,56 @@ SpriteFrameTest.m_pSprite2 = nil SpriteFrameTest.m_nCounter = 0 function SpriteFrameTest.onEnter() - local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() + local s = cc.Director:getInstance():getWinSize() + local cache = cc.SpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") - cache:addSpriteFramesWithFile("animations/grossini_blue.plist", "animations/grossini_blue.png") + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") + cache:addSpriteFrames("animations/grossini_blue.plist", "animations/grossini_blue.png") - SpriteFrameTest.m_pSprite1 = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - SpriteFrameTest.m_pSprite1:setPosition( CCPoint( s.width/2-80, s.height/2) ) + SpriteFrameTest.m_pSprite1 = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + SpriteFrameTest.m_pSprite1:setPosition( cc.p( s.width/2-80, s.height/2) ) - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") spritebatch:addChild(SpriteFrameTest.m_pSprite1) Helper.currentLayer:addChild(spritebatch) - local animFrames = CCArray:createWithCapacity(15) + local animFrames = {} for i = 1,14 do - local frame = cache:getSpriteFrameByName( string.format("grossini_dance_%02d.png", i) ) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame( string.format("grossini_dance_%02d.png", i) ) + animFrames[i] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - SpriteFrameTest.m_pSprite1:runAction( CCRepeatForever:create( CCAnimate:create(animation) ) ) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + SpriteFrameTest.m_pSprite1:runAction( cc.RepeatForever:create( cc.Animate:create(animation) ) ) SpriteFrameTest.m_pSprite1:setFlipX(false) SpriteFrameTest.m_pSprite1:setFlipY(false) - SpriteFrameTest.m_pSprite2 = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - SpriteFrameTest.m_pSprite2:setPosition( CCPoint( s.width/2 + 80, s.height/2) ) + SpriteFrameTest.m_pSprite2 = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + SpriteFrameTest.m_pSprite2:setPosition( cc.p( s.width/2 + 80, s.height/2) ) Helper.currentLayer:addChild(SpriteFrameTest.m_pSprite2) - local moreFrames = CCArray:createWithCapacity(20) + local moreFrames = {} for i = 1,14 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_gray_%02d.png",i)) - moreFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_gray_%02d.png",i)) + moreFrames[i] = frame end for i = 1,4 do - local frame = cache:getSpriteFrameByName(string.format("grossini_blue_%02d.png",i)) - moreFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_blue_%02d.png",i)) + moreFrames[14 + i] = frame end - moreFrames:addObjectsFromArray(animFrames) - local animMixed = CCAnimation:createWithSpriteFrames(moreFrames, 0.3) + --contact + for i = 1, 14 do + moreFrames[18 + i] = animFrames[i] + end - SpriteFrameTest.m_pSprite2:runAction(CCRepeatForever:create( CCAnimate:create(animMixed) ) ) + + local animMixed = cc.Animation:createWithSpriteFrames(moreFrames, 0.3) + + SpriteFrameTest.m_pSprite2:runAction(cc.RepeatForever:create( cc.Animate:create(animMixed) ) ) SpriteFrameTest.m_pSprite2:setFlipX(false) SpriteFrameTest.m_pSprite2:setFlipY(false) @@ -295,7 +300,7 @@ function SpriteFrameTest.onEnter() end function SpriteFrameTest.onExit() - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") cache:removeSpriteFramesFromFile("animations/grossini_blue.plist") @@ -342,7 +347,7 @@ function SpriteFrameTest.onEnterOrExit(tag) end function SpriteFrameTest.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer:registerScriptHandler(SpriteFrameTest.onEnterOrExit) @@ -360,33 +365,33 @@ local SpriteFrameAliasNameTest = {} SpriteFrameAliasNameTest.__index = SpriteFrameAliasNameTest function SpriteFrameAliasNameTest.onEnter() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini-aliases.plist", "animations/grossini-aliases.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini-aliases.plist", "animations/grossini-aliases.png") - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width * 0.5, s.height * 0.5)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width * 0.5, s.height * 0.5)) - local spriteBatch = CCSpriteBatchNode:create("animations/grossini-aliases.png") + local spriteBatch = cc.SpriteBatchNode:create("animations/grossini-aliases.png") cclog("spriteBatch = " .. tostring(tolua.isnull(spriteBatch))) cclog("sprite = " .. tostring(tolua.isnull(sprite))) spriteBatch:addChild(sprite) Helper.currentLayer:addChild(spriteBatch) - local animFrames = CCArray:createWithCapacity(15) + local animFrames = {} for i = 1,14 do - local frame = cache:getSpriteFrameByName(string.format("dance_%02d", i)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("dance_%02d", i)) + animFrames[i] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) -- 14 frames * 1sec = 14 seconds - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) end function SpriteFrameAliasNameTest.onExit() - CCSpriteFrameCache:getInstance():removeSpriteFramesFromFile("animations/grossini-aliases.plist") + cc.SpriteFrameCache:getInstance():removeSpriteFramesFromFile("animations/grossini-aliases.plist") end function SpriteFrameAliasNameTest.onEnterOrExit(tag) @@ -398,7 +403,7 @@ function SpriteFrameAliasNameTest.onEnterOrExit(tag) end function SpriteFrameAliasNameTest.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer:registerScriptHandler(SpriteFrameAliasNameTest.onEnterOrExit) @@ -417,30 +422,30 @@ local SpriteAnchorPoint = {} SpriteAnchorPoint.__index = SpriteAnchorPoint function SpriteAnchorPoint.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local rotate = CCRotateBy:create(10, 360) - local action = CCRepeatForever:create(rotate) + local rotate = cc.RotateBy:create(10, 360) + local action = cc.RepeatForever:create(rotate) for i = 0, 2 do - local sprite = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*i, 121*1, 85, 121) ) - sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) + local sprite = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*i, 121*1, 85, 121) ) + sprite:setPosition( cc.p( s.width/4*(i+1), s.height/2) ) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) point:setPosition( sprite:getPosition() ) layer:addChild(point, 10) if i == 0 then - sprite:setAnchorPoint( CCPoint(0, 0) ) + sprite:setAnchorPoint( cc.p(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end point:setPosition( sprite:getPosition() ) - local copy = tolua.cast(action:clone(), "CCAction") + local copy = tolua.cast(action:clone(), "Action") sprite:runAction(copy) layer:addChild(sprite, i) end @@ -449,7 +454,7 @@ function SpriteAnchorPoint.initLayer(layer) end function SpriteAnchorPoint.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer = SpriteAnchorPoint.initLayer(layer) @@ -467,33 +472,33 @@ SpriteBatchNodeAnchorPoint.__index = SpriteBatchNodeAnchorPoint function SpriteBatchNodeAnchorPoint.initLayer(layer) -- small capacity. Testing resizing. -- Don't use capacity=1 in your real game. It is expensive to resize the capacity - local batch = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 1) + local batch = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 1) layer:addChild(batch, 0, kTagSpriteBatchNode) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local rotate = CCRotateBy:create(10, 360) - local action = CCRepeatForever:create(rotate) + local rotate = cc.RotateBy:create(10, 360) + local action = cc.RepeatForever:create(rotate) for i=0,2 do - local sprite = CCSprite:createWithTexture(batch:getTexture(), CCRect(85*i, 121*1, 85, 121)) - sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) + local sprite = cc.Sprite:createWithTexture(batch:getTexture(), cc.rect(85*i, 121*1, 85, 121)) + sprite:setPosition( cc.p( s.width/4*(i+1), s.height/2) ) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( CCPoint(0,0) ) + sprite:setAnchorPoint( cc.p(0,0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) - local copy = tolua.cast(action:clone(), "CCAction") + local copy = tolua.cast(action:clone(), "Action") sprite:runAction(copy) batch:addChild(sprite, i) end @@ -502,7 +507,7 @@ function SpriteBatchNodeAnchorPoint.initLayer(layer) end function SpriteBatchNodeAnchorPoint.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer = SpriteBatchNodeAnchorPoint.initLayer(layer) @@ -521,43 +526,43 @@ local SpriteOffsetAnchorRotation = {} SpriteOffsetAnchorRotation.__index = SpriteOffsetAnchorRotation function SpriteOffsetAnchorRotation.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local s = cc.Director:getInstance():getWinSize() + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i=0,2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint( s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p( s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) point:setPosition( sprite:getPosition() ) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( CCPoint(0, 0) ) + sprite:setAnchorPoint( cc.p(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) - local animFrames = CCArray:createWithCapacity(14) + local animFrames = {} for i = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(i+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png",(i+1))) + animFrames[i + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create( CCAnimate:create(animation) ) ) - sprite:runAction(CCRepeatForever:create(CCRotateBy:create(10, 360) ) ) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create( cc.Animate:create(animation) ) ) + sprite:runAction(cc.RepeatForever:create(cc.RotateBy:create(10, 360) ) ) layer:addChild(sprite, 0) end @@ -567,14 +572,14 @@ end function SpriteOffsetAnchorRotation.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorRotation.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorRotation.eventHandler) Helper.initWithLayer(layer) @@ -595,13 +600,13 @@ SpriteBatchNodeOffsetAnchorRotation.__index = SpriteBatchNodeOffsetAnchorRotatio function SpriteBatchNodeOffsetAnchorRotation.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") cclog("1") layer:addChild(spritebatch) @@ -610,33 +615,33 @@ function SpriteBatchNodeOffsetAnchorRotation.initLayer(layer) -- -- Animation using Sprite BatchNode -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition( cc.p( s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint( CCPoint(0,0) ) + sprite:setAnchorPoint( cc.p(0,0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) - local animFrames = CCArray:createWithCapacity(14) + local animFrames = {} for k = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(k+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png",(k+1))) + animFrames[k + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create( CCAnimate:create(animation) )) - sprite:runAction(CCRepeatForever:create(CCRotateBy:create(10, 360) )) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create( cc.Animate:create(animation) )) + sprite:runAction(cc.RepeatForever:create(cc.RotateBy:create(10, 360) )) spritebatch:addChild(sprite, i) end @@ -645,14 +650,14 @@ end function SpriteBatchNodeOffsetAnchorRotation.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorRotation.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorRotation.eventHandler) Helper.initWithLayer(layer) @@ -672,48 +677,48 @@ local SpriteOffsetAnchorScale = {} SpriteOffsetAnchorScale.__index = SpriteOffsetAnchorScale function SpriteOffsetAnchorScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0,2 do -- -- Animation using Sprite BatchNode -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition( cc.p( s.width/4*(i+1), s.height/2) ) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) point:setPosition( sprite:getPosition() ) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( CCPoint(0, 0) ) + sprite:setAnchorPoint( cc.p(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) - local animFrames = CCArray:createWithCapacity(14) + local animFrames = {} for i = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(i+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png",(i+1))) + animFrames[i + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create( CCAnimate:create(animation) )) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create( cc.Animate:create(animation) )) - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) layer:addChild(sprite, 0) end @@ -723,14 +728,14 @@ end function SpriteOffsetAnchorScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorScale.eventHandler) Helper.initWithLayer(layer) @@ -749,50 +754,50 @@ end local SpriteBatchNodeOffsetAnchorScale = {} function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritesheet = CCSpriteBatchNode:create("animations/grossini.png") + local spritesheet = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritesheet) for i = 0,2 do -- Animation using Sprite BatchNode - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0,0)) + sprite:setAnchorPoint(cc.p(0,0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:createWithCapacity(14) + local animFrames = {} local str for k = 0, 13 do str = string.format("grossini_dance_%02d.png", (k+1)) - local frame = cache:getSpriteFrameByName(str) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(str) + animFrames[k + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) spritesheet:addChild(sprite, i) end @@ -801,7 +806,7 @@ function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) end function SpriteBatchNodeOffsetAnchorScale.onExit() - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -813,7 +818,7 @@ function SpriteBatchNodeOffsetAnchorScale.eventHandler(tag) end function SpriteBatchNodeOffsetAnchorScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorScale.eventHandler) @@ -834,55 +839,50 @@ SpriteOffsetAnchorSkew.__index = SpriteOffsetAnchorSkew function SpriteOffsetAnchorSkew.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j + 1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j + 1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local actionArray = CCArray:create() - local skewX = CCSkewBy:create(2, 45, 0) - actionArray:addObject(skewX) + local skewX = cc.SkewBy:create(2, 45, 0) local skewX_back = skewX:reverse() - actionArray:addObject(skewX_back) - local skewY = CCSkewBy:create(2, 0, 45) - actionArray:addObject(skewY) + local skewY = cc.SkewBy:create(2, 0, 45) local skewY_back = skewY:reverse() - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) layer:addChild(sprite, 0) end @@ -892,14 +892,14 @@ end function SpriteOffsetAnchorSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorSkew.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorSkew.eventHandler) Helper.initWithLayer(layer) @@ -917,55 +917,50 @@ SpriteOffsetAnchorRotationalSkew.__index = SpriteOffsetAnchorRotationalSkew function SpriteOffsetAnchorRotationalSkew.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0,0)) + sprite:setAnchorPoint(cc.p(0,0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1,1)) + sprite:setAnchorPoint(cc.p(1,1)) end - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) - local animFrames = CCArray:create() + local animFrames = {} for i = 0,13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (i+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", (i+1))) + animFrames[i + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local actionArray = CCArray:create() - local skewX = CCRotateBy:create(2, 45) - actionArray:addObject(skewX) + local skewX = cc.RotateBy:create(2, 45) local skewX_back = skewX:reverse() - actionArray:addObject(skewX_back) - local skewY = CCRotateBy:create(2, -45) - actionArray:addObject(skewY) + local skewY = cc.RotateBy:create(2, -45) local skewY_back = skewY:reverse() - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) layer:addChild(sprite, 0) end @@ -974,14 +969,14 @@ end function SpriteOffsetAnchorRotationalSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorRotationalSkew.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorRotationalSkew.eventHandler) Helper.initWithLayer(layer) @@ -1001,58 +996,53 @@ SpriteBatchNodeOffsetAnchorSkew.__index = SpriteBatchNodeOffsetAnchorSkew function SpriteBatchNodeOffsetAnchorSkew.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritebatch) for i = 0, 2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j + 1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j + 1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local actionArray = CCArray:create() - local skewX = CCSkewBy:create(2, 45, 0) - actionArray:addObject(skewX) + local skewX = cc.SkewBy:create(2, 45, 0) local skewX_back = skewX:reverse() - actionArray:addObject(skewX_back) - local skewY = CCSkewBy:create(2, 0, 45) - actionArray:addObject(skewY) + local skewY = cc.SkewBy:create(2, 0, 45) local skewY_back = skewY:reverse() - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) spritebatch:addChild(sprite, i) end @@ -1062,14 +1052,14 @@ end function SpriteBatchNodeOffsetAnchorSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorSkew.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorSkew.eventHandler) Helper.initWithLayer(layer) @@ -1088,59 +1078,54 @@ SpriteBatchNodeOffsetAnchorRotationalSkew.__index = SpriteBatchNodeOffsetAnchorR function SpriteBatchNodeOffsetAnchorRotationalSkew.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritebatch) for i = 0, 2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0,0)) + sprite:setAnchorPoint(cc.p(0,0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1,1)) + sprite:setAnchorPoint(cc.p(1,1)) end - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", (j+1))) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local actionArray = CCArray:create() - local skewX = CCRotateBy:create(2, 45) - actionArray:addObject(skewX) + local skewX = cc.RotateBy:create(2, 45) local skewX_back = skewX:reverse() - actionArray:addObject(skewX_back) - local skewY = CCRotateBy:create(2, -45) - actionArray:addObject(skewY) + local skewY = cc.RotateBy:create(2, -45) local skewY_back = skewY:reverse() - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) spritebatch:addChild(sprite, i) end @@ -1151,14 +1136,14 @@ end -- remove resources function SpriteBatchNodeOffsetAnchorRotationalSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorRotationalSkew.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorRotationalSkew.eventHandler) Helper.initWithLayer(layer) @@ -1175,60 +1160,55 @@ end local SpriteOffsetAnchorSkewScale = {} function SpriteOffsetAnchorSkewScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0,0)) + sprite:setAnchorPoint(cc.p(0,0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j+1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) -- Skew - local skewX = CCSkewBy:create(2, 45, 0) + local skewX = cc.SkewBy:create(2, 45, 0) local skewX_back = skewX:reverse() - local skewY = CCSkewBy:create(2, 0, 45) + local skewY = cc.SkewBy:create(2, 0, 45) local skewY_back = skewY:reverse() - local actionArray = CCArray:create() - actionArray:addObject(skewX) - actionArray:addObject(skewX_back) - actionArray:addObject(skewY) - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) -- Scale - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) layer:addChild(sprite, 0) end @@ -1238,14 +1218,14 @@ end function SpriteOffsetAnchorSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorSkewScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorSkewScale.eventHandler) Helper.initWithLayer(layer) @@ -1261,60 +1241,55 @@ end local SpriteOffsetAnchorRotationalSkewScale = {} function SpriteOffsetAnchorRotationalSkewScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", (j+1))) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) -- Skew - local skewX = CCRotateBy:create(2, 45, 0) + local skewX = cc.RotateBy:create(2, 45, 0) local skewX_back = skewX:reverse() - local skewY = CCRotateBy:create(2, 0, 45) + local skewY = cc.RotateBy:create(2, 0, 45) local skewY_back = skewY:reverse() - local actionArray = CCArray:create() - actionArray:addObject(skewX) - actionArray:addObject(skewX_back) - actionArray:addObject(skewY) - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) -- Scale - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) layer:addChild(sprite, i) end @@ -1324,14 +1299,14 @@ end function SpriteOffsetAnchorRotationalSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorRotationalSkewScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorRotationalSkewScale.eventHandler) Helper.initWithLayer(layer) @@ -1347,65 +1322,60 @@ end local SpriteBatchNodeOffsetAnchorSkewScale = {} function SpriteBatchNodeOffsetAnchorSkewScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritebatch) for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", (j+1))) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) -- skew - local skewX = CCSkewBy:create(2, 45, 0) + local skewX = cc.SkewBy:create(2, 45, 0) local skewX_back = skewX:reverse() - local skewY = CCSkewBy:create(2, 0, 45) + local skewY = cc.SkewBy:create(2, 0, 45) local skewY_back = skewY:reverse() - local actionArray = CCArray:create() - actionArray:addObject(skewX) - actionArray:addObject(skewX_back) - actionArray:addObject(skewY) - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) -- scale - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) spritebatch:addChild(sprite, i) end @@ -1413,14 +1383,14 @@ end function SpriteBatchNodeOffsetAnchorSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorSkewScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorSkewScale.eventHandler) Helper.initWithLayer(layer) @@ -1435,21 +1405,21 @@ end -- local SpriteBatchNodeOffsetAnchorRotationalSkewScale = {} function SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritebatch) for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) @@ -1457,42 +1427,37 @@ function SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j+1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) -- Skew - local skewX = CCRotateBy:create(2, 45, 0) + local skewX = cc.RotateBy:create(2, 45, 0) local skewX_back = skewX:reverse() - local skewY = CCRotateBy:create(2, 0, 45) + local skewY = cc.RotateBy:create(2, 0, 45) local skewY_back = skewY:reverse() - local actionArray = CCArray:create() - actionArray:addObject(skewX) - actionArray:addObject(skewX_back) - actionArray:addObject(skewY) - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) -- Scale - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) spritebatch:addChild(sprite, i) end @@ -1500,14 +1465,14 @@ end function SpriteBatchNodeOffsetAnchorRotationalSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorRotationalSkewScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorRotationalSkewScale.eventHandler) Helper.initWithLayer(layer) SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) @@ -1522,53 +1487,48 @@ end -- local SpriteOffsetAnchorFlip = {} function SpriteOffsetAnchorFlip.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j+1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local flip = CCFlipY:create(true) - local flip_back = CCFlipY:create(false) - local delay = CCDelayTime:create(1) - local delay2 = CCDelayTime:create(1) + local flip = cc.FlipY:create(true) + local flip_back = cc.FlipY:create(false) + local delay = cc.DelayTime:create(1) + local delay2 = cc.DelayTime:create(1) - local actionArray = CCArray:create() - actionArray:addObject(delay) - actionArray:addObject(flip) - actionArray:addObject(delay2) - actionArray:addObject(flip_back) - local seq = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(delay, flip, delay2, flip_back) + sprite:runAction(cc.RepeatForever:create(seq)) layer:addChild(sprite, 0) end @@ -1576,14 +1536,14 @@ end function SpriteOffsetAnchorFlip.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorFlip.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorFlip.eventHandler) Helper.initWithLayer(layer) @@ -1596,7 +1556,7 @@ end function SpriteTest() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { Sprite1.create, diff --git a/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua b/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua index 40c2dcf0b3..ec191438b1 100644 --- a/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua @@ -1,4 +1,4 @@ -local scheduler = CCDirector:getInstance():getScheduler() +local scheduler = cc.Director:getInstance():getScheduler() local kTagLabel = 1 local kTagSprite1 = 2 local kTagSprite2 = 3 @@ -7,10 +7,10 @@ local originCreateLayer = createTestLayer local function createTestLayer(title, subtitle) local ret = originCreateLayer(title, subtitle) Helper.titleLabel:setTag(kTagLabel) - CCTextureCache:getInstance():dumpCachedTextureInfo() - local col = CCLayerColor:create(Color4B(128,128,128,255)) + cc.TextureCache:getInstance():dumpCachedTextureInfo() + local col = cc.LayerColor:create(cc.c4b(128,128,128,255)) ret:addChild(col, -10) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end -------------------------------------------------------------------- @@ -21,12 +21,12 @@ end local function TextureTIFF() local ret = createTestLayer("TIFF Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.tiff") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.tiff") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -38,12 +38,12 @@ end local function TexturePNG() local ret = createTestLayer("PNG Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.png") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.png") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -54,12 +54,12 @@ end -------------------------------------------------------------------- local function TextureJPEG() local ret = createTestLayer("JPEG Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.jpeg") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.jpeg") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -70,12 +70,12 @@ end -------------------------------------------------------------------- local function TextureWEBP() local ret = createTestLayer("WEBP Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.webp") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.webp") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -87,47 +87,35 @@ end local function TextureMipMap() local ret = createTestLayer("Texture Mipmap", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local texture0 = CCTextureCache:getInstance():addImage( + local texture0 = cc.TextureCache:getInstance():addImage( "Images/grossini_dance_atlas.png") texture0:generateMipmap() - local texParams = CCTexture:TexParams() - texParams.minFilter = GL_LINEAR_MIPMAP_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_CLAMP_TO_EDGE - texParams.wrapT = GL_CLAMP_TO_EDGE - texture0:setTexParameters(texParams) + texture0:setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE) - local texture1 = CCTextureCache:getInstance():addImage( + local texture1 = cc.TextureCache:getInstance():addImage( "Images/grossini_dance_atlas_nomipmap.png") - local img0 = CCSprite:createWithTexture(texture0) - img0:setTextureRect(CCRect(85, 121, 85, 121)) - img0:setPosition(CCPoint( s.width/3.0, s.height/2.0)) + local img0 = cc.Sprite:createWithTexture(texture0) + img0:setTextureRect(cc.rect(85, 121, 85, 121)) + img0:setPosition(cc.p( s.width/3.0, s.height/2.0)) ret:addChild(img0) - local img1 = CCSprite:createWithTexture(texture1) - img1:setTextureRect(CCRect(85, 121, 85, 121)) - img1:setPosition(CCPoint( 2*s.width/3.0, s.height/2.0)) + local img1 = cc.Sprite:createWithTexture(texture1) + img1:setTextureRect(cc.rect(85, 121, 85, 121)) + img1:setPosition(cc.p( 2*s.width/3.0, s.height/2.0)) ret:addChild(img1) - local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) + local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "CCEaseOut") + local scale2 = tolua.cast(scale1:clone(), "EaseOut") local sc_back2 = scale2:reverse() - local arr = CCArray:create() - arr:addObject(scale1) - arr:addObject(sc_back) - img0:runAction(CCRepeatForever:create(CCSequence:create(arr))) - - arr = CCArray:create() - arr:addObject(scale2) - arr:addObject(sc_back2) - img1:runAction(CCRepeatForever:create(CCSequence:create(arr))) - CCTextureCache:getInstance():dumpCachedTextureInfo() + img0:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) + img1:runAction(cc.RepeatForever:create(cc.Sequence:create(scale2, sc_back2))) + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -140,47 +128,33 @@ end -------------------------------------------------------------------- local function TexturePVRMipMap() local ret = createTestLayer("PVRTC MipMap Test", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local imgMipMap = CCSprite:create("Images/logo-mipmap.pvr") + local imgMipMap = cc.Sprite:create("Images/logo-mipmap.pvr") if imgMipMap ~= nil then - imgMipMap:setPosition(CCPoint( s.width/2.0-100, s.height/2.0)) + imgMipMap:setPosition(cc.p( s.width/2.0-100, s.height/2.0)) ret:addChild(imgMipMap) -- support mipmap filtering - local texParams = CCTexture:TexParams() - texParams.minFilter = GL_LINEAR_MIPMAP_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_CLAMP_TO_EDGE - texParams.wrapT = GL_CLAMP_TO_EDGE - - imgMipMap:getTexture():setTexParameters(texParams) + imgMipMap:getTexture():setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE) end - local img = CCSprite:create("Images/logo-nomipmap.pvr") + local img = cc.Sprite:create("Images/logo-nomipmap.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0+100, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0+100, s.height/2.0)) ret:addChild(img) - local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) + local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "CCEaseOut") + local scale2 = tolua.cast(scale1:clone(), "EaseOut") local sc_back2 = scale2:reverse() - local arr = CCArray:create() - arr:addObject(scale1) - arr:addObject(sc_back) - imgMipMap:runAction(CCRepeatForever:create(CCSequence:create(arr))) - - arr = CCArray:create() - arr:addObject(scale2) - arr:addObject(sc_back2) - - img:runAction(CCRepeatForever:create(CCSequence:create(arr))) + imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) + img:runAction(cc.RepeatForever:create(cc.Sequence:create(scale2, sc_back2))) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -192,42 +166,29 @@ end -------------------------------------------------------------------- local function TexturePVRMipMap2() local ret = createTestLayer("PVR MipMap Test #2", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local imgMipMap = CCSprite:create("Images/test_image_rgba4444_mipmap.pvr") - imgMipMap:setPosition(CCPoint( s.width/2.0-100, s.height/2.0)) + local imgMipMap = cc.Sprite:create("Images/test_image_rgba4444_mipmap.pvr") + imgMipMap:setPosition(cc.p( s.width/2.0-100, s.height/2.0)) ret:addChild(imgMipMap) -- support mipmap filtering - local texParams = CCTexture:TexParams() - texParams.minFilter = GL_LINEAR_MIPMAP_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_CLAMP_TO_EDGE - texParams.wrapT = GL_CLAMP_TO_EDGE + imgMipMap:getTexture():setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE) - imgMipMap:getTexture():setTexParameters(texParams) - - local img = CCSprite:create("Images/test_image.png") - img:setPosition(CCPoint( s.width/2.0+100, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.png") + img:setPosition(cc.p( s.width/2.0+100, s.height/2.0)) ret:addChild(img) - local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) + local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "CCEaseOut") + local scale2 = tolua.cast(scale1:clone(), "EaseOut") local sc_back2 = scale2:reverse() - local arr = CCArray:create() - arr:addObject(scale1) - arr:addObject(sc_back) - imgMipMap:runAction(CCRepeatForever:create(CCSequence:create(arr))) + imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) + img:runAction(cc.RepeatForever:create(cc.Sequence:create(scale2, sc_back2))) - arr = CCArray:create() - arr:addObject(scale2) - arr:addObject(sc_back2) - - img:runAction(CCRepeatForever:create(CCSequence:create(arr))) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -241,16 +202,16 @@ end local function TexturePVR2BPP() local ret = createTestLayer("PVR TC 2bpp Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtc2bpp.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtc2bpp.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -263,17 +224,17 @@ end -------------------------------------------------------------------- local function TexturePVR() local ret = createTestLayer("PVR TC 4bpp Test #2") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.pvr") + local img = cc.Sprite:create("Images/test_image.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported.") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -287,17 +248,17 @@ end local function TexturePVR4BPP() local ret = createTestLayer("PVR TC 4bpp Test #3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtc4bpp.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtc4bpp.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported in cocos2d-mac") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -311,12 +272,12 @@ end local function TexturePVRRGBA8888() local ret = createTestLayer("PVR + RGBA 8888 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba8888.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba8888.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -330,16 +291,16 @@ end local function TexturePVRBGRA8888() local ret = createTestLayer("PVR + BGRA 8888 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_bgra8888.pvr") + local img = cc.Sprite:create("Images/test_image_bgra8888.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("BGRA8888 images are not supported") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -352,12 +313,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGBA5551() local ret = createTestLayer("PVR + RGBA 5551 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba5551.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba5551.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -370,12 +331,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGBA4444() local ret = createTestLayer("PVR + RGBA 4444 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba4444.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba4444.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -389,12 +350,12 @@ end local function TexturePVRRGBA4444GZ() local ret = createTestLayer("PVR + RGBA 4444 + GZ Test", "This is a gzip PVR image") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba4444.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba4444.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -406,14 +367,14 @@ end -- -------------------------------------------------------------------- local function TexturePVRRGBA4444CCZ() - local ret = createTestLayer("PVR + RGBA 4444 + CCZ Test", + local ret = createTestLayer("PVR + RGBA 4444 + cc.Z Test", "This is a ccz PVR image") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba4444.pvr.ccz") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba4444.pvr.ccz") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -426,12 +387,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGB565() local ret = createTestLayer("PVR + RGB 565 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgb565.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgb565.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -440,14 +401,14 @@ end -- http:--www.imgtec.com/powervr/insider/powervr-pvrtextool.asp local function TexturePVRRGB888() local ret = createTestLayer("PVR + RGB 888 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgb888.pvr") + local img = cc.Sprite:create("Images/test_image_rgb888.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -460,12 +421,12 @@ end -------------------------------------------------------------------- local function TexturePVRA8() local ret = createTestLayer("PVR + A8 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_a8.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_a8.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -478,12 +439,12 @@ end -------------------------------------------------------------------- local function TexturePVRI8() local ret = createTestLayer("PVR + I8 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_i8.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_i8.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -497,61 +458,61 @@ end -------------------------------------------------------------------- local function TexturePVRAI88() local ret = createTestLayer("PVR + AI88 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_ai88.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_ai88.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVR2BPPv3 local function TexturePVR2BPPv3() local ret = createTestLayer("PVR TC 2bpp Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtc2bpp_v3.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtc2bpp_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVRII2BPPv3 local function TexturePVRII2BPPv3() local ret = createTestLayer("PVR TC II 2bpp Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtcii2bpp_v3.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtcii2bpp_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVR4BPPv3 local function TexturePVR4BPPv3() local ret = createTestLayer("PVR TC 4bpp Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtc4bpp_v3.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtc4bpp_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -563,17 +524,17 @@ end local function TexturePVRII4BPPv3() local ret = createTestLayer("PVR TC II 4bpp Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtcii4bpp_v3.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtcii4bpp_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -581,16 +542,16 @@ end local function TexturePVRRGBA8888v3() local ret = createTestLayer("PVR + RGBA 8888 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba8888_v3.pvr") + local img = cc.Sprite:create("Images/test_image_rgba8888_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -599,18 +560,18 @@ local function TexturePVRBGRA8888v3() local ret = createTestLayer("PVR + BGRA 8888 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_bgra8888_v3.pvr") + local img = cc.Sprite:create("Images/test_image_bgra8888_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("BGRA images are not supported") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -618,15 +579,15 @@ end local function TexturePVRRGBA5551v3() local ret = createTestLayer("PVR + RGBA 5551 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba5551_v3.pvr") + local s = cc.Director:getInstance():getWinSize() + local img = cc.Sprite:create("Images/test_image_rgba5551_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -634,16 +595,16 @@ end local function TexturePVRRGBA4444v3() local ret = createTestLayer("PVR + RGBA 4444 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba4444_v3.pvr") + local img = cc.Sprite:create("Images/test_image_rgba4444_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -651,16 +612,16 @@ end local function TexturePVRRGB565v3() local ret = createTestLayer("PVR + RGB 565 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgb565_v3.pvr") + local img = cc.Sprite:create("Images/test_image_rgb565_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -668,16 +629,16 @@ end local function TexturePVRRGB888v3() local ret = createTestLayer("PVR + RGB 888 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgb888_v3.pvr") + local img = cc.Sprite:create("Images/test_image_rgb888_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -685,16 +646,16 @@ end local function TexturePVRA8v3() local ret = createTestLayer("PVR + A8 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_a8_v3.pvr") + local img = cc.Sprite:create("Images/test_image_a8_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -702,16 +663,16 @@ end local function TexturePVRI8v3() local ret = createTestLayer("PVR + I8 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_i8_v3.pvr") + local img = cc.Sprite:create("Images/test_image_i8_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -719,16 +680,16 @@ end local function TexturePVRAI88v3() local ret = createTestLayer("PVR + AI88 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_ai88_v3.pvr") + local img = cc.Sprite:create("Images/test_image_ai88_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -742,11 +703,11 @@ end local function TexturePVRBadEncoding() local ret = createTestLayer("PVR Unsupported encoding", "You should not see any image") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image-bad_encoding.pvr") + local img = cc.Sprite:create("Images/test_image-bad_encoding.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end return ret @@ -760,12 +721,12 @@ end local function TexturePVRNonSquare() local ret = createTestLayer("PVR + Non square texture", "Loading a 128x256 texture") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/grossini_128x256_mipmap.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/grossini_128x256_mipmap.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -777,14 +738,14 @@ end local function TexturePVRNPOT4444() local ret = createTestLayer("PVR RGBA4 + NPOT texture", "Loading a 81x121 RGBA4444 texture.") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/grossini_pvr_rgba4444.pvr") + local img = cc.Sprite:create("Images/grossini_pvr_rgba4444.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -796,14 +757,14 @@ end local function TexturePVRNPOT8888() local ret = createTestLayer("PVR RGBA8 + NPOT texture", "Loading a 81x121 RGBA8888 texture.") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/grossini_pvr_rgba8888.pvr") + local img = cc.Sprite:create("Images/grossini_pvr_rgba8888.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -815,15 +776,15 @@ end local function TextureAlias() local ret = createTestLayer("AntiAlias / Alias textures", "Left image is antialiased. Right image is aliases") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() -- - -- Sprite 1: GL_LINEAR + -- Sprite 1: gl.LINEAR -- - -- Default filter is GL_LINEAR + -- Default filter is gl.LINEAR - local sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(CCPoint( s.width/3.0, s.height/2.0)) + local sprite = cc.Sprite:create("Images/grossinis_sister1.png") + sprite:setPosition(cc.p( s.width/3.0, s.height/2.0)) ret:addChild(sprite) -- this is the default filterting @@ -833,25 +794,22 @@ local function TextureAlias() -- Sprite 1: GL_NEAREST -- - local sprite2 = CCSprite:create("Images/grossinis_sister2.png") - sprite2:setPosition(CCPoint( 2*s.width/3.0, s.height/2.0)) + local sprite2 = cc.Sprite:create("Images/grossinis_sister2.png") + sprite2:setPosition(cc.p( 2*s.width/3.0, s.height/2.0)) ret:addChild(sprite2) -- Use Nearest in this one sprite2:getTexture():setAliasTexParameters() -- scale them to show - local sc = CCScaleBy:create(3, 8.0) - local sc_back = tolua.cast(sc:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(sc) - arr:addObject(sc_back) - local scaleforever = CCRepeatForever:create(CCSequence:create(arr)) - local scaleToo = tolua.cast(scaleforever:clone(), "CCRepeatForever") + local sc = cc.ScaleBy:create(3, 8.0) + local sc_back = tolua.cast(sc:reverse(), "ScaleBy") + local scaleforever = cc.RepeatForever:create(cc.Sequence:create(sc, sc_back)) + local scaleToo = tolua.cast(scaleforever:clone(), "RepeatForever") sprite2:runAction(scaleforever) sprite:runAction(scaleToo) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -871,80 +829,76 @@ local function TexturePixelFormat() -- 3- 16-bit RGB5A1 -- 4- 16-bit RGB565 - local label = tolua.cast(ret:getChildByTag(kTagLabel), "CCLabelTTF") - label:setColor(Color3B(16,16,255)) + local label = tolua.cast(ret:getChildByTag(kTagLabel), "LabelTTF") + label:setColor(cc.c3b(16,16,255)) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local background = CCLayerColor:create(Color4B(128,128,128,255), s.width, s.height) + local background = cc.LayerColor:create(cc.c4b(128,128,128,255), s.width, s.height) ret:addChild(background, -1) -- RGBA 8888 image (32-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - local sprite1 = CCSprite:create("Images/test-rgba1.png") - sprite1:setPosition(CCPoint(1*s.width/7, s.height/2+32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + local sprite1 = cc.Sprite:create("Images/test-rgba1.png") + sprite1:setPosition(cc.p(1*s.width/7, s.height/2+32)) ret:addChild(sprite1, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite1:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite1:getTexture()) -- RGBA 4444 image (16-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - local sprite2 = CCSprite:create("Images/test-rgba1.png") - sprite2:setPosition(CCPoint(2*s.width/7, s.height/2-32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + local sprite2 = cc.Sprite:create("Images/test-rgba1.png") + sprite2:setPosition(cc.p(2*s.width/7, s.height/2-32)) ret:addChild(sprite2, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite2:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite2:getTexture()) -- RGB5A1 image (16-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB5A1) - local sprite3 = CCSprite:create("Images/test-rgba1.png") - sprite3:setPosition(CCPoint(3*s.width/7, s.height/2+32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1) + local sprite3 = cc.Sprite:create("Images/test-rgba1.png") + sprite3:setPosition(cc.p(3*s.width/7, s.height/2+32)) ret:addChild(sprite3, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite3:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite3:getTexture()) -- RGB888 image - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB888) - local sprite4 = CCSprite:create("Images/test-rgba1.png") - sprite4:setPosition(CCPoint(4*s.width/7, s.height/2-32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 ) + local sprite4 = cc.Sprite:create("Images/test-rgba1.png") + sprite4:setPosition(cc.p(4*s.width/7, s.height/2-32)) ret:addChild(sprite4, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite4:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite4:getTexture()) -- RGB565 image (16-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB565) - local sprite5 = CCSprite:create("Images/test-rgba1.png") - sprite5:setPosition(CCPoint(5*s.width/7, s.height/2+32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565) + local sprite5 = cc.Sprite:create("Images/test-rgba1.png") + sprite5:setPosition(cc.p(5*s.width/7, s.height/2+32)) ret:addChild(sprite5, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite5:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite5:getTexture()) -- A8 image (8-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8) - local sprite6 = CCSprite:create("Images/test-rgba1.png") - sprite6:setPosition(CCPoint(6*s.width/7, s.height/2-32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_A8 ) + local sprite6 = cc.Sprite:create("Images/test-rgba1.png") + sprite6:setPosition(cc.p(6*s.width/7, s.height/2-32)) ret:addChild(sprite6, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite6:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite6:getTexture()) - local fadeout = CCFadeOut:create(2) - local fadein = CCFadeIn:create(2) - local arr = CCArray:create() - arr:addObject(CCDelayTime:create(2)) - arr:addObject(fadeout) - arr:addObject(fadein) - local seq = CCSequence:create(arr) - local seq_4ever = CCRepeatForever:create(seq) - local seq_4ever2 = tolua.cast(seq_4ever:clone(), "CCRepeatForever") - local seq_4ever3 = tolua.cast(seq_4ever:clone(), "CCRepeatForever") - local seq_4ever4 = tolua.cast(seq_4ever:clone(), "CCRepeatForever") - local seq_4ever5 = tolua.cast(seq_4ever:clone(), "CCRepeatForever") + local fadeout = cc.FadeOut:create(2) + local fadein = cc.FadeIn:create(2) + local seq = cc.Sequence:create(cc.DelayTime:create(2), fadeout, fadein) + local seq_4ever = cc.RepeatForever:create(seq) + local seq_4ever2 = tolua.cast(seq_4ever:clone(), "RepeatForever") + local seq_4ever3 = tolua.cast(seq_4ever:clone(), "RepeatForever") + local seq_4ever4 = tolua.cast(seq_4ever:clone(), "RepeatForever") + local seq_4ever5 = tolua.cast(seq_4ever:clone(), "RepeatForever") sprite1:runAction(seq_4ever) sprite2:runAction(seq_4ever2) @@ -953,8 +907,8 @@ local function TexturePixelFormat() sprite5:runAction(seq_4ever5) -- restore default - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT) + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -970,33 +924,24 @@ local function TextureBlend() for i=0, 14 do -- BOTTOM sprites have alpha pre-multiplied -- they use by default GL_ONE, GL_ONE_MINUS_SRC_ALPHA - local cloud = CCSprite:create("Images/test_blend.png") + local cloud = cc.Sprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 100+i) - cloud:setPosition(CCPoint(50+25*i, 80)) - local blendFunc1 = BlendFunc() - blendFunc1.src = GL_ONE - blendFunc1.dst = GL_ONE_MINUS_SRC_ALPHA - cloud:setBlendFunc(blendFunc1) + cloud:setPosition(cc.p(50+25*i, 80)) + cloud:setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) -- CENTER sprites have also alpha pre-multiplied -- they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA - cloud = CCSprite:create("Images/test_blend.png") + cloud = cc.Sprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 200+i) - cloud:setPosition(CCPoint(50+25*i, 160)) - local blendFunc2 = BlendFunc() - blendFunc2.src = GL_ONE_MINUS_DST_COLOR - blendFunc2.dst = GL_ZERO - cloud:setBlendFunc(blendFunc2) + cloud:setPosition(cc.p(50+25*i, 160)) + cloud:setBlendFunc(gl.ONE_MINUS_DST_COLOR , gl.ZERO) -- UPPER sprites are using custom blending function -- You can set any blend function to your sprites - cloud = CCSprite:create("Images/test_blend.png") + cloud = cc.Sprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 200+i) - cloud:setPosition(CCPoint(50+25*i, 320-80)) - local blendFunc3 = BlendFunc() - blendFunc3.src = GL_SRC_ALPHA - blendFunc3.dst = GL_ONE - cloud:setBlendFunc(blendFunc3) -- additive blending + cloud:setPosition(cc.p(50+25*i, 320-80)) + cloud:setBlendFunc(gl.SRC_ALPHA, gl.ONE) -- additive blending end return ret end @@ -1012,37 +957,34 @@ local function TextureAsync() "Textures should load while an animation is being run") local m_nImageOffset = 0 - local size =CCDirector:getInstance():getWinSize() + local size =cc.Director:getInstance():getWinSize() - local label = CCLabelTTF:create("Loading...", "Marker Felt", 32) - label:setPosition(CCPoint( size.width/2, size.height/2)) + local label = cc.LabelTTF:create("Loading...", "Marker Felt", 32) + label:setPosition(cc.p( size.width/2, size.height/2)) ret:addChild(label, 10) - local scale = CCScaleBy:create(0.3, 2) - local scale_back = tolua.cast(scale:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(scale) - arr:addObject(scale_back) - local seq = CCSequence:create(arr) - label:runAction(CCRepeatForever:create(seq)) + local scale = cc.ScaleBy:create(0.3, 2) + local scale_back = tolua.cast(scale:reverse(), "ScaleBy") + local seq = cc.Sequence:create(scale, scale_back) + label:runAction(cc.RepeatForever:create(seq)) local function imageLoaded(pObj) - local tex = tolua.cast(pObj, "CCTexture2D") - local director = CCDirector:getInstance() + local tex = tolua.cast(pObj, "Texture2D") + local director = cc.Director:getInstance() - --CCASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread") + --cc.ASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread") -- IMPORTANT: The order on the callback is not guaranteed. Don't depend on the callback -- This test just creates a sprite based on the Texture - local sprite = CCSprite:createWithTexture(tex) - sprite:setAnchorPoint(CCPoint(0,0)) + local sprite = cc.Sprite:createWithTexture(tex) + sprite:setAnchorPoint(cc.p(0,0)) ret:addChild(sprite, -1) local size = director:getWinSize() local i = m_nImageOffset * 32 - sprite:setPosition(CCPoint( i % size.width, (i / size.width) * 32 )) + sprite:setPosition(cc.p( i % size.width, (i / size.width) * 32 )) m_nImageOffset = m_nImageOffset + 1 cclog("Image loaded:...")-- %p", tex) @@ -1055,16 +997,16 @@ local function TextureAsync() for j=0, 7 do local szSpriteName = string.format( "Images/sprites_test/sprite-%d-%d.png", i, j) - CCTextureCache:getInstance():addImageAsync( + cc.TextureCache:getInstance():addImageAsync( szSpriteName, imageLoaded) end end - CCTextureCache:getInstance():addImageAsync("Images/background1.jpg", imageLoaded) - CCTextureCache:getInstance():addImageAsync("Images/background2.jpg", imageLoaded) - CCTextureCache:getInstance():addImageAsync("Images/background.png", imageLoaded) - CCTextureCache:getInstance():addImageAsync("Images/atlastest.png", imageLoaded) - CCTextureCache:getInstance():addImageAsync("Images/grossini_dance_atlas.png",imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/background1.jpg", imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/background2.jpg", imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/background.png", imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/atlastest.png", imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/grossini_dance_atlas.png",imageLoaded) end local schedulerEntry = nil @@ -1073,7 +1015,7 @@ local function TextureAsync() schedulerEntry = scheduler:scheduleScriptFunc(loadImages, 1.0, false) elseif event == "exit" then scheduler:unscheduleScriptEntry(schedulerEntry) - CCTextureCache:getInstance():removeAllTextures() + cc.TextureCache:getInstance():removeAllTextures() end end @@ -1089,33 +1031,24 @@ end local function TextureGlClamp() local ret = createTestLayer("Texture GL_CLAMP") - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() -- The .png image MUST be power of 2 in order to create a continue effect. -- eg: 32x64, 512x128, 256x1024, 64x64, etc.. - local sprite = CCSprite:create("Images/pattern1.png", CCRect(0,0,512,256)) + local sprite = cc.Sprite:create("Images/pattern1.png", cc.rect(0,0,512,256)) ret:addChild(sprite, -1, kTagSprite1) - sprite:setPosition(CCPoint(size.width/2,size.height/2)) - local texParams = CCTexture:TexParams() - texParams.minFilter = GL_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_CLAMP_TO_EDGE - texParams.wrapT = GL_CLAMP_TO_EDGE + sprite:setPosition(cc.p(size.width/2,size.height/2)) + sprite:getTexture():setTexParameters(gl.LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE) - sprite:getTexture():setTexParameters(texParams) - - local rotate = CCRotateBy:create(4, 360) + local rotate = cc.RotateBy:create(4, 360) sprite:runAction(rotate) - local scale = CCScaleBy:create(2, 0.04) - local scaleBack = tolua.cast(scale:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(scale) - arr:addObject(scaleBack) - local seq = CCSequence:create(arr) + local scale = cc.ScaleBy:create(2, 0.04) + local scaleBack = tolua.cast(scale:reverse(), "ScaleBy") + local seq = cc.Sequence:create(scale, scaleBack) sprite:runAction(seq) local function onNodeEvent(event) if event == "exit" then - CCTextureCache:getInstance():removeUnusedTextures() + cc.TextureCache:getInstance():removeUnusedTextures() end end @@ -1130,36 +1063,26 @@ end -- -------------------------------------------------------------------- local function TextureGlRepeat() - local ret = createTestLayer("Texture GL_REPEAT") + local ret = createTestLayer("Texture gl.REPEAT") - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() -- The .png image MUST be power of 2 in order to create a continue effect. -- eg: 32x64, 512x128, 256x1024, 64x64, etc.. - local sprite = CCSprite:create("Images/pattern1.png", CCRect(0, 0, 4096, 4096)) + local sprite = cc.Sprite:create("Images/pattern1.png", cc.rect(0, 0, 4096, 4096)) ret:addChild(sprite, -1, kTagSprite1) - sprite:setPosition(CCPoint(size.width/2,size.height/2)) - local texParams = CCTexture:TexParams() + sprite:setPosition(cc.p(size.width/2,size.height/2)) + sprite:getTexture():setTexParameters(gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT) - texParams.minFilter = GL_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_REPEAT - texParams.wrapT = GL_REPEAT - - sprite:getTexture():setTexParameters(texParams) - - local rotate = CCRotateBy:create(4, 360) + local rotate = cc.RotateBy:create(4, 360) sprite:runAction(rotate) - local scale = CCScaleBy:create(2, 0.04) - local scaleBack = tolua.cast(scale:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(scale) - arr:addObject(scaleBack) - local seq = CCSequence:create(arr) + local scale = cc.ScaleBy:create(2, 0.04) + local scaleBack = tolua.cast(scale:reverse(), "ScaleBy") + local seq = cc.Sequence:create(scale, scaleBack) sprite:runAction(seq) local function onNodeEvent(event) if event == "exit" then - CCTextureCache:getInstance():removeUnusedTextures() + cc.TextureCache:getInstance():removeUnusedTextures() end end @@ -1179,28 +1102,28 @@ local function TextureSizeTest() local sprite = nil cclog("Loading 512x512 image...") - sprite = CCSprite:create("Images/texture512x512.png") + sprite = cc.Sprite:create("Images/texture512x512.png") if sprite ~= nil then cclog("OK\n") else cclog("Error\n") cclog("Loading 1024x1024 image...") - sprite = CCSprite:create("Images/texture1024x1024.png") + sprite = cc.Sprite:create("Images/texture1024x1024.png") if sprite ~= nil then cclog("OK\n") else cclog("Error\n") -- @todo -- cclog("Loading 2048x2048 image...") - -- sprite = CCSprite:create("Images/texture2048x2048.png") + -- sprite = cc.Sprite:create("Images/texture2048x2048.png") -- if( sprite ) -- cclog("OK\n") -- else -- cclog("Error\n") -- -- cclog("Loading 4096x4096 image...") - -- sprite = CCSprite:create("Images/texture4096x4096.png") + -- sprite = cc.Sprite:create("Images/texture4096x4096.png") -- if( sprite ) -- cclog("OK\n") -- else @@ -1215,38 +1138,38 @@ end -- -------------------------------------------------------------------- local function TextureCache1() - local ret = createTestLayer("CCTextureCache: remove", + local ret = createTestLayer("TextureCache: remove", "4 images should appear: alias, antialias, alias, antilias") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local sprite = nil - sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(CCPoint(s.width/5*1, s.height/2)) + sprite = cc.Sprite:create("Images/grossinis_sister1.png") + sprite:setPosition(cc.p(s.width/5*1, s.height/2)) sprite:getTexture():setAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) - CCTextureCache:getInstance():removeTexture(sprite:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite:getTexture()) - sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(CCPoint(s.width/5*2, s.height/2)) + sprite = cc.Sprite:create("Images/grossinis_sister1.png") + sprite:setPosition(cc.p(s.width/5*2, s.height/2)) sprite:getTexture():setAntiAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) -- 2nd set of sprites - sprite = CCSprite:create("Images/grossinis_sister2.png") - sprite:setPosition(CCPoint(s.width/5*3, s.height/2)) + sprite = cc.Sprite:create("Images/grossinis_sister2.png") + sprite:setPosition(cc.p(s.width/5*3, s.height/2)) sprite:getTexture():setAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) - CCTextureCache:getInstance():removeTextureForKey("Images/grossinis_sister2.png") + cc.TextureCache:getInstance():removeTextureForKey("Images/grossinis_sister2.png") - sprite = CCSprite:create("Images/grossinis_sister2.png") - sprite:setPosition(CCPoint(s.width/5*4, s.height/2)) + sprite = cc.Sprite:create("Images/grossinis_sister2.png") + sprite:setPosition(cc.p(s.width/5*4, s.height/2)) sprite:getTexture():setAntiAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) @@ -1257,20 +1180,20 @@ end local function TextureDrawAtPoint() local m_pTex1 = nil local m_pTex2F = nil - local ret = createTestLayer("CCTexture2D: drawAtPoint", + local ret = createTestLayer("Texture2D: drawAtPoint", "draws 2 textures using drawAtPoint") local function draw() -- TextureDemo:draw() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - m_pTex1:drawAtPoint(CCPoint(s.width/2-50, s.height/2 - 50)) - m_pTex2F:drawAtPoint(CCPoint(s.width/2+50, s.height/2 - 50)) + m_pTex1:drawAtPoint(cc.p(s.width/2-50, s.height/2 - 50)) + m_pTex2F:drawAtPoint(cc.p(s.width/2+50, s.height/2 - 50)) end - m_pTex1 = CCTextureCache:getInstance():addImage("Images/grossinis_sister1.png") - m_pTex2F = CCTextureCache:getInstance():addImage("Images/grossinis_sister2.png") + m_pTex1 = cc.TextureCache:getInstance():addImage("Images/grossinis_sister1.png") + m_pTex2F = cc.TextureCache:getInstance():addImage("Images/grossinis_sister2.png") m_pTex1:retain() m_pTex2F:retain() @@ -1289,22 +1212,22 @@ end -- TextureDrawInRect local function TextureDrawInRect() - local ret = createTestLayer("CCTexture2D: drawInRect", + local ret = createTestLayer("Texture2D: drawInRect", "draws 2 textures using drawInRect") local function draw() -- TextureDemo:draw() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local rect1 = CCRect( s.width/2 - 80, 20, m_pTex1:getContentSize().width * 0.5, m_pTex1:getContentSize().height *2 ) - local rect2 = CCRect( s.width/2 + 80, s.height/2, m_pTex1:getContentSize().width * 2, m_pTex1:getContentSize().height * 0.5 ) + local rect1 = cc.rect( s.width/2 - 80, 20, m_pTex1:getContentSize().width * 0.5, m_pTex1:getContentSize().height *2 ) + local rect2 = cc.rect( s.width/2 + 80, s.height/2, m_pTex1:getContentSize().width * 2, m_pTex1:getContentSize().height * 0.5 ) m_pTex1:drawInRect(rect1) m_pTex2F:drawInRect(rect2) end - local m_pTex1 = CCTextureCache:getInstance():addImage("Images/grossinis_sister1.png") - local m_pTex2F = CCTextureCache:getInstance():addImage("Images/grossinis_sister2.png") + local m_pTex1 = cc.TextureCache:getInstance():addImage("Images/grossinis_sister1.png") + local m_pTex2F = cc.TextureCache:getInstance():addImage("Images/grossinis_sister2.png") m_pTex1:retain() m_pTex2F:retain() @@ -1330,14 +1253,14 @@ local function TextureMemoryAlloc() "Testing Texture Memory allocation. Use Instruments + VM Tracker") local m_pBackground = nil - CCMenuItemFont:setFontSize(24) + cc.MenuItemFont:setFontSize(24) local function updateImage(tag,sender) if m_pBackground ~= nil then cclog("updateImage"..tag) - m_pBackground:removeFromParentAndCleanup(true) + m_pBackground:removeFromParent(true) end - CCTextureCache:getInstance():removeUnusedTextures() + cc.TextureCache:getInstance():removeUnusedTextures() local file = "" if tag == 0 then @@ -1352,47 +1275,41 @@ local function TextureMemoryAlloc() file = "Images/test_1021x1024_a8.pvr" end - m_pBackground = CCSprite:create(file) + m_pBackground = cc.Sprite:create(file) ret:addChild(m_pBackground, -10) m_pBackground:setVisible(false) - local s = CCDirector:getInstance():getWinSize() - m_pBackground:setPosition(CCPoint(s.width/2, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + m_pBackground:setPosition(cc.p(s.width/2, s.height/2)) end - local item1 = CCMenuItemFont:create("PNG") + local item1 = cc.MenuItemFont:create("PNG") item1:registerScriptTapHandler(updateImage) item1:setTag(0) - local item2 = CCMenuItemFont:create("RGBA8") + local item2 = cc.MenuItemFont:create("RGBA8") item2:registerScriptTapHandler(updateImage) item2:setTag(1) - local item3 = CCMenuItemFont:create("RGB8") + local item3 = cc.MenuItemFont:create("RGB8") item3:registerScriptTapHandler(updateImage) item3:setTag(2) - local item4 = CCMenuItemFont:create("RGBA4") + local item4 = cc.MenuItemFont:create("RGBA4") item4:registerScriptTapHandler(updateImage) item4:setTag(3) - local item5 = CCMenuItemFont:create("A8") + local item5 = cc.MenuItemFont:create("A8") item5:registerScriptTapHandler(updateImage) item5:setTag(4) - local arr = CCArray:create() - arr:addObject(item1) - arr:addObject(item2) - arr:addObject(item3) - arr:addObject(item4) - arr:addObject(item5) - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item1, item2, item3, item4, item5) menu:alignItemsHorizontally() ret:addChild(menu) - local warmup = CCMenuItemFont:create("warm up texture") + local warmup = cc.MenuItemFont:create("warm up texture") local function changeBackgroundVisible(tag, sender) if m_pBackground ~= nil then @@ -1402,14 +1319,14 @@ local function TextureMemoryAlloc() end warmup:registerScriptTapHandler(changeBackgroundVisible) - local menu2 = CCMenu:createWithItem(warmup) + local menu2 = cc.Menu:create(warmup) menu2:alignItemsHorizontally() ret:addChild(menu2) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - menu2:setPosition(CCPoint(s.width/2, s.height/4)) + menu2:setPosition(cc.p(s.width/2, s.height/4)) return ret end @@ -1419,42 +1336,38 @@ local function TexturePVRv3Premult() "All images should look exactly the same") local function transformSprite(sprite) - local fade = CCFadeOut:create(2) - local dl = CCDelayTime:create(2) - local fadein = tolua.cast(fade:reverse(), "CCFadeOut") - local arr = CCArray:create() - arr:addObject(fade) - arr:addObject(fadein) - arr:addObject(dl) - local seq = CCSequence:create(arr) - local repeatAction = CCRepeatForever:create(seq) + local fade = cc.FadeOut:create(2) + local dl = cc.DelayTime:create(2) + local fadein = tolua.cast(fade:reverse(), "FadeOut") + local seq = cc.Sequence:create(fade, fadein, dl) + local repeatAction = cc.RepeatForever:create(seq) sprite:runAction(repeatAction) end - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() - local background = CCLayerColor:create(Color4B(128,128,128,255), size.width, size.height) + local background = cc.LayerColor:create(cc.c4b(128,128,128,255), size.width, size.height) ret:addChild(background, -1) -- PVR premultiplied - local pvr1 = CCSprite:create("Images/grossinis_sister1-testalpha_premult.pvr") + local pvr1 = cc.Sprite:create("Images/grossinis_sister1-testalpha_premult.pvr") ret:addChild(pvr1, 0) - pvr1:setPosition(CCPoint(size.width/4*1, size.height/2)) + pvr1:setPosition(cc.p(size.width/4*1, size.height/2)) transformSprite(pvr1) -- PVR non-premultiplied - local pvr2 = CCSprite:create("Images/grossinis_sister1-testalpha_nopremult.pvr") + local pvr2 = cc.Sprite:create("Images/grossinis_sister1-testalpha_nopremult.pvr") ret:addChild(pvr2, 0) - pvr2:setPosition(CCPoint(size.width/4*2, size.height/2)) + pvr2:setPosition(cc.p(size.width/4*2, size.height/2)) transformSprite(pvr2) -- PNG - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - CCTextureCache:getInstance():removeTextureForKey("Images/grossinis_sister1-testalpha.png") - local png = CCSprite:create("Images/grossinis_sister1-testalpha.png") + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + cc.TextureCache:getInstance():removeTextureForKey("Images/grossinis_sister1-testalpha.png") + local png = cc.Sprite:create("Images/grossinis_sister1-testalpha.png") ret:addChild(png, 0) - png:setPosition(CCPoint(size.width/4*3, size.height/2)) + png:setPosition(cc.p(size.width/4*3, size.height/2)) transformSprite(png) return ret end @@ -1463,7 +1376,7 @@ end function Texture2dTestMain() cclog("Texture2dTestMain") Helper.index = 1 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { TextureMemoryAlloc, TextureAlias, diff --git a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua index 2440455ac6..b80891af25 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua @@ -1,11 +1,11 @@ -local size = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local size = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local kTagTileMap = 1 local function createTileDemoLayer(title, subtitle) - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) local titleStr = title == nil and "No title" or title local subTitleStr = subtitle == nil and "drag the screen" or subtitle @@ -25,7 +25,7 @@ local function createTileDemoLayer(title, subtitle) local diffX = x - prev.x local diffY = y - prev.y - node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) ) + node:setPosition( cc.pAdd(cc.p(newX, newY), cc.p(diffX, diffY)) ) prev.x = x prev.y = y end @@ -42,7 +42,7 @@ end local function TileMapTest() local layer = createTileDemoLayer("TileMapAtlas") - local map = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) + local map = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) -- Convert it to "alias" (GL_LINEAR filtering) map:getTexture():setAntiAliasTexParameters() @@ -55,17 +55,14 @@ local function TileMapTest() layer:addChild(map, 0, kTagTileMap) - map:setAnchorPoint( CCPoint(0, 0.5) ) + map:setAnchorPoint( cc.p(0, 0.5) ) - local scale = CCScaleBy:create(4, 0.8) + local scale = cc.ScaleBy:create(4, 0.8) local scaleBack = scale:reverse() - local action_arr = CCArray:create() - action_arr:addObject(scale) - action_arr:addObject(scaleBack) - local seq = CCSequence:create(action_arr) + local seq = cc.Sequence:create(scale, scaleBack) - map:runAction(CCRepeatForever:create(seq)) + map:runAction(cc.RepeatForever:create(seq)) return layer end @@ -77,7 +74,7 @@ end -------------------------------------------------------------------- local function TileMapEditTest() local layer = createTileDemoLayer("Editable TileMapAtlas") - local map = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) + local map = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) -- Create an Aliased Atlas map:getTexture():setAliasTexParameters() @@ -93,7 +90,7 @@ local function TileMapEditTest() -- The only limitation is that you cannot change an empty, or assign an empty tile to a tile -- The value 0 not rendered so don't assign or change a tile with value 0 - local tilemap = tolua.cast(layer:getChildByTag(kTagTileMap), "CCTileMapAtlas") + local tilemap = tolua.cast(layer:getChildByTag(kTagTileMap), "TileMapAtlas") -- -- For example you can iterate over all the tiles @@ -109,7 +106,7 @@ local function TileMapEditTest() -- end -- NEW since v0.7 - local c = tilemap:getTileAt(CCPoint(13,21)) + local c = tilemap:getTileAt(cc.p(13,21)) c.r = c.r + 1 c.r = c.r % 50 @@ -117,7 +114,7 @@ local function TileMapEditTest() c.r=1 end -- NEW since v0.7 - tilemap:setTile(c, CCPoint(13,21) ) + tilemap:setTile(c, cc.p(13,21) ) end local schedulerEntry = nil @@ -133,8 +130,8 @@ local function TileMapEditTest() layer:addChild(map, 0, kTagTileMap) - map:setAnchorPoint( CCPoint(0, 0) ) - map:setPosition( CCPoint(-20,-200) ) + map:setAnchorPoint( cc.p(0, 0) ) + map:setPosition( cc.p(-20,-200) ) return layer end @@ -152,10 +149,10 @@ local function TMXOrthoTest() -- -- it should not flicker. No artifacts should appear -- - --local color = CCLayerColor:create( Color4B(64,64,64,255) ) + --local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) --addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test2.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test2.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -165,10 +162,10 @@ local function TMXOrthoTest() local child = nil local pObject = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - pObject = pChildrenArray:objectAtIndex(i) - child = tolua.cast(pObject, "CCSpriteBatchNode") + pObject = pChildrenArray[i + 1] + child = tolua.cast(pObject, "SpriteBatchNode") if child == nil then break @@ -180,18 +177,18 @@ local function TMXOrthoTest() local x = 0 local y = 0 local z = 0 - x, y, z = map:getCamera():getEyeXYZ(x, y, z) + x, y, z = map:getCamera():getEye() cclog("before eye x="..x..",y="..y..",z="..z) - map:getCamera():setEyeXYZ(x-200, y, z+300) - x, y, z = map:getCamera():getEyeXYZ(x, y, z) + map:getCamera():setEye(x-200, y, z+300) + x, y, z = map:getCamera():getEye() cclog("after eye x="..x..",y="..y..",z="..z) local function onNodeEvent(event) if event == "enter" then - CCDirector:getInstance():setProjection(kCCDirectorProjection3D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION3_D ) elseif event == "exit" then - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D ) end end @@ -209,7 +206,7 @@ end local function TMXOrthoTest2() local layer = createTileDemoLayer("TMX Ortho test2") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test1.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test1.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -219,10 +216,10 @@ local function TMXOrthoTest2() local child = nil local pObject = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray:objectAtIndex(i), "CCSpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") if child == nil then break @@ -230,7 +227,7 @@ local function TMXOrthoTest2() child:getTexture():setAntiAliasTexParameters() end - map:runAction( CCScaleBy:create(2, 0.5) ) + map:runAction( cc.ScaleBy:create(2, 0.5) ) return layer end @@ -241,7 +238,7 @@ end -------------------------------------------------------------------- local function TMXOrthoTest3() local layer = createTileDemoLayer("TMX anchorPoint test") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test3.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test3.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -251,10 +248,10 @@ local function TMXOrthoTest3() local child = nil local pObject = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray:objectAtIndex(i), "CCSpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") if child == nil then break @@ -263,7 +260,7 @@ local function TMXOrthoTest3() end map:setScale(0.2) - map:setAnchorPoint( CCPoint(0.5, 0.5) ) + map:setAnchorPoint( cc.p(0.5, 0.5) ) return layer end @@ -275,7 +272,7 @@ end -------------------------------------------------------------------- local function TMXOrthoTest4() local ret = createTileDemoLayer("TMX width/height test") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test4.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test4.tmx") ret:addChild(map, 0, kTagTileMap) local s1 = map:getContentSize() @@ -285,10 +282,10 @@ local function TMXOrthoTest4() local child = nil local pObject = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray:objectAtIndex(i), "CCSpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") if child == nil then break @@ -296,18 +293,18 @@ local function TMXOrthoTest4() child:getTexture():setAntiAliasTexParameters() end - map:setAnchorPoint(CCPoint(0, 0)) + map:setAnchorPoint(cc.p(0, 0)) local layer = map:getLayer("Layer 0") local s = layer:getLayerSize() - local sprite = layer:getTileAt(CCPoint(0,0)) + local sprite = layer:getTileAt(cc.p(0,0)) sprite:setScale(2) - sprite = layer:getTileAt(CCPoint(s.width-1,0)) + sprite = layer:getTileAt(cc.p(s.width-1,0)) sprite:setScale(2) - sprite = layer:getTileAt(CCPoint(0,s.height-1)) + sprite = layer:getTileAt(cc.p(0,s.height-1)) sprite:setScale(2) - sprite = layer:getTileAt(CCPoint(s.width-1,s.height-1)) + sprite = layer:getTileAt(cc.p(s.width-1,s.height-1)) sprite:setScale(2) local schedulerEntry = nil @@ -315,11 +312,11 @@ local function TMXOrthoTest4() local function removeSprite(dt) scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") local layer0 = map:getLayer("Layer 0") local s = layer0:getLayerSize() - local sprite = layer0:getTileAt( CCPoint(s.width-1,0) ) + local sprite = layer0:getTileAt( cc.p(s.width-1,0) ) layer0:removeChild(sprite, true) end @@ -349,7 +346,7 @@ local function TMXReadWriteTest() local ret = createTileDemoLayer("TMX Read/Write test") local m_gid = 0 local m_gid2 = 0 - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test2.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test2.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -361,25 +358,25 @@ local function TMXReadWriteTest() map:setScale( 1 ) - local tile0 = layer:getTileAt(CCPoint(1,63)) - local tile1 = layer:getTileAt(CCPoint(2,63)) - local tile2 = layer:getTileAt(CCPoint(3,62))--CCPoint(1,62)) - local tile3 = layer:getTileAt(CCPoint(2,62)) - tile0:setAnchorPoint( CCPoint(0.5, 0.5) ) - tile1:setAnchorPoint( CCPoint(0.5, 0.5) ) - tile2:setAnchorPoint( CCPoint(0.5, 0.5) ) - tile3:setAnchorPoint( CCPoint(0.5, 0.5) ) + local tile0 = layer:getTileAt(cc.p(1,63)) + local tile1 = layer:getTileAt(cc.p(2,63)) + local tile2 = layer:getTileAt(cc.p(3,62))--cc.p(1,62)) + local tile3 = layer:getTileAt(cc.p(2,62)) + tile0:setAnchorPoint( cc.p(0.5, 0.5) ) + tile1:setAnchorPoint( cc.p(0.5, 0.5) ) + tile2:setAnchorPoint( cc.p(0.5, 0.5) ) + tile3:setAnchorPoint( cc.p(0.5, 0.5) ) - local move = CCMoveBy:create(0.5, CCPoint(0,160)) - local rotate = CCRotateBy:create(2, 360) - local scale = CCScaleBy:create(2, 5) - local opacity = CCFadeOut:create(2) - local fadein = CCFadeIn:create(2) - local scaleback = CCScaleTo:create(1, 1) + local move = cc.MoveBy:create(0.5, cc.p(0,160)) + local rotate = cc.RotateBy:create(2, 360) + local scale = cc.ScaleBy:create(2, 5) + local opacity = cc.FadeOut:create(2) + local fadein = cc.FadeIn:create(2) + local scaleback = cc.ScaleTo:create(1, 1) local function removeSprite(sender) --------cclog("removing tile: %x", sender) - local node = tolua.cast(sender, "CCNode") + local node = tolua.cast(sender, "Node") if nil == node then print("Errro node is nil") end @@ -391,19 +388,11 @@ local function TMXReadWriteTest() ----------cclog("atlas quantity: %d", p:textureAtlas():totalQuads()) end - local finish = CCCallFunc:create(removeSprite) - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(rotate) - arr:addObject(scale) - arr:addObject(opacity) - arr:addObject(fadein) - arr:addObject(scaleback) - arr:addObject(finish) - local seq0 = CCSequence:create(arr) - local seq1 = tolua.cast(seq0:clone(), "CCAction") - local seq2 = tolua.cast(seq0:clone(), "CCAction") - local seq3 = tolua.cast(seq0:clone(), "CCAction") + local finish = cc.CallFunc:create(removeSprite) + local seq0 = cc.Sequence:create(move, rotate, scale, opacity, fadein, scaleback, finish) + local seq1 = tolua.cast(seq0:clone(), "Action") + local seq2 = tolua.cast(seq0:clone(), "Action") + local seq3 = tolua.cast(seq0:clone(), "Action") tile0:runAction(seq0) tile1:runAction(seq1) @@ -411,7 +400,7 @@ local function TMXReadWriteTest() tile3:runAction(seq3) - m_gid = layer:getTileGIDAt(CCPoint(0,63)) + m_gid = layer:getTileGIDAt(cc.p(0,63)) --------cclog("Tile GID at:(0,63) is: %d", m_gid) local updateColScheduler = nil local repainWithGIDScheduler = nil @@ -419,8 +408,8 @@ local function TMXReadWriteTest() local function updateCol(dt) - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "CCTMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") --------cclog("++++atlas quantity: %d", layer:textureAtlas():getTotalQuads()) --------cclog("++++children: %d", layer:getChildren():count() ) @@ -429,7 +418,7 @@ local function TMXReadWriteTest() local s = layer:getLayerSize() local y = 0 for y=0, s.height-1, 1 do - layer:setTileGID(m_gid2, CCPoint(3, y)) + layer:setTileGID(m_gid2, cc.p(3, y)) end m_gid2 = (m_gid2 + 1) % 80 @@ -437,27 +426,27 @@ local function TMXReadWriteTest() local function repaintWithGID(dt) -- unschedule:_cmd) - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "CCTMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") local s = layer:getLayerSize() local x = 0 for x=0, s.width-1, 1 do local y = s.height-1 - local tmpgid = layer:getTileGIDAt( CCPoint(x, y) ) - layer:setTileGID(tmpgid+1, CCPoint(x, y)) + local tmpgid = layer:getTileGIDAt( cc.p(x, y) ) + layer:setTileGID(tmpgid+1, cc.p(x, y)) end end local function removeTiles(dt) scheduler:unscheduleScriptEntry(removeTilesScheduler) removeTilesScheduler = nil - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "CCTMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") local s = layer:getLayerSize() local y = 0 for y=0, s.height-1, 1 do - layer:removeTileAt( CCPoint(5.0, y) ) + layer:removeTileAt( cc.p(5.0, y) ) end end @@ -498,10 +487,10 @@ end -------------------------------------------------------------------- local function TMXHexTest() local ret = createTileDemoLayer("TMX Hex tes") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/hexa-test.tmx") + local map = cc.TMXTiledMap:create("TileMaps/hexa-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -516,16 +505,16 @@ end -------------------------------------------------------------------- local function TMXIsoTest() local ret = createTileDemoLayer("TMX Isometric test 0") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/iso-test.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test.tmx") ret:addChild(map, 0, kTagTileMap) -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction( CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ) + map:runAction( cc.MoveTo:create(1.0, cc.p( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ) return ret end @@ -536,16 +525,16 @@ end -------------------------------------------------------------------- local function TMXIsoTest1() local ret = createTileDemoLayer("TMX Isometric test + anchorPoint") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/iso-test1.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test1.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - map:setAnchorPoint(CCPoint(0.5, 0.5)) + map:setAnchorPoint(cc.p(0.5, 0.5)) return ret end @@ -556,10 +545,10 @@ end -------------------------------------------------------------------- local function TMXIsoTest2() local ret = createTileDemoLayer("TMX Isometric test 2") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/iso-test2.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test2.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -568,7 +557,7 @@ local function TMXIsoTest2() -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction( CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) + map:runAction( cc.MoveTo:create(1.0, cc.p( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) return ret end @@ -579,10 +568,10 @@ end -------------------------------------------------------------------- local function TMXUncompressedTest() local ret = createTileDemoLayer("TMX Uncompressed test") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/iso-test2-uncompressed.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test2-uncompressed.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -591,15 +580,15 @@ local function TMXUncompressedTest() -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction(CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) + map:runAction(cc.MoveTo:create(1.0, cc.p( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) -- testing release map local pChildrenArray = map:getChildren() local layer = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - layer = tolua.cast(pChildrenArray:objectAtIndex(i), "CCTMXLayer") + layer = tolua.cast(pChildrenArray[i + 1], "TMXLayer") if layer == nil then break end @@ -615,7 +604,7 @@ end -------------------------------------------------------------------- local function TMXTilesetTest() local ret = createTileDemoLayer("TMX Tileset test") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test5.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test5.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -639,7 +628,7 @@ end -------------------------------------------------------------------- local function TMXOrthoObjectsTest() local ret = createTileDemoLayer("TMX Ortho object test", "You should see a white box around the 3 platforms") - local map = CCTMXTiledMap:create("TileMaps/ortho-objects.tmx") + local map = cc.TMXTiledMap:create("TileMaps/ortho-objects.tmx") ret:addChild(map, -1, kTagTileMap) local s = map:getContentSize() @@ -651,10 +640,10 @@ local function TMXOrthoObjectsTest() local dict = nil local i = 0 - local len = objects:count() + local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary") + dict = objects[i + 1] if dict == nil then break @@ -670,35 +659,35 @@ end local function draw() - local map = tolua.cast(getChildByTag(kTagTileMap), "CCTMXTiledMap") + local map = tolua.cast(getChildByTag(kTagTileMap), "TMXTiledMap") local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() local dict = nil local i = 0 - local len = objects:count() + local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary") + dict = objects[i + 1] if dict == nil then break end local key = "x" - local x = (tolua.cast(dict:objectForKey(key), "CCString")):intValue() + local x = dict["x"] key = "y" - local y = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("y")):getNumber() + local y = dict["y"]--dynamic_cast(dict:objectForKey("y")):getNumber() key = "width" - local width = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("width")):getNumber() + local width = dict["width"]--dynamic_cast(dict:objectForKey("width")):getNumber() key = "height" - local height = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("height")):getNumber() + local height = dict["height"]--dynamic_cast(dict:objectForKey("height")):getNumber() glLineWidth(3) - CCDrawPrimitives.ccDrawLine( CCPoint(x, y), CCPoint((x+width), y) ) - CCDrawPrimitives.ccDrawLine( CCPoint((x+width), y), CCPoint((x+width), (y+height)) ) - CCDrawPrimitives.ccDrawLine( CCPoint((x+width), (y+height)), CCPoint(x, (y+height)) ) - CCDrawPrimitives.ccDrawLine( CCPoint(x, (y+height)), CCPoint(x, y) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x, y), cc.p((x+width), y) ) + cc.DrawPrimitives.ccDrawLine( cc.p((x+width), y), cc.p((x+width), (y+height)) ) + cc.DrawPrimitives.ccDrawLine( cc.p((x+width), (y+height)), cc.p(x, (y+height)) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x, (y+height)), cc.p(x, y) ) glLineWidth(1) end @@ -712,7 +701,7 @@ end local function TMXIsoObjectsTest() local ret = createTileDemoLayer("TMX Iso object test", "You need to parse them manually. See bug #810") - local map = CCTMXTiledMap:create("TileMaps/iso-test-objectgroup.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-objectgroup.tmx") ret:addChild(map, -1, kTagTileMap) local s = map:getContentSize() @@ -725,9 +714,9 @@ local function TMXIsoObjectsTest() --UxMutableDictionary* dict local dict = nil local i = 0 - local len = objects:count() + local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary") + dict = tolua.cast(objects[i + 1], "Dictionary") if dict == nil then break @@ -739,35 +728,35 @@ end local function draw() - local map = tolua.cast(getChildByTag(kTagTileMap), "CCTMXTiledMap") + local map = tolua.cast(getChildByTag(kTagTileMap), "TMXTiledMap") local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() local dict = nil local i = 0 - local len = objects:count() + local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary") + dict = tolua.cast(objects[i + 1], "Dictionary") if dict == nil then break end local key = "x" - local x = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("x")):getNumber() + local x = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("x")):getNumber() key = "y" - local y = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("y")):getNumber() + local y = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("y")):getNumber() key = "width" - local width = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("width")):getNumber() + local width = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("width")):getNumber() key = "height" - local height = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("height")):getNumber() + local height = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("height")):getNumber() glLineWidth(3) - CCDrawPrimitives.ccDrawLine( CCPoint(x,y), CCPoint(x+width,y) ) - CCDrawPrimitives.ccDrawLine( CCPoint(x+width,y), CCPoint(x+width,y+height) ) - CCDrawPrimitives.ccDrawLine( CCPoint(x+width,y+height), CCPoint(x,y+height) ) - CCDrawPrimitives.ccDrawLine( CCPoint(x,y+height), CCPoint(x,y) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x,y), cc.p(x+width,y) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x+width,y), cc.p(x+width,y+height) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x+width,y+height), cc.p(x,y+height) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x,y+height), cc.p(x,y) ) glLineWidth(1) end @@ -781,7 +770,7 @@ end local function TMXResizeTest() local ret = createTileDemoLayer("TMX resize test", "Should not crash. Testing issue #740") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test5.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test5.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -793,7 +782,7 @@ local function TMXResizeTest() local y = 0 for y = 0, ls.height-1, 1 do for x = 0, ls.width-1, 1 do - layer:setTileGID(1, CCPoint( x, y ) ) + layer:setTileGID(1, cc.p( x, y ) ) end end return ret @@ -807,31 +796,27 @@ end local function TMXIsoZorder() local m_tamara = nil local ret = createTileDemoLayer("TMX Iso Zorder", "Sprite should hide behind the trees") - local map = CCTMXTiledMap:create("TileMaps/iso-test-zorder.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-zorder.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - map:setPosition(CCPoint(-s.width/2,0)) + map:setPosition(cc.p(-s.width/2,0)) - m_tamara = CCSprite:create(s_pPathSister1) - map:addChild(m_tamara, map:getChildren():count() ) + m_tamara = cc.Sprite:create(s_pPathSister1) + map:addChild(m_tamara, table.getn(map:getChildren())) m_tamara:retain() local mapWidth = map:getMapSize().width * map:getTileSize().width - m_tamara:setPosition(CC_POINT_PIXELS_TO_POINTS(CCPoint( mapWidth/2,0))) - m_tamara:setAnchorPoint(CCPoint(0.5,0)) + m_tamara:setPosition(CC_POINT_PIXELS_TO_POINTS(cc.p( mapWidth/2,0))) + m_tamara:setAnchorPoint(cc.p(0.5,0)) - local move = CCMoveBy:create(10, CCPoint(300,250)) + local move = cc.MoveBy:create(10, cc.p(300,250)) local back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - m_tamara:runAction( CCRepeatForever:create(seq) ) + local seq = cc.Sequence:create(move, back) + m_tamara:runAction( cc.RepeatForever:create(seq) ) local function repositionSprite(dt) - local x,y = m_tamara:getPosition() - local p = CCPoint(x, y) + local p = m_tamara:getPosition() p = CC_POINT_POINTS_TO_PIXELS(p) local map = ret:getChildByTag(kTagTileMap) @@ -871,29 +856,25 @@ end local function TMXOrthoZorder() local m_tamara = nil local ret = createTileDemoLayer("TMX Ortho Zorder", "Sprite should hide behind the trees") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test-zorder.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test-zorder.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - m_tamara = CCSprite:create(s_pPathSister1) - map:addChild(m_tamara, map:getChildren():count()) + m_tamara = cc.Sprite:create(s_pPathSister1) + map:addChild(m_tamara, table.getn(map:getChildren())) m_tamara:retain() - m_tamara:setAnchorPoint(CCPoint(0.5,0)) + m_tamara:setAnchorPoint(cc.p(0.5,0)) - local move = CCMoveBy:create(10, CCPoint(400,450)) + local move = cc.MoveBy:create(10, cc.p(400,450)) local back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - m_tamara:runAction( CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(move, back) + m_tamara:runAction( cc.RepeatForever:create(seq)) local function repositionSprite(dt) - local x, y = m_tamara:getPosition() - local p = CCPoint(x, y) + local p = m_tamara:getPosition() p = CC_POINT_POINTS_TO_PIXELS(p) local map = ret:getChildByTag(kTagTileMap) @@ -933,32 +914,28 @@ end local function TMXIsoVertexZ() local m_tamara = nil local ret = createTileDemoLayer("TMX Iso VertexZ", "Sprite should hide behind the trees") - local map = CCTMXTiledMap:create("TileMaps/iso-test-vertexz.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-vertexz.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() - map:setPosition( CCPoint(-s.width/2,0) ) + map:setPosition( cc.p(-s.width/2,0) ) cclog("ContentSize: %f, %f", s.width,s.height) -- because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you - -- can use any CCSprite and it will work OK. + -- can use any cc.Sprite and it will work OK. local layer = map:getLayer("Trees") - m_tamara = layer:getTileAt( CCPoint(29,29) ) + m_tamara = layer:getTileAt( cc.p(29,29) ) m_tamara:retain() - local move = CCMoveBy:create(10, CCPoint.__mul( CCPoint(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) ) + local move = cc.MoveBy:create(10, cc.pMul( cc.p(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) ) local back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - m_tamara:runAction( CCRepeatForever:create(seq) ) + local seq = cc.Sequence:create(move, back) + m_tamara:runAction( cc.RepeatForever:create(seq) ) local function repositionSprite(dt) -- tile height is 64x32 -- map size: 30x30 - local x, y = m_tamara:getPosition() - local p = CCPoint(x, y) + local p = m_tamara:getPosition() p = CC_POINT_POINTS_TO_PIXELS(p) local newZ = -(p.y+32) /16 m_tamara:setVertexZ( newZ ) @@ -968,11 +945,11 @@ local function TMXIsoVertexZ() local function onNodeEvent(event) if event == "enter" then -- TIP: 2d projection should be used - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D ) schedulerEntry = scheduler:scheduleScriptFunc(repositionSprite, 0, false) elseif event == "exit" then -- At exit use any other projection. - -- CCDirector:getInstance():setProjection:kCCDirectorProjection3D) + -- cc.Director:getInstance():setProjection:cc.DIRECTOR_PROJECTION3_D ) if m_tamara ~= nil then m_tamara:release() @@ -993,32 +970,28 @@ end local function TMXOrthoVertexZ() local m_tamara = nil local ret = createTileDemoLayer("TMX Ortho vertexZ", "Sprite should hide behind the trees") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test-vertexz.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test-vertexz.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) -- because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you - -- can use any CCSprite and it will work OK. + -- can use any cc.Sprite and it will work OK. local layer = map:getLayer("trees") - m_tamara = layer:getTileAt(CCPoint(0,11)) + m_tamara = layer:getTileAt(cc.p(0,11)) cclog("vertexZ:"..m_tamara:getVertexZ()) m_tamara:retain() - local move = CCMoveBy:create(10, CCPoint.__mul( CCPoint(400,450), 1/CC_CONTENT_SCALE_FACTOR())) + local move = cc.MoveBy:create(10, cc.pMul( cc.p(400,450), 1/CC_CONTENT_SCALE_FACTOR())) local back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - m_tamara:runAction( CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(move, back) + m_tamara:runAction( cc.RepeatForever:create(seq)) local function repositionSprite(dt) -- tile height is 101x81 -- map size: 12x12 - local x, y = m_tamara:getPosition() - local p = CCPoint(x, y) + local p = m_tamara:getPosition() p = CC_POINT_POINTS_TO_PIXELS(p) m_tamara:setVertexZ( -( (p.y+81) /81) ) end @@ -1027,11 +1000,11 @@ local function TMXOrthoVertexZ() local function onNodeEvent(event) if event == "enter" then -- TIP: 2d projection should be used - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D ) schedulerEntry = scheduler:scheduleScriptFunc(repositionSprite, 0, false) elseif event == "exit" then -- At exit use any other projection. - -- CCDirector:getInstance():setProjection:kCCDirectorProjection3D) + -- cc.Director:getInstance():setProjection:cc.DIRECTOR_PROJECTION3_D ) if m_tamara ~= nil then m_tamara:release() end @@ -1049,10 +1022,10 @@ end -------------------------------------------------------------------- local function TMXIsoMoveLayer() local ret = createTileDemoLayer("TMX Iso Move Layer", "Trees should be horizontally aligned") - local map = CCTMXTiledMap:create("TileMaps/iso-test-movelayer.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-movelayer.tmx") ret:addChild(map, 0, kTagTileMap) - map:setPosition(CCPoint(-700,-50)) + map:setPosition(cc.p(-700,-50)) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) @@ -1067,7 +1040,7 @@ end -------------------------------------------------------------------- local function TMXOrthoMoveLayer() local ret = createTileDemoLayer("TMX Ortho Move Layer", "Trees should be horizontally aligned") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test-movelayer.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test-movelayer.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -1083,7 +1056,7 @@ end local function TMXTilePropertyTest() local ret = createTileDemoLayer("TMX Tile Property Test", "In the console you should see tile properties") - local map = CCTMXTiledMap:create("TileMaps/ortho-tile-property.tmx") + local map = cc.TMXTiledMap:create("TileMaps/ortho-tile-property.tmx") ret:addChild(map ,0 ,kTagTileMap) local i = 0 for i=1, 20, 1 do @@ -1100,19 +1073,19 @@ end local function TMXOrthoFlipTest() local ret = createTileDemoLayer("TMX tile flip test") - local map = CCTMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") + local map = cc.TMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) local i = 0 - for i = 0, map:getChildren():count()-1, 1 do - local child = tolua.cast(map:getChildren():objectAtIndex(i), "CCSpriteBatchNode") + for i = 0, table.getn(map:getChildren())-1, 1 do + local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end - local action = CCScaleBy:create(2, 0.5) + local action = cc.ScaleBy:create(2, 0.5) map:runAction(action) return ret end @@ -1125,54 +1098,54 @@ end local function TMXOrthoFlipRunTimeTest() local ret = createTileDemoLayer("TMX tile flip run time test", "in 2 sec bottom left tiles will flip") - local map = CCTMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") + local map = cc.TMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) local i = 0 - for i = 0, map:getChildren():count()-1, 1 do - local child = tolua.cast(map:getChildren():objectAtIndex(i), "CCSpriteBatchNode") + for i = 0, table.getn(map:getChildren())-1, 1 do + local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end - local action = CCScaleBy:create(2, 0.5) + local action = cc.ScaleBy:create(2, 0.5) map:runAction(action) local function flipIt(dt) - -- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") + -- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") -- local layer = map:getLayer("Layer 0") -- --blue diamond - -- local tileCoord = CCPoint(1,10) + -- local tileCoord = cc.p(1,10) -- local flags = 0 -- local GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Vertical - -- if( flags & kCCTMXTileVerticalFlag ) - -- flags &= ~kCCTMXTileVerticalFlag + -- if( flags & kcc.TMXTileVerticalFlag ) + -- flags &= ~kcc.TMXTileVerticalFlag -- else - -- flags |= kCCTMXTileVerticalFlag + -- flags |= kcc.TMXTileVerticalFlag -- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags) - -- tileCoord = CCPoint(1,8) + -- tileCoord = cc.p(1,8) -- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Vertical - -- if( flags & kCCTMXTileVerticalFlag ) - -- flags &= ~kCCTMXTileVerticalFlag + -- if( flags & kcc.TMXTileVerticalFlag ) + -- flags &= ~kcc.TMXTileVerticalFlag -- else - -- flags |= kCCTMXTileVerticalFlag + -- flags |= kcc.TMXTileVerticalFlag -- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags) - -- tileCoord = CCPoint(2,8) + -- tileCoord = cc.p(2,8) -- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Horizontal - -- if( flags & kCCTMXTileHorizontalFlag ) - -- flags &= ~kCCTMXTileHorizontalFlag + -- if( flags & kcc.TMXTileHorizontalFlag ) + -- flags &= ~kcc.TMXTileHorizontalFlag -- else - -- flags |= kCCTMXTileHorizontalFlag + -- flags |= kcc.TMXTileHorizontalFlag -- layer:setTileGID(GID, tileCoord, (ccTMXTileFlags)flags) end local schedulerEntry = nil @@ -1198,26 +1171,26 @@ local function TMXOrthoFromXMLTest() local resources = "TileMaps" -- partial paths are OK as resource paths. local file = resources.."/orthogonal-test1.tmx" - local str = CCString:createWithContentsOfFile(CCFileUtils:getInstance():fullPathForFilename(file)):getCString() - -- CCASSERT(str != NULL, "Unable to open file") + local str = cc.FileUtils:getInstance():getStringFromFile(file) + -- cc.ASSERT(str != NULL, "Unable to open file") if (str == nil) then cclog("Unable to open file") end - local map = CCTMXTiledMap:createWithXML(str ,resources) + local map = cc.TMXTiledMap:createWithXML(str ,resources) ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) local i = 0 - local len = map:getChildren():count() + local len = table.getn(map:getChildren()) for i = 0, len-1, 1 do - local child = tolua.cast(map:getChildren():objectAtIndex(i), "CCSpriteBatchNode") + local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end - local action = CCScaleBy:create(2, 0.5) + local action = cc.ScaleBy:create(2, 0.5) map:runAction(action) return ret end @@ -1229,7 +1202,7 @@ end -------------------------------------------------------------------- local function TMXBug987() local ret = createTileDemoLayer("TMX Bug 987", "You should see an square") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test6.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test6.tmx") ret:addChild(map, 0, kTagTileMap) local s1 = map:getContentSize() @@ -1238,19 +1211,19 @@ local function TMXBug987() local childs = map:getChildren() local i = 0 - local len = childs:count() + local len = table.getn(childs) local pNode = nil for i = 0, len-1, 1 do - pNode = tolua.cast(childs:objectAtIndex(i), "CCTMXLayer") + pNode = tolua.cast(childs[i + 1], "TMXLayer") if pNode == nil then break end pNode:getTexture():setAntiAliasTexParameters() end - map:setAnchorPoint(CCPoint(0, 0)) + map:setAnchorPoint(cc.p(0, 0)) local layer = map:getLayer("Tile Layer 1") - layer:setTileGID(3, CCPoint(2,2)) + layer:setTileGID(3, cc.p(2,2)) return ret end @@ -1261,7 +1234,7 @@ end -------------------------------------------------------------------- local function TMXBug787() local ret = createTileDemoLayer("TMX Bug 787", "You should see a map") - local map = CCTMXTiledMap:create("TileMaps/iso-test-bug787.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-bug787.tmx") ret:addChild(map, 0, kTagTileMap) map:setScale(0.25) return ret @@ -1270,8 +1243,8 @@ end function TileMapTestMain() cclog("TileMapTestMain") Helper.index = 1 - CCDirector:getInstance():setDepthTest(true) - local scene = CCScene:create() + cc.Director:getInstance():setDepthTest(true) + local scene = cc.Scene:create() Helper.createFunctionTable = { TileMapTest, diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua index e970a286f0..06c967b2a6 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua @@ -4,12 +4,12 @@ require "luaScript/VisibleRect" require "luaScript/TouchesTest/Paddle" Ball = class("Ball", function(texture) - return CCSprite:createWithTexture(texture) + return cc.Sprite:createWithTexture(texture) end) Ball.__index = Ball -Ball.m_velocity = CCPoint(0,0) +Ball.m_velocity = cc.p(0,0) local M_PI = 3.1415926 @@ -19,56 +19,56 @@ function Ball:radius() end function Ball:move(delta) - local getPosition = CCPoint(self:getPosition()) - local position = CCPoint.__mul(self.m_velocity, delta) - self:setPosition( CCPoint.__add(getPosition, position) ); + local getPosition = cc.p(self:getPosition()) + local position = cc.pMul(self.m_velocity, delta) + self:setPosition( cc.pAdd(getPosition, position) ) if (getPosition.x > VisibleRect:right().x - self:radius()) then - self:setPosition( CCPoint( VisibleRect:right().x - self:radius(), getPosition.y) ); - self.m_velocity.x = self.m_velocity.x * -1; + self:setPosition( cc.p( VisibleRect:right().x - self:radius(), getPosition.y) ) + self.m_velocity.x = self.m_velocity.x * -1 elseif (getPosition.x < VisibleRect:left().x + self:radius()) then - self:setPosition( CCPoint(VisibleRect:left().x + self:radius(), getPosition.y) ); - self.m_velocity.x = self.m_velocity.x * -1; + self:setPosition( cc.p(VisibleRect:left().x + self:radius(), getPosition.y) ) + self.m_velocity.x = self.m_velocity.x * -1 end end function Ball:collideWithPaddle(paddle) local paddleRect = paddle:rect() - local paddleGetPosition = CCPoint(paddle:getPosition()) - local selfGetPosition = CCPoint(self:getPosition()) + local paddleGetPosition = cc.p(paddle:getPosition()) + local selfGetPosition = cc.p(self:getPosition()) - paddleRect.origin.x = paddleRect.origin.x + paddleGetPosition.x; - paddleRect.origin.y = paddleRect.origin.y + paddleGetPosition.y; + paddleRect.x = paddleRect.x + paddleGetPosition.x + paddleRect.y = paddleRect.y + paddleGetPosition.y - local lowY = paddleRect:getMinY(); - local midY = paddleRect:getMidY(); - local highY = paddleRect:getMaxY(); + local lowY = cc.rectGetMinY(paddleRect) + local midY = cc.rectGetMidY(paddleRect) + local highY = cc.rectGetMaxY(paddleRect) - local leftX = paddleRect:getMinX(); - local rightX = paddleRect:getMaxX(); + local leftX = cc.rectGetMinX(paddleRect) + local rightX = cc.rectGetMaxX(paddleRect) if (selfGetPosition.x > leftX and selfGetPosition.x < rightX) then - local hit = false; - local angleOffset = 0.0; + local hit = false + local angleOffset = 0.0 if (selfGetPosition.y > midY and selfGetPosition.y <= highY + self:radius()) then - self:setPosition( CCPoint(selfGetPosition.x, highY + self:radius()) ); - hit = true; - angleOffset = M_PI / 2; + self:setPosition( cc.p(selfGetPosition.x, highY + self:radius()) ) + hit = true + angleOffset = M_PI / 2 elseif (selfGetPosition.y < midY and selfGetPosition.y >= lowY - self:radius()) then - self:setPosition( CCPoint(selfGetPosition.x, lowY - self:radius()) ); - hit = true; - angleOffset = -M_PI / 2; + self:setPosition( cc.p(selfGetPosition.x, lowY - self:radius()) ) + hit = true + angleOffset = -M_PI / 2 end if (hit) then - local hitAngle = (CCPoint.__sub(paddleGetPosition, paddleGetPosition)):getAngle() + angleOffset; + local hitAngle = cc.pToAngleSelf(cc.pSub(paddleGetPosition, paddleGetPosition)) + angleOffset - local scalarVelocity = (self.m_velocity):getLength() * 1.05; - local velocityAngle = -(self.m_velocity):getAngle() + 0.5 * hitAngle; + local scalarVelocity = cc.pGetLength(self.m_velocity) * 1.05 + local velocityAngle = -cc.pToAngleSelf(self.m_velocity) + 0.5 * hitAngle - self.m_velocity = CCPoint.__mul(CCPoint:forAngle(velocityAngle), scalarVelocity); + self.m_velocity = cc.pMul(cc.pForAngle(velocityAngle), scalarVelocity) end end @@ -89,7 +89,7 @@ function Ball.ballWithTexture(aTexture) end local ball = Ball.new(aTexture) - ball:autorelease() + --ball:autorelease() return ball end diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua index ebbadec579..050d587ed5 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua @@ -2,7 +2,7 @@ require "luaScript/extern" require "luaScript/VisibleRect" Paddle = class("Paddle", function(texture) - return CCSprite:createWithTexture(texture) + return cc.Sprite:createWithTexture(texture) end) Paddle.__index = Paddle @@ -15,14 +15,14 @@ Paddle.m_state = kPaddleStateGrabbed function Paddle:rect() local s = self:getTexture():getContentSize() - return CCRect(-s.width / 2, -s.height / 2, s.width, s.height) + return cc.rect(-s.width / 2, -s.height / 2, s.width, s.height) end function Paddle:containsTouchLocation(x,y) - local position = CCPoint(self:getPosition()) + local position = cc.p(self:getPosition()) local s = self:getTexture():getContentSize() - local touchRect = CCRect(-s.width / 2 + position.x, -s.height / 2 + position.y, s.width, s.height) - local b = touchRect:containsPoint(CCPoint(x,y)) + local touchRect = cc.rect(-s.width / 2 + position.x, -s.height / 2 + position.y, s.width, s.height) + local b = cc.rectContainsPoint(touchRect, cc.p(x,y)) return b end @@ -36,7 +36,7 @@ function Paddle:ccTouchBegan(x, y) end function Paddle:ccTouchMoved(x, y) - self:setPosition( CCPoint(x,y) ); + self:setPosition( cc.p(x,y) ); end function Paddle:ccTouchEnded(x, y) diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua index 48b6de4098..085de21ebe 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua @@ -16,14 +16,14 @@ local m_paddles = {} local layer = nil local function backCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function resetAndScoreBallForPlayer(player) - m_ballStartingVelocity = CCPoint.__mul(m_ballStartingVelocity, -1.1); + m_ballStartingVelocity = cc.pMul(m_ballStartingVelocity, -1.1); m_ball:setVelocity( m_ballStartingVelocity ); m_ball:setPosition( VisibleRect:center() ); end @@ -39,7 +39,7 @@ local function doStep(delta) m_ball:collideWithPaddle( paddle ); end - local ballPosition = CCPoint(m_ball:getPosition()) + local ballPosition = cc.p(m_ball:getPosition()) if (ballPosition.y > VisibleRect:top().y - kStatusBarHeight + m_ball:radius()) then resetAndScoreBallForPlayer( kLowPlayer ); elseif (ballPosition.y < VisibleRect:bottom().y-m_ball:radius()) then @@ -60,10 +60,10 @@ local function onTouch(event, x, y) end local function CreateTouchesLayer() - layer = CCLayer:create() + layer = cc.Layer:create() - m_ballStartingVelocity = CCPoint(20.0, -100.0); - local mgr = CCTextureCache:getInstance() + m_ballStartingVelocity = cc.p(20.0, -100.0); + local mgr = cc.TextureCache:getInstance() local texture = mgr:addImage(s_Ball) m_ball = Ball.ballWithTexture(texture); @@ -72,24 +72,24 @@ local function CreateTouchesLayer() layer:addChild( m_ball ); m_ball:retain(); - local paddleTexture = CCTextureCache:getInstance():addImage(s_Paddle); + local paddleTexture = cc.TextureCache:getInstance():addImage(s_Paddle); local paddlesM = {} local paddle = Paddle:paddleWithTexture(paddleTexture); - paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:bottom().y + 15) ); + paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:bottom().y + 15) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 15) ); + paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 15) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:bottom().y + 100) ); + paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:bottom().y + 100) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 100) ); + paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 100) ); paddlesM[#paddlesM+1] = paddle m_paddles = paddlesM @@ -117,7 +117,7 @@ local function nextAction() end function TouchesTest() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(nextAction()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua b/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua index 3f659a9fa2..bb9bb8692f 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua @@ -4,7 +4,7 @@ require "luaScript/TransitionsTest/TransitionsName" local SceneIdx = -1 local CurSceneNo = 2 local TRANSITION_DURATION = 1.2 -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() local function switchSceneTypeNo() if CurSceneNo == 1 then @@ -38,56 +38,56 @@ end local function backCallback(sender) local scene = backAction() - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function restartCallback(sender) local scene = restartAction() - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function nextCallback(sender) local scene = nextAction() - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end ----------------------------- -- TestLayer1 ----------------------------- local function createLayer1() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y = s.width, s.height - local bg1 = CCSprite:create(s_back1) - bg1:setPosition(CCPoint(s.width / 2, s.height / 2)) + local bg1 = cc.Sprite:create(s_back1) + bg1:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) - local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32) + local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32) layer:addChild(titleLabel) - titleLabel:setColor(Color3B(255,32,32)) + titleLabel:setColor(cc.c3b(255,32,32)) titleLabel:setPosition(x / 2, y - 100) - local label = CCLabelTTF:create("SCENE 1", "Marker Felt", 38) - label:setColor(Color3B(16,16,255)) + local label = cc.LabelTTF:create("SCENE 1", "Marker Felt", 38) + label:setColor(cc.c3b(16,16,255)) label:setPosition(x / 2, y / 2) layer:addChild(label) -- menu - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPoint(0, 0)) - item1:setPosition(CCPoint(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(s.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(cc.p(0, 0)) + item1:setPosition(cc.p(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(s.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) layer:addChild(menu, 1) @@ -98,39 +98,39 @@ end -- TestLayer2 ----------------------------- local function createLayer2() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y = s.width, s.height - local bg1 = CCSprite:create(s_back2) - bg1:setPosition(CCPoint(s.width / 2, s.height / 2)) + local bg1 = cc.Sprite:create(s_back2) + bg1:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) - local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 ) + local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 ) layer:addChild(titleLabel) - titleLabel:setColor(Color3B(255,32,32)) + titleLabel:setColor(cc.c3b(255,32,32)) titleLabel:setPosition(x / 2, y - 100) - local label = CCLabelTTF:create("SCENE 2", "Marker Felt", 38) - label:setColor(Color3B(16,16,255)) + local label = cc.LabelTTF:create("SCENE 2", "Marker Felt", 38) + label:setColor(cc.c3b(16,16,255)) label:setPosition(x / 2, y / 2) layer:addChild(label) -- menu - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPoint(0, 0)) - item1:setPosition(CCPoint(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(s.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(cc.p(0, 0)) + item1:setPosition(cc.p(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(s.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) layer:addChild(menu, 1) @@ -141,7 +141,7 @@ end -- Create Transition Test ----------------------------- local function createTransition(index, t, scene) - CCDirector:getInstance():setDepthTest(false) + cc.Director:getInstance():setDepthTest(false) if firstEnter == true then firstEnter = false @@ -149,96 +149,96 @@ local function createTransition(index, t, scene) end if index == Transition_Table.CCTransitionJumpZoom then - scene = CCTransitionJumpZoom:create(t, scene) + scene = cc.TransitionJumpZoom:create(t, scene) elseif index == Transition_Table.CCTransitionProgressRadialCCW then - scene = CCTransitionProgressRadialCCW:create(t, scene) + scene = cc.TransitionProgressRadialCCW:create(t, scene) elseif index == Transition_Table.CCTransitionProgressRadialCW then - scene = CCTransitionProgressRadialCW:create(t, scene) + scene = cc.TransitionProgressRadialCW:create(t, scene) elseif index == Transition_Table.CCTransitionProgressHorizontal then - scene = CCTransitionProgressHorizontal:create(t, scene) + scene = cc.TransitionProgressHorizontal:create(t, scene) elseif index == Transition_Table.CCTransitionProgressVertical then - scene = CCTransitionProgressVertical:create(t, scene) + scene = cc.TransitionProgressVertical:create(t, scene) elseif index == Transition_Table.CCTransitionProgressInOut then - scene = CCTransitionProgressInOut:create(t, scene) + scene = cc.TransitionProgressInOut:create(t, scene) elseif index == Transition_Table.CCTransitionProgressOutIn then - scene = CCTransitionProgressOutIn:create(t, scene) + scene = cc.TransitionProgressOutIn:create(t, scene) elseif index == Transition_Table.CCTransitionCrossFade then - scene = CCTransitionCrossFade:create(t, scene) + scene = cc.TransitionCrossFade:create(t, scene) elseif index == Transition_Table.TransitionPageForward then - CCDirector:getInstance():setDepthTest(true) - scene = CCTransitionPageTurn:create(t, scene, false) + cc.Director:getInstance():setDepthTest(true) + scene = cc.TransitionPageTurn:create(t, scene, false) elseif index == Transition_Table.TransitionPageBackward then - CCDirector:getInstance():setDepthTest(true) - scene = CCTransitionPageTurn:create(t, scene, true) + cc.Director:getInstance():setDepthTest(true) + scene = cc.TransitionPageTurn:create(t, scene, true) elseif index == Transition_Table.CCTransitionFadeTR then - scene = CCTransitionFadeTR:create(t, scene) + scene = cc.TransitionFadeTR:create(t, scene) elseif index == Transition_Table.CCTransitionFadeBL then - scene = CCTransitionFadeBL:create(t, scene) + scene = cc.TransitionFadeBL:create(t, scene) elseif index == Transition_Table.CCTransitionFadeUp then - scene = CCTransitionFadeUp:create(t, scene) + scene = cc.TransitionFadeUp:create(t, scene) elseif index == Transition_Table.CCTransitionFadeDown then - scene = CCTransitionFadeDown:create(t, scene) + scene = cc.TransitionFadeDown:create(t, scene) elseif index == Transition_Table.CCTransitionTurnOffTiles then - scene = CCTransitionTurnOffTiles:create(t, scene) + scene = cc.TransitionTurnOffTiles:create(t, scene) elseif index == Transition_Table.CCTransitionSplitRows then - scene = CCTransitionSplitRows:create(t, scene) + scene = cc.TransitionSplitRows:create(t, scene) elseif index == Transition_Table.CCTransitionSplitCols then - scene = CCTransitionSplitCols:create(t, scene) + scene = cc.TransitionSplitCols:create(t, scene) elseif index == Transition_Table.CCTransitionFade then - scene = CCTransitionFade:create(t, scene) + scene = cc.TransitionFade:create(t, scene) elseif index == Transition_Table.FadeWhiteTransition then - scene = CCTransitionFade:create(t, scene, Color3B(255, 255, 255)) + scene = cc.TransitionFade:create(t, scene, cc.c3b(255, 255, 255)) elseif index == Transition_Table.FlipXLeftOver then - scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationLeftOver) + scene = cc.TransitionFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER ) elseif index == Transition_Table.FlipXRightOver then - scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationRightOver) + scene = cc.TransitionFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER ) elseif index == Transition_Table.FlipYUpOver then - scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationUpOver) + scene = cc.TransitionFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_UP_OVER) elseif index == Transition_Table.FlipYDownOver then - scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationDownOver) + scene = cc.TransitionFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_DOWN_OVER ) elseif index == Transition_Table.FlipAngularLeftOver then - scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver) + scene = cc.TransitionFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER ) elseif index == Transition_Table.FlipAngularRightOver then - scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationRightOver) + scene = cc.TransitionFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER ) elseif index == Transition_Table.ZoomFlipXLeftOver then - scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationLeftOver) + scene = cc.TransitionZoomFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER ) elseif index == Transition_Table.ZoomFlipXRightOver then - scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationRightOver) + scene = cc.TransitionZoomFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER ) elseif index == Transition_Table.ZoomFlipYUpOver then - scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationUpOver) + scene = cc.TransitionZoomFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_UP_OVER) elseif index == Transition_Table.ZoomFlipYDownOver then - scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationDownOver) + scene = cc.TransitionZoomFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_DOWN_OVER ) elseif index == Transition_Table.ZoomFlipAngularLeftOver then - scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver) + scene = cc.TransitionZoomFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER ) elseif index == Transition_Table.ZoomFlipAngularRightOver then - scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationRightOver) + scene = cc.TransitionZoomFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER ) elseif index == Transition_Table.CCTransitionShrinkGrow then - scene = CCTransitionShrinkGrow:create(t, scene) + scene = cc.TransitionShrinkGrow:create(t, scene) elseif index == Transition_Table.CCTransitionRotoZoom then - scene = CCTransitionRotoZoom:create(t, scene) + scene = cc.TransitionRotoZoom:create(t, scene) elseif index == Transition_Table.CCTransitionMoveInL then - scene = CCTransitionMoveInL:create(t, scene) + scene = cc.TransitionMoveInL:create(t, scene) elseif index == Transition_Table.CCTransitionMoveInR then - scene = CCTransitionMoveInR:create(t, scene) + scene = cc.TransitionMoveInR:create(t, scene) elseif index == Transition_Table.CCTransitionMoveInT then - scene = CCTransitionMoveInT:create(t, scene) + scene = cc.TransitionMoveInT:create(t, scene) elseif index == Transition_Table.CCTransitionMoveInB then - scene = CCTransitionMoveInB:create(t, scene) + scene = cc.TransitionMoveInB:create(t, scene) elseif index == Transition_Table.CCTransitionSlideInL then - scene = CCTransitionSlideInL:create(t, scene) + scene = cc.TransitionSlideInL:create(t, scene) elseif index == Transition_Table.CCTransitionSlideInR then - scene = CCTransitionSlideInR:create(t, scene) + scene = cc.TransitionSlideInR:create(t, scene) elseif index == Transition_Table.CCTransitionSlideInT then - scene = CCTransitionSlideInT:create(t, scene) + scene = cc.TransitionSlideInT:create(t, scene) elseif index == Transition_Table.CCTransitionSlideInB then - scene = CCTransitionSlideInB:create(t, scene) + scene = cc.TransitionSlideInB:create(t, scene) end return scene end function generateTranScene() - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = nil if CurSceneNo == 1 then @@ -255,7 +255,7 @@ end function TransitionsTest() cclog("TransitionsTest") - local scene = CCScene:create() + local scene = cc.Scene:create() SceneIdx = -1 CurSceneNo = 2 diff --git a/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua b/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua index 9a4ad1e713..beab70922e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua @@ -6,62 +6,62 @@ local function doTest() -- set default value - CCUserDefault:getInstance():setStringForKey("string", "value1") - CCUserDefault:getInstance():setIntegerForKey("integer", 10) - CCUserDefault:getInstance():setFloatForKey("float", 2.3) - CCUserDefault:getInstance():setDoubleForKey("double", 2.4) - CCUserDefault:getInstance():setBoolForKey("bool", true) + cc.UserDefault:getInstance():setStringForKey("string", "value1") + cc.UserDefault:getInstance():setIntegerForKey("integer", 10) + cc.UserDefault:getInstance():setFloatForKey("float", 2.3) + cc.UserDefault:getInstance():setDoubleForKey("double", 2.4) + cc.UserDefault:getInstance():setBoolForKey("bool", true) -- print value - local ret = CCUserDefault:getInstance():getStringForKey("string") + local ret = cc.UserDefault:getInstance():getStringForKey("string") cclog("string is %s", ret) - local d = CCUserDefault:getInstance():getDoubleForKey("double") + local d = cc.UserDefault:getInstance():getDoubleForKey("double") cclog("double is %f", d) - local i = CCUserDefault:getInstance():getIntegerForKey("integer") + local i = cc.UserDefault:getInstance():getIntegerForKey("integer") cclog("integer is %d", i) - local f = CCUserDefault:getInstance():getFloatForKey("float") + local f = cc.UserDefault:getInstance():getFloatForKey("float") cclog("float is %f", f) - local b = CCUserDefault:getInstance():getBoolForKey("bool") + local b = cc.UserDefault:getInstance():getBoolForKey("bool") if b == true then cclog("bool is true") else cclog("bool is false") end - --CCUserDefault:getInstance():flush() + --cc.UserDefault:getInstance():flush() cclog("********************** after change value ***********************") -- change the value - CCUserDefault:getInstance():setStringForKey("string", "value2") - CCUserDefault:getInstance():setIntegerForKey("integer", 11) - CCUserDefault:getInstance():setFloatForKey("float", 2.5) - CCUserDefault:getInstance():setDoubleForKey("double", 2.6) - CCUserDefault:getInstance():setBoolForKey("bool", false) + cc.UserDefault:getInstance():setStringForKey("string", "value2") + cc.UserDefault:getInstance():setIntegerForKey("integer", 11) + cc.UserDefault:getInstance():setFloatForKey("float", 2.5) + cc.UserDefault:getInstance():setDoubleForKey("double", 2.6) + cc.UserDefault:getInstance():setBoolForKey("bool", false) - CCUserDefault:getInstance():flush() + cc.UserDefault:getInstance():flush() -- print value - ret = CCUserDefault:getInstance():getStringForKey("string") + ret = cc.UserDefault:getInstance():getStringForKey("string") cclog("string is %s", ret) - d = CCUserDefault:getInstance():getDoubleForKey("double") + d = cc.UserDefault:getInstance():getDoubleForKey("double") cclog("double is %f", d) - i = CCUserDefault:getInstance():getIntegerForKey("integer") + i = cc.UserDefault:getInstance():getIntegerForKey("integer") cclog("integer is %d", i) - f = CCUserDefault:getInstance():getFloatForKey("float") + f = cc.UserDefault:getInstance():getFloatForKey("float") cclog("float is %f", f) - b = CCUserDefault:getInstance():getBoolForKey("bool") + b = cc.UserDefault:getInstance():getBoolForKey("bool") if b == true then cclog("bool is true") else @@ -70,11 +70,11 @@ local function doTest() end function UserDefaultTestMain() - local ret = CCScene:create() - local s = CCDirector:getInstance():getWinSize() - local label = CCLabelTTF:create("CCUserDefault test see log", "Arial", 28) + local ret = cc.Scene:create() + local s = cc.Director:getInstance():getWinSize() + local label = cc.LabelTTF:create("UserDefault test see log", "Arial", 28) ret:addChild(label, 0) - label:setPosition( CCPoint(s.width/2, s.height-50) ) + label:setPosition( cc.p(s.width/2, s.height-50) ) doTest() return ret end diff --git a/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua b/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua index e7b6b1710b..a84dbbf085 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua @@ -1,4 +1,4 @@ -local scheduler = CCDirector:getInstance():getScheduler() +local scheduler = cc.Director:getInstance():getScheduler() -------------------------------------------------------------------- -- -- ZwoptexGenericTest @@ -9,33 +9,33 @@ local function ZwoptexGenericTest() "Coordinate Formats, Rotation, Trimming, flipX/Y") local spriteFrameIndex = 0 local counter = 0 - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local schedulerEntry = nil local schedulerFlipSpriteEntry = nil local sprite1 = nil local sprite2 = nil local function onEnter() - CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini.plist") - CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini-generic.plist") + cc.SpriteFrameCache:getInstance():addSpriteFrames("zwoptex/grossini.plist") + cc.SpriteFrameCache:getInstance():addSpriteFrames("zwoptex/grossini-generic.plist") - local layer1 = CCLayerColor:create(Color4B(255, 0, 0, 255), 85, 121) - layer1:setPosition(CCPoint(s.width/2-80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) + local layer1 = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 85, 121) + layer1:setPosition(cc.p(s.width/2-80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) ret:addChild(layer1) - sprite1 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName("grossini_dance_01.png")) - sprite1:setPosition(CCPoint( s.width/2-80, s.height/2)) + sprite1 = cc.Sprite:createWithSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame("grossini_dance_01.png")) + sprite1:setPosition(cc.p( s.width/2-80, s.height/2)) ret:addChild(sprite1) sprite1:setFlipX(false) sprite1:setFlipY(false) - local layer2 = CCLayerColor:create(Color4B(255, 0, 0, 255), 85, 121) - layer2:setPosition(CCPoint(s.width/2+80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) + local layer2 = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 85, 121) + layer2:setPosition(cc.p(s.width/2+80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) ret:addChild(layer2) - sprite2 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName("grossini_dance_generic_01.png")) - sprite2:setPosition(CCPoint( s.width/2 + 80, s.height/2)) + sprite2 = cc.Sprite:createWithSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame("grossini_dance_generic_01.png")) + sprite2:setPosition(cc.p( s.width/2 + 80, s.height/2)) ret:addChild(sprite2) sprite2:setFlipX(false) @@ -74,8 +74,8 @@ local function ZwoptexGenericTest() local str1 = string.format("grossini_dance_%02d.png", spriteFrameIndex) local str2 = string.format("grossini_dance_generic_%02d.png", spriteFrameIndex) - sprite1:setDisplayFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName(str1)) - sprite2:setDisplayFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName(str2)) + sprite1:setDisplayFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str1)) + sprite2:setDisplayFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str2)) end sprite1:retain() @@ -97,7 +97,7 @@ local function ZwoptexGenericTest() end sprite1:release() sprite2:release() - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("zwoptex/grossini.plist") cache:removeSpriteFramesFromFile("zwoptex/grossini-generic.plist") end @@ -118,7 +118,7 @@ end function ZwoptexTestMain() cclog("ZwoptexTestMain") Helper.index = 1 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { ZwoptexGenericTest } diff --git a/samples/Lua/TestLua/Resources/luaScript/extern.lua b/samples/Lua/TestLua/Resources/luaScript/extern.lua index 60c03ba54a..172db1a9ed 100644 --- a/samples/Lua/TestLua/Resources/luaScript/extern.lua +++ b/samples/Lua/TestLua/Resources/luaScript/extern.lua @@ -60,16 +60,16 @@ function class(classname, super) end function schedule(node, callback, delay) - local delay = CCDelayTime:create(delay) - local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback)) - local action = CCRepeatForever:create(sequence) + local delay = cc.DelayTime:create(delay) + local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback)) + local action = cc.RepeatForever:create(sequence) node:runAction(action) return action end function performWithDelay(node, callback, delay) - local delay = CCDelayTime:create(delay) - local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback)) + local delay = cc.DelayTime:create(delay) + local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback)) node:runAction(sequence) return sequence end diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index a68bb24f2c..1e2bb48e4f 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -8,6 +8,7 @@ require "luaScript/helper" require "luaScript/testResource" require "luaScript/VisibleRect" +require "luaScript/AccelerometerTest/AccelerometerTest" require "luaScript/ActionManagerTest/ActionManagerTest" require "luaScript/ActionsEaseTest/ActionsEaseTest" require "luaScript/ActionsProgressTest/ActionsProgressTest" @@ -19,35 +20,30 @@ require "luaScript/CurrentLanguageTest/CurrentLanguageTest" require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest" require "luaScript/EffectsTest/EffectsTest" require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest" +require "luaScript/ExtensionTest/ExtensionTest" require "luaScript/FontTest/FontTest" require "luaScript/IntervalTest/IntervalTest" require "luaScript/KeypadTest/KeypadTest" require "luaScript/LabelTest/LabelTest" require "luaScript/LayerTest/LayerTest" - ---[[ -require "luaScript/TransitionsTest/TransitionsTest" -require "luaScript/RotateWorldTest/RotateWorldTest" -require "luaScript/ParticleTest/ParticleTest" +require "luaScript/MenuTest/MenuTest" require "luaScript/MotionStreakTest/MotionStreakTest" require "luaScript/NodeTest/NodeTest" -require "luaScript/TouchesTest/TouchesTest" -require "luaScript/SpriteTest/SpriteTest" - -require "luaScript/PerformanceTest/PerformanceTest" +require "luaScript/OpenGLTest/OpenGLTest" require "luaScript/ParallaxTest/ParallaxTest" -require "luaScript/TileMapTest/TileMapTest" - -require "luaScript/MenuTest/MenuTest" +require "luaScript/ParticleTest/ParticleTest" +require "luaScript/PerformanceTest/PerformanceTest" +require "luaScript/RenderTextureTest/RenderTextureTest" +require "luaScript/RotateWorldTest/RotateWorldTest" +require "luaScript/SpriteTest/SpriteTest" require "luaScript/SceneTest/SceneTest" require "luaScript/Texture2dTest/Texture2dTest" -require "luaScript/RenderTextureTest/RenderTextureTest" -require "luaScript/ZwoptexTest/ZwoptexTest" +require "luaScript/TileMapTest/TileMapTest" +require "luaScript/TouchesTest/TouchesTest" +require "luaScript/TransitionsTest/TransitionsTest" require "luaScript/UserDefaultTest/UserDefaultTest" -require "luaScript/ExtensionTest/ExtensionTest" -require "luaScript/AccelerometerTest/AccelerometerTest" -require "luaScript/OpenGLTest/OpenGLTest" -]]-- +require "luaScript/ZwoptexTest/ZwoptexTest" + local LINE_SPACE = 40 diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index e8ff07d4dc..c342250d9f 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -49,6 +49,7 @@ extern "C" { #include "lua_cocos2dx_auto.hpp" #include "lua_cocos2dx_extension_auto.hpp" #include "lua_cocos2dx_manual.hpp" +#include "LuaBasicConversions.h" namespace { int lua_print(lua_State * luastate) @@ -125,6 +126,7 @@ bool LuaStack::init(void) {NULL, NULL} }; luaL_register(_state, "_G", global_functions); + g_luaType.clear(); register_all_cocos2dx(_state); tolua_opengl_open(_state); register_all_cocos2dx_extension(_state); diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp index e26a3d41df..27b8888883 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp @@ -23,9 +23,16 @@ ****************************************************************************/ #include "LuaBasicConversions.h" + +#ifdef __cplusplus extern "C" { -#include "tolua++.h" +#endif +#include "tolua_fix.h" +#ifdef __cplusplus } +#endif + +std::map g_luaType; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err) @@ -881,6 +888,50 @@ bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints return ok; } + +bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret) +{ + if (nullptr == L || argc == 0 ) + return false; + + bool ok = true; + + Array* array = Array::create(); + for (int i = 0; i < argc; i++) + { + double num = 0.0; + if (lua_isnumber(L, i + 2)) + { + ok &= luaval_to_number(L, i + 2, &num); + if (!ok) + break; + + array->addObject(Integer::create((int)num)); + } + else if (lua_isstring(L, i + 2)) + { + std::string str = lua_tostring(L, i + 2); + array->addObject(String::create(str)); + } + else if (lua_isuserdata(L, i + 2)) + { + tolua_Error err; + if (!tolua_isusertype(L, i + 2, "Object", 0, &err)) + { + luaval_to_native_err(L,"#ferror:",&err); + ok = false; + break; + } + Object* obj = static_cast(tolua_tousertype(L, i + 2, nullptr)); + array->addObject(obj); + } + } + + *ret = array; + + return ok; +} + void point_to_luaval(lua_State* L,const Point& pt) { if (NULL == L) @@ -1064,171 +1115,171 @@ void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue) void array_to_luaval(lua_State* L,Array* inValue) { - if (NULL == L || NULL == inValue) + if (nullptr == L || nullptr == inValue) return; - if (0 == inValue->count() ) - return; - - Object* obj = NULL; + Object* obj = nullptr; lua_newtable(L); std::string className = ""; - int pos = 0; - String* strVal = NULL; - Dictionary* dictVal = NULL; - Array* arrVal = NULL; - Double* doubleVal = NULL; - Bool* boolVal = NULL; - Float* floatVal = NULL; - Integer* intVal = NULL; + String* strVal = nullptr; + Dictionary* dictVal = nullptr; + Array* arrVal = nullptr; + Double* doubleVal = nullptr; + Bool* boolVal = nullptr; + Float* floatVal = nullptr; + Integer* intVal = nullptr; + int indexTable = 1; CCARRAY_FOREACH(inValue, obj) { - if (NULL == obj) + if (nullptr == obj) continue; - className = typeid(*obj).name(); - pos = className.rfind(":"); - if (pos > 0 && pos + 1 < className.length() ) + uint32_t typeId = cocos2d::getHashCodeByString(typeid(*obj).name()); + auto iter = g_luaType.find(typeId); + if (g_luaType.end() != iter) { - className = className.substr(pos + 1, std::string::npos); - - luaL_getmetatable(L, className.c_str()); /* stack: table mt */ - - if (!lua_isnil(L, -1)) + className = iter->second; + if (nullptr != dynamic_cast(obj)) { - lua_pop(L, 1); - tolua_pushusertype(L, (void*)obj, className.c_str()); - } - else - { - lua_pop(L, -1); - if((strVal = dynamic_cast(obj))) - { - lua_pushstring(L, strVal->getCString()); - } - else if ((dictVal = dynamic_cast(obj))) - { - dictionary_to_luaval(L, dictVal); - } - else if ((arrVal = dynamic_cast(obj))) - { - array_to_luaval(L, arrVal); - } - else if ((doubleVal = dynamic_cast(obj))) - { - lua_pushnumber(L, (lua_Number)doubleVal->getValue()); - } - else if ((floatVal = dynamic_cast(obj))) - { - lua_pushnumber(L, (lua_Number)floatVal->getValue()); - } - else if ((intVal = dynamic_cast(obj))) - { - lua_pushinteger(L, (lua_Integer)intVal->getValue()); - } - else if ((boolVal = dynamic_cast(obj))) - { - lua_pushboolean(L, boolVal->getValue()); - } else - { - CCASSERT(false, "the type isn't suppored."); - } + lua_pushnumber(L, (lua_Number)indexTable); + int ID = (obj) ? (int)obj->_ID : -1; + int* luaID = (obj) ? &obj->_luaID : NULL; + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,className.c_str()); + lua_rawset(L, -3); + obj->retain(); + ++indexTable; } } + else if((strVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushstring(L, strVal->getCString()); + lua_rawset(L, -3); + ++indexTable; + } + else if ((dictVal = dynamic_cast(obj))) + { + dictionary_to_luaval(L, dictVal); + } + else if ((arrVal = dynamic_cast(obj))) + { + array_to_luaval(L, arrVal); + } + else if ((doubleVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushnumber(L, (lua_Number)doubleVal->getValue()); + lua_rawset(L, -3); + ++indexTable; + } + else if ((floatVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushnumber(L, (lua_Number)floatVal->getValue()); + lua_rawset(L, -3); + ++indexTable; + } + else if ((intVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushinteger(L, (lua_Integer)intVal->getValue()); + lua_rawset(L, -3); + ++indexTable; + } + else if ((boolVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushboolean(L, boolVal->getValue()); + lua_rawset(L, -3); + ++indexTable; + } + else + { + CCASSERT(false, "the type isn't suppored."); + } } } void dictionary_to_luaval(lua_State* L, Dictionary* dict) { - if (NULL == L || NULL == dict) + if (nullptr == L || nullptr == dict) return; - if (0 == dict->count() ) - return; - - DictElement* element = NULL; + DictElement* element = nullptr; lua_newtable(L); std::string className = ""; - int pos = 0; - String* strVal = NULL; - Dictionary* dictVal = NULL; - Array* arrVal = NULL; - Double* doubleVal = NULL; - Bool* boolVal = NULL; - Float* floatVal = NULL; - Integer* intVal = NULL; - Object* obj = NULL; + String* strVal = nullptr; + Dictionary* dictVal = nullptr; + Array* arrVal = nullptr; + Double* doubleVal = nullptr; + Bool* boolVal = nullptr; + Float* floatVal = nullptr; + Integer* intVal = nullptr; CCDICT_FOREACH(dict, element) { if (NULL == element) continue; - className = typeid(*element).name(); - pos = className.rfind(":"); - if (pos > 0 && pos + 1 < className.length() ) + uint32_t typeId = cocos2d::getHashCodeByString(typeid(element->getObject()).name()); + auto iter = g_luaType.find(typeId); + if (g_luaType.end() != iter) { - obj = element->getObject(); - if (NULL == obj) - continue; - - className = className.substr(pos + 1, std::string::npos); - - luaL_getmetatable(L, className.c_str()); /* stack: table mt */ - if (!lua_isnil(L, -1)) + className = iter->second; + if ( nullptr != dynamic_cast(element->getObject())) { - lua_pop(L, 1); - tolua_pushusertype(L, (void*)obj, className.c_str()); - } - else - { - lua_pop(L, -1); - if((strVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushstring(L, strVal->getCString()); - lua_rawset(L, -3); - } - else if ((dictVal = dynamic_cast(obj))) - { - dictionary_to_luaval(L, dictVal); - } - else if ((arrVal = dynamic_cast(obj))) - { - array_to_luaval(L, arrVal); - } - else if ((doubleVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushnumber(L, (lua_Number)doubleVal->getValue()); - lua_rawset(L, -3); - } - else if ((floatVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushnumber(L, (lua_Number)floatVal->getValue()); - lua_rawset(L, -3); - } - else if ((intVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushinteger(L, (lua_Integer)intVal->getValue()); - lua_rawset(L, -3); - } - else if ((boolVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushboolean(L, boolVal->getValue()); - lua_rawset(L, -3); - } - else - { - CCASSERT(false, "the type isn't suppored."); - } + lua_pushstring(L, element->getStrKey()); + int ID = (element->getObject()) ? (int)element->getObject()->_ID : -1; + int* luaID = (element->getObject()) ? &(element->getObject()->_luaID) : NULL; + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)element->getObject(),className.c_str()); + lua_rawset(L, -3); + element->getObject()->retain(); } } + else if((strVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushstring(L, strVal->getCString()); + lua_rawset(L, -3); + } + else if ((dictVal = dynamic_cast(element->getObject()))) + { + dictionary_to_luaval(L, dictVal); + } + else if ((arrVal = dynamic_cast(element->getObject()))) + { + array_to_luaval(L, arrVal); + } + else if ((doubleVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushnumber(L, (lua_Number)doubleVal->getValue()); + lua_rawset(L, -3); + } + else if ((floatVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushnumber(L, (lua_Number)floatVal->getValue()); + lua_rawset(L, -3); + } + else if ((intVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushinteger(L, (lua_Integer)intVal->getValue()); + lua_rawset(L, -3); + } + else if ((boolVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushboolean(L, boolVal->getValue()); + lua_rawset(L, -3); + } + else + { + CCASSERT(false, "the type isn't suppored."); + } } } diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.h b/scripting/lua/cocos2dx_support/LuaBasicConversions.h index bbd6dca25a..87171e0782 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.h +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.h @@ -3,12 +3,19 @@ extern "C" { #include "lua.h" +#include "tolua++.h" } #include "cocos2d.h" using namespace cocos2d; +extern std::map g_luaType; + +#if COCOS2D_DEBUG >=1 +void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err); +#endif + // to native extern bool luaval_to_int32(lua_State* L,int lo,int* outValue); extern bool luaval_to_uint32(lua_State* L, int lo, unsigned int* outValue); @@ -29,6 +36,7 @@ extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outVa extern bool luaval_to_array(lua_State* L,int lo, Array** outValue); extern bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue); extern bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints); +extern bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret); // from native extern void point_to_luaval(lua_State* L,const Point& pt); diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id index d3e9b8256b..1a95695d30 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -faeffa101e0d6ba77fa19f3bd83b12a267209994 \ No newline at end of file +13bc27135b11b87249075c37897972a41802f216 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index 3199a451d6..58dc858cdf 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -2a962b5abd27e8a47e73534fe2e521e181cc64be \ No newline at end of file +e29ba39a2c542d0e15e41231b795fadbdad66af3 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp index 69abad2a2d..9b672e575f 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp @@ -1982,6 +1982,76 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index 1ac1962780..81938e2d35 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -4b98d069e4cc8f6af4dc2c64c6ec3fa2590bd927 \ No newline at end of file +171d6ef055d78d7211eb55d8a8de5eda09476d0a \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index f01619e02a..627a599501 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -a63246415c81d091a2eb88c4ba396b6d3c80c027 \ No newline at end of file +00379738c9ad94edf867bd46e85597812c340f29 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp index a2f3e2a6d3..727217721f 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp @@ -246,6 +246,143 @@ int register_all_cocos2dx_extension(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js index da9e2d08bd..5b4f3a5b7c 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js @@ -135,6 +135,12 @@ addOwnerOutletName : function () {}, */ getOwnerCallbackNames : function () {}, +/** + * @method addDocumentCallbackControlEvents + * @param {cocos2d::extension::Control::EventType} + */ +addDocumentCallbackControlEvents : function () {}, + /** * @method setCCBRootPath * @param {const char*} @@ -166,6 +172,12 @@ readSoundKeyframesForSeq : function () {}, */ getCCBRootPath : function () {}, +/** + * @method getOwnerCallbackControlEvents + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getOwnerCallbackControlEvents : function () {}, + /** * @method getOwnerOutletNodes * @return A value converted from C/C++ "cocos2d::Array*" @@ -178,6 +190,12 @@ getOwnerOutletNodes : function () {}, */ readUTF8 : function () {}, +/** + * @method addOwnerCallbackControlEvents + * @param {cocos2d::extension::Control::EventType} + */ +addOwnerCallbackControlEvents : function () {}, + /** * @method getOwnerOutletNames * @return A value converted from C/C++ "cocos2d::Array*" @@ -1062,6 +1080,13 @@ getLastCompletedSequenceName : function () {}, */ setRootNode : function () {}, +/** + * @method runAnimationsForSequenceNamedTweenDuration + * @param {const char*} + * @param {float} + */ +runAnimationsForSequenceNamedTweenDuration : function () {}, + /** * @method addDocumentOutletName * @param {std::string} @@ -1106,6 +1131,12 @@ actionForCallbackChannel : function () {}, */ getDocumentOutletNames : function () {}, +/** + * @method addDocumentCallbackControlEvents + * @param {cocos2d::extension::Control::EventType} + */ +addDocumentCallbackControlEvents : function () {}, + /** * @method init * @return A value converted from C/C++ "bool" @@ -1119,11 +1150,10 @@ init : function () {}, getKeyframeCallbacks : function () {}, /** - * @method runAnimationsForSequenceNamedTweenDuration - * @param {const char*} - * @param {float} + * @method getDocumentCallbackControlEvents + * @return A value converted from C/C++ "cocos2d::Array*" */ -runAnimationsForSequenceNamedTweenDuration : function () {}, +getDocumentCallbackControlEvents : function () {}, /** * @method setRootContainerSize @@ -1232,6 +1262,828 @@ CCBAnimationManager : function () {}, }; +/** + * @class ControlHuePicker + */ +cc.ControlHuePicker = { + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method initWithTargetAndPos + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Node*} + * @param {cocos2d::Point} + */ +initWithTargetAndPos : function () {}, + +/** + * @method setHue + * @param {float} + */ +setHue : function () {}, + +/** + * @method getStartPos + * @return A value converted from C/C++ "cocos2d::Point" + */ +getStartPos : function () {}, + +/** + * @method getHue + * @return A value converted from C/C++ "float" + */ +getHue : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method setBackground + * @param {cocos2d::Sprite*} + */ +setBackground : function () {}, + +/** + * @method setHuePercentage + * @param {float} + */ +setHuePercentage : function () {}, + +/** + * @method getBackground + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getBackground : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method getSlider + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getSlider : function () {}, + +/** + * @method getHuePercentage + * @return A value converted from C/C++ "float" + */ +getHuePercentage : function () {}, + +/** + * @method setSlider + * @param {cocos2d::Sprite*} + */ +setSlider : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" + * @param {cocos2d::Node*} + * @param {cocos2d::Point} + */ +create : function () {}, + +/** + * @method ControlHuePicker + * @constructor + */ +ControlHuePicker : function () {}, + +}; + +/** + * @class ControlSaturationBrightnessPicker + */ +cc.ControlSaturationBrightnessPicker = { + +/** + * @method getShadow + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getShadow : function () {}, + +/** + * @method initWithTargetAndPos + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Node*} + * @param {cocos2d::Point} + */ +initWithTargetAndPos : function () {}, + +/** + * @method getStartPos + * @return A value converted from C/C++ "cocos2d::Point" + */ +getStartPos : function () {}, + +/** + * @method getOverlay + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getOverlay : function () {}, + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method getSlider + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getSlider : function () {}, + +/** + * @method getBackground + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getBackground : function () {}, + +/** + * @method getSaturation + * @return A value converted from C/C++ "float" + */ +getSaturation : function () {}, + +/** + * @method getBrightness + * @return A value converted from C/C++ "float" + */ +getBrightness : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" + * @param {cocos2d::Node*} + * @param {cocos2d::Point} + */ +create : function () {}, + +/** + * @method ControlSaturationBrightnessPicker + * @constructor + */ +ControlSaturationBrightnessPicker : function () {}, + +}; + +/** + * @class ControlColourPicker + */ +cc.ControlColourPicker = { + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method getHuePicker + * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" + */ +getHuePicker : function () {}, + +/** + * @method setColor + * @param {cocos2d::Color3B} + */ +setColor : function () {}, + +/** + * @method hueSliderValueChanged + * @param {cocos2d::Object*} + * @param {cocos2d::extension::Control::EventType} + */ +hueSliderValueChanged : function () {}, + +/** + * @method getcolourPicker + * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" + */ +getcolourPicker : function () {}, + +/** + * @method setBackground + * @param {cocos2d::Sprite*} + */ +setBackground : function () {}, + +/** + * @method init + * @return A value converted from C/C++ "bool" + */ +init : function () {}, + +/** + * @method setcolourPicker + * @param {cocos2d::extension::ControlSaturationBrightnessPicker*} + */ +setcolourPicker : function () {}, + +/** + * @method colourSliderValueChanged + * @param {cocos2d::Object*} + * @param {cocos2d::extension::Control::EventType} + */ +colourSliderValueChanged : function () {}, + +/** + * @method setHuePicker + * @param {cocos2d::extension::ControlHuePicker*} + */ +setHuePicker : function () {}, + +/** + * @method getBackground + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getBackground : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlColourPicker*" + */ +create : function () {}, + +/** + * @method ControlColourPicker + * @constructor + */ +ControlColourPicker : function () {}, + +}; + +/** + * @class ControlPotentiometer + */ +cc.ControlPotentiometer = { + +/** + * @method setPreviousLocation + * @param {cocos2d::Point} + */ +setPreviousLocation : function () {}, + +/** + * @method setProgressTimer + * @param {cocos2d::ProgressTimer*} + */ +setProgressTimer : function () {}, + +/** + * @method potentiometerMoved + * @param {cocos2d::Point} + */ +potentiometerMoved : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method getMinimumValue + * @return A value converted from C/C++ "float" + */ +getMinimumValue : function () {}, + +/** + * @method setThumbSprite + * @param {cocos2d::Sprite*} + */ +setThumbSprite : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method setValue + * @param {float} + */ +setValue : function () {}, + +/** + * @method setMaximumValue + * @param {float} + */ +setMaximumValue : function () {}, + +/** + * @method setMinimumValue + * @param {float} + */ +setMinimumValue : function () {}, + +/** + * @method potentiometerEnded + * @param {cocos2d::Point} + */ +potentiometerEnded : function () {}, + +/** + * @method distanceBetweenPointAndPoint + * @return A value converted from C/C++ "float" + * @param {cocos2d::Point} + * @param {cocos2d::Point} + */ +distanceBetweenPointAndPoint : function () {}, + +/** + * @method getProgressTimer + * @return A value converted from C/C++ "cocos2d::ProgressTimer*" + */ +getProgressTimer : function () {}, + +/** + * @method getMaximumValue + * @return A value converted from C/C++ "float" + */ +getMaximumValue : function () {}, + +/** + * @method angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint + * @return A value converted from C/C++ "float" + * @param {cocos2d::Point} + * @param {cocos2d::Point} + * @param {cocos2d::Point} + * @param {cocos2d::Point} + */ +angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : function () {}, + +/** + * @method isTouchInside + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + */ +isTouchInside : function () {}, + +/** + * @method getValue + * @return A value converted from C/C++ "float" + */ +getValue : function () {}, + +/** + * @method potentiometerBegan + * @param {cocos2d::Point} + */ +potentiometerBegan : function () {}, + +/** + * @method getThumbSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getThumbSprite : function () {}, + +/** + * @method initWithTrackSprite_ProgressTimer_ThumbSprite + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Sprite*} + * @param {cocos2d::ProgressTimer*} + * @param {cocos2d::Sprite*} + */ +initWithTrackSprite_ProgressTimer_ThumbSprite : function () {}, + +/** + * @method getPreviousLocation + * @return A value converted from C/C++ "cocos2d::Point" + */ +getPreviousLocation : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlPotentiometer*" + * @param {const char*} + * @param {const char*} + * @param {const char*} + */ +create : function () {}, + +/** + * @method ControlPotentiometer + * @constructor + */ +ControlPotentiometer : function () {}, + +}; + +/** + * @class ControlSlider + */ +cc.ControlSlider = { + +/** + * @method locationFromTouch + * @return A value converted from C/C++ "cocos2d::Point" + * @param {cocos2d::Touch*} + */ +locationFromTouch : function () {}, + +/** + * @method setProgressSprite + * @param {cocos2d::Sprite*} + */ +setProgressSprite : function () {}, + +/** + * @method getMaximumAllowedValue + * @return A value converted from C/C++ "float" + */ +getMaximumAllowedValue : function () {}, + +/** + * @method getMinimumAllowedValue + * @return A value converted from C/C++ "float" + */ +getMinimumAllowedValue : function () {}, + +/** + * @method getMinimumValue + * @return A value converted from C/C++ "float" + */ +getMinimumValue : function () {}, + +/** + * @method setThumbSprite + * @param {cocos2d::Sprite*} + */ +setThumbSprite : function () {}, + +/** + * @method setMinimumValue + * @param {float} + */ +setMinimumValue : function () {}, + +/** + * @method setMinimumAllowedValue + * @param {float} + */ +setMinimumAllowedValue : function () {}, + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method setValue + * @param {float} + */ +setValue : function () {}, + +/** + * @method setMaximumValue + * @param {float} + */ +setMaximumValue : function () {}, + +/** + * @method needsLayout + */ +needsLayout : function () {}, + +/** + * @method getBackgroundSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getBackgroundSprite : function () {}, + +/** + * @method initWithSprites + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Sprite*} + * @param {cocos2d::Sprite*} + * @param {cocos2d::Sprite*} + */ +initWithSprites : function () {}, + +/** + * @method getMaximumValue + * @return A value converted from C/C++ "float" + */ +getMaximumValue : function () {}, + +/** + * @method isTouchInside + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + */ +isTouchInside : function () {}, + +/** + * @method getValue + * @return A value converted from C/C++ "float" + */ +getValue : function () {}, + +/** + * @method getThumbSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getThumbSprite : function () {}, + +/** + * @method getProgressSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getProgressSprite : function () {}, + +/** + * @method setBackgroundSprite + * @param {cocos2d::Sprite*} + */ +setBackgroundSprite : function () {}, + +/** + * @method setMaximumAllowedValue + * @param {float} + */ +setMaximumAllowedValue : function () {}, + +/** + * @method ControlSlider + * @constructor + */ +ControlSlider : function () {}, + +}; + +/** + * @class ControlStepper + */ +cc.ControlStepper = { + +/** + * @method setMinusSprite + * @param {cocos2d::Sprite*} + */ +setMinusSprite : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method getMinusLabel + * @return A value converted from C/C++ "cocos2d::LabelTTF*" + */ +getMinusLabel : function () {}, + +/** + * @method setWraps + * @param {bool} + */ +setWraps : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method isContinuous + * @return A value converted from C/C++ "bool" + */ +isContinuous : function () {}, + +/** + * @method getMinusSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getMinusSprite : function () {}, + +/** + * @method updateLayoutUsingTouchLocation + * @param {cocos2d::Point} + */ +updateLayoutUsingTouchLocation : function () {}, + +/** + * @method setValueWithSendingEvent + * @param {double} + * @param {bool} + */ +setValueWithSendingEvent : function () {}, + +/** + * @method getPlusLabel + * @return A value converted from C/C++ "cocos2d::LabelTTF*" + */ +getPlusLabel : function () {}, + +/** + * @method stopAutorepeat + */ +stopAutorepeat : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method setMaximumValue + * @param {double} + */ +setMaximumValue : function () {}, + +/** + * @method setPlusSprite + * @param {cocos2d::Sprite*} + */ +setPlusSprite : function () {}, + +/** + * @method setMinusLabel + * @param {cocos2d::LabelTTF*} + */ +setMinusLabel : function () {}, + +/** + * @method setValue + * @param {double} + */ +setValue : function () {}, + +/** + * @method setStepValue + * @param {double} + */ +setStepValue : function () {}, + +/** + * @method getPlusSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getPlusSprite : function () {}, + +/** + * @method update + * @param {float} + */ +update : function () {}, + +/** + * @method setMinimumValue + * @param {double} + */ +setMinimumValue : function () {}, + +/** + * @method startAutorepeat + */ +startAutorepeat : function () {}, + +/** + * @method initWithMinusSpriteAndPlusSprite + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Sprite*} + * @param {cocos2d::Sprite*} + */ +initWithMinusSpriteAndPlusSprite : function () {}, + +/** + * @method getValue + * @return A value converted from C/C++ "double" + */ +getValue : function () {}, + +/** + * @method setPlusLabel + * @param {cocos2d::LabelTTF*} + */ +setPlusLabel : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlStepper*" + * @param {cocos2d::Sprite*} + * @param {cocos2d::Sprite*} + */ +create : function () {}, + +/** + * @method ControlStepper + * @constructor + */ +ControlStepper : function () {}, + +}; + +/** + * @class ControlSwitch + */ +cc.ControlSwitch = { + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method isOn + * @return A value converted from C/C++ "bool" + */ +isOn : function () {}, + +/** + * @method ccTouchCancelled + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchCancelled : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method hasMoved + * @return A value converted from C/C++ "bool" + */ +hasMoved : function () {}, + +/** + * @method locationFromTouch + * @return A value converted from C/C++ "cocos2d::Point" + * @param {cocos2d::Touch*} + */ +locationFromTouch : function () {}, + +/** + * @method ControlSwitch + * @constructor + */ +ControlSwitch : function () {}, + +}; + /** * @class TableViewCell */ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp index 372407218f..1db8768fb8 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp @@ -291,6 +291,93 @@ tolua_lerror: return 0; } + + +static int tolua_cocos2dx_Menu_alignItemsInRows(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Menu* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_Menu_alignItemsInRows'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (argc > 0) + { + Array* array = NULL; + if (luavals_variadic_to_array(tolua_S, argc, &array)) + { + self->alignItemsInRowsWithArray(array); + } + return 0; + } + + CCLOG("wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInRows: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'alignItemsInRows'.\n",&tolua_err); +#endif + return 0; +} + +static int tolua_cocos2dx_Menu_alignItemsInColumns(lua_State* tolua_S) +{ + + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Menu* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Menu_alignItemsInColumns'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (argc > 0) + { + Array* array = NULL; + if (luavals_variadic_to_array(tolua_S, argc, &array)) + { + self->alignItemsInColumnsWithArray(array); + } + return 0; + } + + CCLOG("wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInColumns: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'alignItemsInRows'.\n",&tolua_err); +#endif + return 0; +} + static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) { if (NULL == tolua_S) @@ -304,18 +391,34 @@ static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S) - 1; - if(1 == argc) + if(argc >= 1) { - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,2,"MenuItem",0,&tolua_err) ) + MenuItemToggle* tolua_ret = MenuItemToggle::create(); + if (NULL == tolua_ret) { - goto tolua_lerror; + return 0; } + + for (uint32_t i = 0; i < argc; ++i) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S, i + 2,"MenuItem",0,&tolua_err) ) + { + goto tolua_lerror; + } #endif - MenuItem* item = (MenuItem*) tolua_tousertype(tolua_S,2,0); - MenuItemToggle* tolua_ret = (MenuItemToggle*) MenuItemToggle::create(item); - int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + MenuItem* item = static_cast(tolua_tousertype(tolua_S, i + 2,0)); + if (0 == i) + { + tolua_ret->initWithItem(item); + } + else + { + tolua_ret->addSubItem(item); + } + } + + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemToggle"); return 1; @@ -534,7 +637,7 @@ tolua_lerror: #endif } -int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S) +static int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -579,7 +682,7 @@ tolua_lerror: #endif } -int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S) +static int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -618,7 +721,7 @@ tolua_lerror: #endif } -int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S) +static int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -663,9 +766,9 @@ tolua_lerror: #endif } -int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S) +static int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S) { - if (NULL == tolua_S) + if (nullptr == tolua_S) return 0; int argc = 0; @@ -703,7 +806,6 @@ tolua_lerror: #endif } - static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S) { if (NULL == tolua_S) @@ -1590,6 +1692,559 @@ static int tolua_cocos2dx_LayerColor_setBlendFunc(lua_State* tolua_S) return tolua_cocos2dx_setBlendFunc(tolua_S,"LayerColor"); } +static int tolua_cocos2dx_ParticleSystem_setBlendFunc(lua_State* tolua_S) +{ + return tolua_cocos2dx_setBlendFunc(tolua_S,"ParticleSystem"); +} + +static int tolua_cocos2dx_LayerMultiplex_create(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Array* array = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S, 1, "LayerMultiplex", 0, &tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc > 0) + { + if (luavals_variadic_to_array(tolua_S, argc, &array) && nullptr != array ) + { + LayerMultiplex* tolua_ret = LayerMultiplex::createWithArray(array); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"LayerMultiplex"); + return 1; + } + else + { + CCLOG("error in tolua_cocos2dx_LayerMultiplex_create \n"); + return 0; + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_Camera_getCenterXYZ(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Camera* self = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getCenterXYZ'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + float x; + float y; + float z; + self->getCenterXYZ(&x, &y, &z); + tolua_pushnumber(tolua_S,(lua_Number)x); + tolua_pushnumber(tolua_S, (lua_Number)y); + tolua_pushnumber(tolua_S, (lua_Number)z); + return 3; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getCenterXYZ'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_Camera_getEyeXYZ(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Camera* self = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getEyeXYZ'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + float x; + float y; + float z; + self->getEyeXYZ(&x, &y, &z); + tolua_pushnumber(tolua_S,(lua_Number)x); + tolua_pushnumber(tolua_S, (lua_Number)y); + tolua_pushnumber(tolua_S, (lua_Number)z); + return 3; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getEyeXYZ'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_Camera_getUpXYZ(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Camera* self = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getUpXYZ'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + float x; + float y; + float z; + self->getUpXYZ(&x, &y, &z); + tolua_pushnumber(tolua_S,(lua_Number)x); + tolua_pushnumber(tolua_S, (lua_Number)y); + tolua_pushnumber(tolua_S, (lua_Number)z); + return 3; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getUpXYZ'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_FileUtils_getStringFromFile(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + FileUtils* self = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"FileUtils",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_FileUtils_getStringFromFile'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { + const char* arg0; + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (ok) + { + std::string fullPathName = FileUtils::getInstance()->fullPathForFilename(arg0); + String* contentsOfFile = String::createWithContentsOfFile(fullPathName.c_str()); + if (nullptr != contentsOfFile) + { + const char* tolua_ret = contentsOfFile->getCString(); + tolua_pushstring(tolua_S, tolua_ret); + } + return 1; + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getStringFromFile'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_UserDefault_getInstance(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"UserDefault",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if(0 == argc) + { + UserDefault* tolua_ret = (UserDefault*) UserDefault::getInstance(); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"UserDefault"); + return 1; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getInstance'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_GLProgram_create(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + bool ok = false; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if(2 == argc) + { + const char *arg0, *arg1; + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); + + GLProgram* tolua_ret = new GLProgram(); + if (nullptr == tolua_ret) + return 0; + + tolua_ret->autorelease(); + tolua_ret->initWithVertexShaderFilename(arg0, arg1); + int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"GLProgram"); + return 1; + + } + + CCLOG("'create' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_cocos2d_GLProgram_getProgram(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + GLProgram* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (GLProgram*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_GLProgram_getProgram'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (0 == argc) + { + unsigned const int tolua_ret = ( unsigned const int) self->getProgram(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + return 1; + } + + CCLOG("'getProgram' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getProgram'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_GLProgram_setUniformLocationF32(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + GLProgram* self = nullptr; + int location = 0; + double f1 = 0.0; + double f2 = 0.0; + double f3 = 0.0; + double f4 = 0.0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (GLProgram*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_GLProgram_getProgram'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc >= 2 && argc <= 5) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + + location = (int) tolua_tonumber(tolua_S,2,0); + f1 = (float) tolua_tonumber(tolua_S,3,0); + + if (2 == argc) + { + self->setUniformLocationWith1f(location,f1); + return 0; + } + + if (argc >= 3) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,4,0,&tolua_err)) + goto tolua_lerror; +#endif + + f2 = (float) tolua_tonumber(tolua_S,3,0); + if (3 == argc) + { + self->setUniformLocationWith2f(location, f1, f2); + return 0; + } + } + + if (argc >= 4) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,5,0,&tolua_err)) + goto tolua_lerror; +#endif + + f3 = (float) tolua_tonumber(tolua_S,3,0); + if (4 == argc) + { + self->setUniformLocationWith3f(location, f1, f2, f3); + return 0; + } + } + + if (argc == 5) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,6,0,&tolua_err)) + goto tolua_lerror; +#endif + + f4 = (float) tolua_tonumber(tolua_S,3,0); + if (4 == argc) + { + self->setUniformLocationWith4f(location, f1, f2, f3, f4); + return 0; + } + + } + } + + CCLOG("'setUniformLocationF32' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setUniformLocationF32'.",&tolua_err); + return 0; +#endif + +} + +static void extendGLProgram(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "GLProgram"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_GLProgram_create ); + lua_rawset(tolua_S,-3); + + lua_pushstring(tolua_S,"getProgram"); + lua_pushcfunction(tolua_S,tolua_cocos2d_GLProgram_getProgram ); + lua_rawset(tolua_S,-3); + + lua_pushstring(tolua_S,"setUniformLocationF32"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_GLProgram_setUniformLocationF32 ); + lua_rawset(tolua_S,-3); + } +} + +static int tolua_cocos2dx_Texture2D_setTexParameters(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Texture2D* self = nullptr; + GLuint arg1 = 0; + GLuint arg2 = 0; + GLuint arg3 = 0; + GLuint arg4 = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Texture2D",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (Texture2D*) tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Texture2D_setTexParameters'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (4 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 5, 0, &tolua_err)) + { + goto tolua_lerror; + } +#endif + + arg1 = (GLuint)tolua_tonumber(tolua_S, 2, 0); + arg2 = (GLuint)tolua_tonumber(tolua_S, 3, 0); + arg3 = (GLuint)tolua_tonumber(tolua_S, 4, 0); + arg4 = (GLuint)tolua_tonumber(tolua_S, 5, 0); + + Texture2D::TexParams param = { arg1, arg2, arg3, arg4 }; + + self->setTexParameters(param); + + return 0; + } + + CCLOG("'setTexParameters' function of Texture2D wrong number of arguments: %d, was expecting %d\n", argc,4); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setTexParameters'.",&tolua_err); + return 0; +#endif +} + +static void extendTexture2D(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "Texture2D"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setTexParameters"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Texture2D_setTexParameters ); + lua_rawset(tolua_S,-3); + } +} + int register_all_cocos2dx_manual(lua_State* tolua_S) { if (NULL == tolua_S) @@ -1659,6 +2314,12 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_Menu_create); lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"alignItemsInRows"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInRows); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"alignItemsInColumns"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInColumns); + lua_rawset(tolua_S,-3); } lua_pushstring(tolua_S,"Node"); @@ -1814,5 +2475,61 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S,"LayerMultiplex"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerMultiplex_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"ParticleSystem"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setBlendFunc"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_ParticleSystem_setBlendFunc); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S, "Camera"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getCenter"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getCenterXYZ ); + lua_rawset(tolua_S,-3); + + lua_pushstring(tolua_S,"getUp"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getUpXYZ ); + lua_rawset(tolua_S,-3); + + lua_pushstring(tolua_S,"getEye"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getEyeXYZ ); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S, "FileUtils"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getStringFromFile"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_FileUtils_getStringFromFile ); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S, "UserDefault"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getInstance"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_UserDefault_getInstance ); + lua_rawset(tolua_S,-3); + } + + extendGLProgram(tolua_S); + extendTexture2D(tolua_S); + return 0; } \ No newline at end of file diff --git a/scripting/lua/script/Cocos2d.lua b/scripting/lua/script/Cocos2d.lua index fff43e987d..cc6b948c82 100644 --- a/scripting/lua/script/Cocos2d.lua +++ b/scripting/lua/script/Cocos2d.lua @@ -5,10 +5,30 @@ cc.DIRECTOR_PROJECTION_3D = 1 --Point function cc.p(_x,_y) - return { x = _x, y = _y } + if nil == _y then + return { x = _x.x, y = _x.y } + else + return { x = _x, y = _y } + end end -function cc.getPLength(pt) +function cc.pAdd(pt1,pt2) + return {x = pt1.x + pt2.x , y = pt1.y + pt2.y } +end + +function cc.pSub(pt1,pt2) + return {x = pt1.x - pt2.x , y = pt1.y - pt2.y } +end + +function cc.pMul(pt1,factor) + return { x = pt1.x * factor , y = pt1.y * factor } +end + +function cc.pForAngle(a) + return { x = math.cos(a), y = math.sin(a) } +end + +function cc.pGetLength(pt) return math.sqrt( pt.x * pt.x + pt.y * pt.y ); end @@ -21,6 +41,33 @@ function cc.pNormalize(pt) return { x = pt.x / length, y = pt.y / length } end +function cc.pCross(self,other) + return self.x * other.y - self.y * other.x +end + +function cc.pDot(self,other) + return self.x * other.x - self.y * other.y +end + +function cc.pToAngleSelf(self) + return math.atan2(self.y, self.x) +end + +function cc.pToAngle(self,other) + local a2 = cc.pNormalize(self) + local b2 = cc.pNormalize(other) + local angle = math.atan2(cc.pCross(a2, b2), cc.pDot(a2, b2) ) + if angle < 1.192092896e-7 then + return 0.0 + end + + return angle +end + +function cc.pGetDistance(startP,endP) + return cc.pGetLength(cc.pSub(startP,endP)) +end + --Size function cc.size( _width,_height ) return { width = _width, height = _height } @@ -31,6 +78,80 @@ function cc.rect(_x,_y,_width,_height) return { x = _x, y = _y, width = _width, height = _height } end +function cc.rectEqualToRect(rect1,rect2) + if ((rect1.x >= rect2.x) or (rect1.y >= rect2.y) or + ( rect1.x + rect1.width <= rect2.x + rect2.width) or + ( rect1.y + rect1.height <= rect2.y + rect2.height)) then + return false + end + + return true +end + +function cc.rectGetMaxX(rect) + return rect.x + rect.width +end + +function cc.rectGetMidX(rect) + return rect.x + rect.width / 2.0 +end + +function cc.rectGetMinX(rect) + return rect.x; +end + +function cc.rectGetMaxY(rect) + return rect.y + rect.height +end + +function cc.rectGetMidY(rect) + return rect.y + rect.height / 2.0 +end + +function cc.rectGetMinY(rect) + return rect.y +end + +function cc.rectContainsPoint( rect, point ) + local ret = false + + if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and + (point.y >= rect.y) and (point.y <= rect.y + rect.height) then + ret = true + end + + return ret +end + +function cc.rectIntersectsRect( rect1, rect2 ) + local intersect = not ( rect1.x > rect2.x + rect2.width or + rect1.x + rect1.width < rect2.x or + rect1.y > rect2.y + rect2.height or + rect1.y + rect1.height < rect2.y ) + + return intersect +end + +function cc.rectUnion( rect1, rect2 ) + local rect = cc.rect(0, 0, 0, 0) + rect.x = math.min(rect1.x, rect2.x) + rect.y = math.min(rect1.y, rect2.y) + rect.width = math.max(rect1.x + rect1.width, rect2.x + rect2.width) - rect.x + rect.height = math.max(rect1.y + rect1.height, rect2.y + rect2.height) - rect.y + return rect +end + +function cc.rectIntersection( rect1, rect2 ) + local intersection = cc.rect( + math.max(rect1.x, rect2.x), + math.max(rect1.y, rect2.y), + 0, 0) + + intersection.width = math.min(rect1.x + rect1.width, rect2.x + rect2.width) - intersection.x + intersection.height = math.min(rect1.y + rect1.height, rect2.y + rect2.height) - intersection.y + return intersection; +end + --Color3B function cc.c3b( _r,_g,_b ) return { r = _r, g = _g, b = _b } @@ -46,15 +167,4 @@ function cc.c4f( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end -function cc.rectContainsPoint( rect, point ) - local ret = false - - if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and - (point.y >= rect.y) and (point.y <= rect.y + rect.height) then - ret = true - end - - return ret; -end - diff --git a/scripting/lua/script/Cocos2dConstants.lua b/scripting/lua/script/Cocos2dConstants.lua index a86697dfef..e363efaca6 100644 --- a/scripting/lua/script/Cocos2dConstants.lua +++ b/scripting/lua/script/Cocos2dConstants.lua @@ -88,17 +88,26 @@ cc.TMX_TILE_VERTICAL_FLAG = 0x40000000 cc.TEXT_ALIGNMENT_CENTER = 0x1 cc.TEXT_ALIGNMENT_LEFT = 0x0 cc.TEXT_ALIGNMENT_RIGHT = 0x2 -cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x3 -cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x5 -cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 -cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x4 -cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0x9 -cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0x8 -cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x2 -cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x7 -cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x1 -cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x6 -cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x0 + +cc.TEXTURE2_D_PIXEL_FORMAT_AUTO = 0x0 +cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888 = 0x1 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x2 +cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x3 +cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x4 +cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x5 +cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x6 +cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x7 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x8 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x9 +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0xa +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4A = 0xb +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0xc +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2A = 0xd +cc.TEXTURE2_D_PIXEL_FORMAT_ETC = 0xe +cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT1 = 0xf +cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT3 = 0x10 +cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT5 = 0x11 +cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 cc.TOUCHES_ALL_AT_ONCE = 0x0 cc.TOUCHES_ONE_BY_ONE = 0x1 cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1 diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 2200bd45c0..278b930c3a 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h %(cocosdir)s/CocosDenshion/inc # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ +classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault Image # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -103,10 +103,10 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Application::[^application.* ^run$], Camera::[getEyeXYZ getCenterXYZ getUpXYZ], ccFontDefinition::[*], - Object::[autorelease isEqual acceptVisitor update] + Object::[autorelease isEqual acceptVisitor update], + UserDefault::[getInstance (s|g)etDataForKey] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY], - MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], ProgressTimer::[setReverseProgress=setReverseDirection], Animation::[addSpriteFrameWithFileName=addSpriteFrameWithFile], AnimationCache::[addAnimationsWithFile=addAnimations animationByName=getAnimation removeAnimationByName=removeAnimation], diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 5b499f8cc1..f9688a8765 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control$ ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ +classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -40,10 +40,12 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC ScrollView::[(g|s)etDelegate$], .*Delegate::[*], .*Loader.*::[*], - *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate .*HSV], EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], TableView::[create (g|s)etDataSource$ (g|s)etDelegate], - Control::[removeHandleOfControlEvent addHandleOfControlEvent] + Control::[removeHandleOfControlEvent addHandleOfControlEvent], + ControlUtils::[*], + ControlSwitchSprite::[*] rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager], CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed]