diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index db64680113..efe0a68963 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -179,10 +179,10 @@ public: virtual void setMargins(int marginH, int marginV); // Overrides - virtual bool ccTouchBegan(Touch *pTouch, cocos2d::Event *pEvent) override; - virtual void ccTouchMoved(Touch *pTouch, cocos2d::Event *pEvent) override; - virtual void ccTouchEnded(Touch *pTouch, cocos2d::Event *pEvent) override; - virtual void ccTouchCancelled(Touch *pTouch, cocos2d::Event *pEvent) override; + virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent) override; + virtual void ccTouchMoved(Touch *pTouch, Event *pEvent) override; + virtual void ccTouchEnded(Touch *pTouch, Event *pEvent) override; + virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent) override; virtual GLubyte getOpacity(void) const override; virtual void setOpacity(GLubyte var) override; virtual const Color3B& getColor(void) const override; diff --git a/samples/Lua/HelloLua/Resources/hello.lua b/samples/Lua/HelloLua/Resources/hello.lua index ea14452160..b6dd2e41d0 100644 --- a/samples/Lua/HelloLua/Resources/hello.lua +++ b/samples/Lua/HelloLua/Resources/hello.lua @@ -1,7 +1,4 @@ -cc = cc or {} -function cc.rect(_x,_y,_width,_height) - return { x = _x, y = _y, width = _width, height = _height } -end +require "Cocos2d" -- cclog cclog = function(...) print(string.format(...)) diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua index 3ef748ffe4..bd1efd53d6 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua @@ -1,7 +1,7 @@ local kTagNode = 0 local kTagGrossini = 1 local kTagSequence = 2 -local scheduler = CCDirector:getInstance():getScheduler() +local scheduler = cc.Director:getInstance():getScheduler() -------------------------------------------------------------------- -- -- Test1 @@ -11,28 +11,33 @@ local scheduler = CCDirector:getInstance():getScheduler() local function CrashTest() local ret = createTestLayer("Test 1. Should not crash") - local child = CCSprite:create(s_pPathGrossini) - child:setPosition( VisibleRect:center() ) + local child = cc.Sprite:create(s_pPathGrossini) + child:setPosition( 200,200 ) ret:addChild(child, 1) --Sum of all action's duration is 1.5 second. - child:runAction(CCRotateBy:create(1.5, 90)) + child:runAction(cc.RotateBy:create(1.5, 90)) + --[[ local arr = CCArray:create() arr:addObject(CCDelayTime:create(1.4)) arr:addObject(CCFadeOut:create(1.1)) - child:runAction(CCSequence:create(arr)) + ]]-- + child:runAction(cc.Sequence:create(cc.DelayTime:create(1.4),cc.FadeOut:create(1.1))) + --[[ arr = CCArray:create() arr:addObject(CCDelayTime:create(1.4)) - + ]]-- local function removeThis() ret:getParent():removeChild(ret, true) Helper.nextAction() end + --[[ local callfunc = CCCallFunc:create(removeThis) arr:addObject(callfunc) + ]]-- --After 1.5 second, self will be removed. - ret:runAction( CCSequence:create(arr)) + ret:runAction( cc.Sequence:create(cc.DelayTime:create(1.4),cc.CallFunc:create(removeThis))) return ret end @@ -44,21 +49,22 @@ end -------------------------------------------------------------------- local function LogicTest() local ret = createTestLayer("Logic test") - local grossini = CCSprite:create(s_pPathGrossini) + local grossini = cc.Sprite:create(s_pPathGrossini) ret:addChild(grossini, 0, 2) - grossini:setPosition(VisibleRect:center()) - + grossini:setPosition(200,200) +--[[ local arr = CCArray:create() arr:addObject(CCMoveBy:create(1, CCPoint(150,0))) - +]]-- local function bugMe(node) node:stopAllActions() --After this stop next action not working, if remove this stop everything is working - node:runAction(CCScaleTo:create(2, 2)) + node:runAction(cc.ScaleTo:create(2, 2)) end - +--[[ local callfunc = CCCallFunc:create(bugMe) arr:addObject(callfunc) - grossini:runAction( CCSequence:create(arr)); +]]-- + grossini:runAction( cc.Sequence:create(cc.MoveBy:create(1, cc.p(150,0)) ,cc.CallFunc:create(bugMe))) return ret end @@ -75,23 +81,24 @@ local function PauseTest() scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil local node = ret:getChildByTag( kTagGrossini ) - local pDirector = CCDirector:getInstance() + local pDirector = cc.Director:getInstance() pDirector:getActionManager():resumeTarget(node) end local function onNodeEvent(event) if event == "enter" then - local l = CCLabelTTF:create("After 3 seconds grossini should move", "Thonburi", 16) + local s = cc.Director:getInstance():getWinSize() + local l = cc.LabelTTF:create("After 3 seconds grossini should move", "Thonburi", 16) ret:addChild(l) - l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y-75) ) + l:setPosition( cc.p(s.width / 2, 245) ) - local grossini = CCSprite:create(s_pPathGrossini) + local grossini = cc.Sprite:create(s_pPathGrossini) ret:addChild(grossini, 0, kTagGrossini) - grossini:setPosition(VisibleRect:center() ) + grossini:setPosition(cc.p(200,200)) - local action = CCMoveBy:create(1, CCPoint(150,0)) + local action = cc.MoveBy:create(1, cc.p(150,0)) - local pDirector = CCDirector:getInstance() + local pDirector = cc.Director:getInstance() pDirector:getActionManager():addAction(action, grossini, true) schedulerEntry = scheduler:scheduleScriptFunc(unpause, 3.0, false) @@ -114,25 +121,28 @@ end -------------------------------------------------------------------- local function RemoveTest() local ret = createTestLayer("Remove Test") - local l = CCLabelTTF:create("Should not crash", "Thonburi", 16) + local l = cc.LabelTTF:create("Should not crash", "Thonburi", 16) + local s = cc.Director:getInstance():getWinSize() ret:addChild(l) - l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 75) ) + l:setPosition( cc.p(s.width / 2, 245)) - local pMove = CCMoveBy:create(2, CCPoint(200, 0)) + local pMove = cc.MoveBy:create(2, cc.p(200, 0)) local function stopAction() local pSprite = ret:getChildByTag(kTagGrossini) pSprite:stopActionByTag(kTagSequence) end - local callfunc = CCCallFunc:create(stopAction) + local callfunc = cc.CallFunc:create(stopAction) + --[[ local arr = CCArray:create() arr:addObject(pMove) arr:addObject(callfunc) - local pSequence = CCSequence:create(arr) + ]]-- + local pSequence = cc.Sequence:create(pMove,callfunc) pSequence:setTag(kTagSequence) - local pChild = CCSprite:create(s_pPathGrossini) - pChild:setPosition( VisibleRect:center() ) + local pChild = cc.Sprite:create(s_pPathGrossini) + pChild:setPosition( 200, 200 ) ret:addChild(pChild, 1, kTagGrossini) pChild:runAction(pSequence) @@ -153,26 +163,27 @@ local function ResumeTest() scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil local pGrossini = ret:getChildByTag(kTagGrossini) - local pDirector = CCDirector:getInstance() + local pDirector = cc.Director:getInstance() pDirector:getActionManager():resumeTarget(pGrossini) end local function onNodeEvent(event) if event == "enter" then - local l = CCLabelTTF:create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16) + local l = cc.LabelTTF:create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16) ret:addChild(l) - l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 75)) + local s = cc.Director:getInstance():getWinSize() + l:setPosition( s.width / 2, 245) - local pGrossini = CCSprite:create(s_pPathGrossini) + local pGrossini = cc.Sprite:create(s_pPathGrossini) ret:addChild(pGrossini, 0, kTagGrossini) - pGrossini:setPosition(VisibleRect:center()) + pGrossini:setPosition(200,200) - pGrossini:runAction(CCScaleBy:create(2, 2)) + pGrossini:runAction(cc.ScaleBy:create(2, 2)) - local pDirector = CCDirector:getInstance() + local pDirector = cc.Director:getInstance() pDirector:getActionManager():pauseTarget(pGrossini) - pGrossini:runAction(CCRotateBy:create(2, 360)) + pGrossini:runAction(cc.RotateBy:create(2, 360)) schedulerEntry = scheduler:scheduleScriptFunc(resumeGrossini, 3.0, false) elseif event == "exit" then @@ -191,8 +202,8 @@ end function ActionManagerTestMain() cclog("ActionManagerTestMain") Helper.index = 1 - CCDirector:getInstance():setDepthTest(true) - local scene = CCScene:create() + cc.Director:getInstance():setDepthTest(true) + local scene = cc.Scene:create() Helper.createFunctionTable = { CrashTest, diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua index b13fe75638..6d5487df7b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua @@ -2,37 +2,37 @@ local kTagAction1 = 1 local kTagAction2 = 2 local kTagSlider = 1 -local s = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local s = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local function createSimpleMoveBy() - return CCMoveBy:create(3, CCPoint(s.width - 130, 0)) + return cc.MoveBy:create(3, cc.p(s.width - 130, 0)) end local function createSimpleDelayTime() - return CCDelayTime:create(0.25) + return cc.DelayTime:create(0.25) end local function positionForTwo() - grossini:setPosition(CCPoint(60, s.height * 1 / 5)) - tamara:setPosition(CCPoint(60, s.height * 4 / 5)) + grossini:setPosition(cc.p(60, s.height * 1 / 5)) + tamara:setPosition(cc.p(60, s.height * 4 / 5)) kathia:setVisible(false) end local function getBaseLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() - grossini = CCSprite:create(s_pPathGrossini) - tamara = CCSprite:create(s_pPathSister1) - kathia = CCSprite:create(s_pPathSister2) + grossini = cc.Sprite:create(s_pPathGrossini) + tamara = cc.Sprite:create(s_pPathSister1) + kathia = cc.Sprite:create(s_pPathSister2) layer:addChild(grossini, 3) layer:addChild(kathia, 2) layer:addChild(tamara, 1) - grossini:setPosition(CCPoint(60, s.height * 1 / 5)) - kathia:setPosition(CCPoint(60, s.height * 2.5 / 5)) - tamara:setPosition(CCPoint(60, s.height * 4 / 5)) + grossini:setPosition(cc.p(60, s.height * 1 / 5)) + kathia:setPosition(cc.p(60, s.height * 2.5 / 5)) + tamara:setPosition(cc.p(60, s.height * 4 / 5)) Helper.initWithLayer(layer) @@ -65,40 +65,43 @@ local function SpriteEase() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseIn:create(createSimpleMoveBy(), 2.5) + local move_ease_in = cc.EaseIn:create(createSimpleMoveBy(), 2.5) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseOut:create(createSimpleMoveBy(), 2.5) + local move_ease_out = cc.EaseOut:create(createSimpleMoveBy(), 2.5) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in,createSimpleDelayTime(),move_ease_in_back,createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out,createSimpleDelayTime(),move_ease_out_back,createSimpleDelayTime()) - local a2 = grossini:runAction(CCRepeatForever:create(seq1)) + local a2 = grossini:runAction(cc.RepeatForever:create(seq1)) a2:setTag(1) - local a1 = tamara:runAction(CCRepeatForever:create(seq2)) + local a1 = tamara:runAction(cc.RepeatForever:create(seq2)) a1:setTag(1) - local a = kathia:runAction(CCRepeatForever:create(seq3)) + local a = kathia:runAction(cc.RepeatForever:create(seq3)) a:setTag(1) layer:registerScriptHandler(SpriteEase_onEnterOrExit) @@ -115,41 +118,45 @@ local function SpriteEaseInOut() local move = createSimpleMoveBy() - local move_ease_inout1 = CCEaseInOut:create(createSimpleMoveBy(), 0.65) + local move_ease_inout1 = cc.EaseInOut:create(createSimpleMoveBy(), 0.65) local move_ease_inout_back1 = move_ease_inout1:reverse() - local move_ease_inout2 = CCEaseInOut:create(createSimpleMoveBy(), 1.35) + local move_ease_inout2 = cc.EaseInOut:create(createSimpleMoveBy(), 1.35) local move_ease_inout_back2 = move_ease_inout2:reverse() - local move_ease_inout3 = CCEaseInOut:create(createSimpleMoveBy(), 1.0) + local move_ease_inout3 = cc.EaseInOut:create(createSimpleMoveBy(), 1.0) local move_ease_inout_back3 = move_ease_inout3:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move_ease_inout1) arr1:addObject(delay) arr1:addObject(move_ease_inout_back1) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) + ]]-- + local seq1 = cc.Sequence:create(move_ease_inout1,delay,move_ease_inout_back1,createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_inout2) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_inout_back2) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_inout2,createSimpleDelayTime(),move_ease_inout_back2,createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_inout3) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_inout_back3) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) +]]-- + local seq3 = cc.Sequence:create(move_ease_inout3, createSimpleDelayTime(), move_ease_inout_back3, createSimpleDelayTime() ) - tamara:runAction(CCRepeatForever:create(seq1)) - kathia:runAction(CCRepeatForever:create(seq2)) - grossini:runAction(CCRepeatForever:create(seq3)) + tamara:runAction(cc.RepeatForever:create(seq1)) + kathia:runAction(cc.RepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("EaseInOut and rates") return layer @@ -164,22 +171,24 @@ local function SpriteEaseExponential() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseExponentialIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseExponentialIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseExponentialOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseExponentialOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - +]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) @@ -187,8 +196,10 @@ local function SpriteEaseExponential() arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) @@ -196,11 +207,12 @@ local function SpriteEaseExponential() arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime() ) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("ExpIn - ExpOut actions") return layer @@ -215,19 +227,21 @@ local function SpriteEaseExponentialInOut() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease = CCEaseExponentialInOut:create(createSimpleMoveBy()) + local move_ease = cc.EaseExponentialInOut:create(createSimpleMoveBy()) local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) +]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease) @@ -235,12 +249,13 @@ local function SpriteEaseExponentialInOut() arr2:addObject(move_ease_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime() ) positionForTwo() - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) Helper.titleLabel:setString("EaseExponentialInOut action") return layer @@ -255,38 +270,41 @@ local function SpriteEaseSine() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseSineIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseSineIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseSineOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseSineOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back,createSimpleDelayTime() ) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("EaseSineIn - EaseSineOut") return layer @@ -301,29 +319,31 @@ local function SpriteEaseSineInOut() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease = CCEaseSineInOut:create(createSimpleMoveBy()) + local move_ease = cc.EaseSineInOut:create(createSimpleMoveBy()) local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) Helper.titleLabel:setString("EaseSineInOut action") return layer @@ -338,38 +358,41 @@ local function SpriteEaseElastic() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseElasticIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseElasticIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseElasticOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseElasticOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("Elastic In - Out actions") return layer @@ -383,41 +406,44 @@ local function SpriteEaseElasticInOut() local move = createSimpleMoveBy() - local move_ease_inout1 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.3) + local move_ease_inout1 = cc.EaseElasticInOut:create(createSimpleMoveBy(), 0.3) local move_ease_inout_back1 = move_ease_inout1:reverse() - local move_ease_inout2 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.45) + local move_ease_inout2 = cc.EaseElasticInOut:create(createSimpleMoveBy(), 0.45) local move_ease_inout_back2 = move_ease_inout2:reverse() - local move_ease_inout3 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.6) + local move_ease_inout3 = cc.EaseElasticInOut:create(createSimpleMoveBy(), 0.6) local move_ease_inout_back3 = move_ease_inout3:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move_ease_inout1) arr1:addObject(delay) arr1:addObject(move_ease_inout_back1) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move_ease_inout1, delay, move_ease_inout_back1, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_inout2) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_inout_back2) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_inout2, createSimpleDelayTime(), move_ease_inout_back2, createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_inout3) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_inout_back3) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_inout3, createSimpleDelayTime(), move_ease_inout_back3, createSimpleDelayTime()) - tamara:runAction(CCRepeatForever:create(seq1)) - kathia:runAction(CCRepeatForever:create(seq2)) - grossini:runAction(CCRepeatForever:create(seq3)) + tamara:runAction(cc.RepeatForever:create(seq1)) + kathia:runAction(cc.RepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("EaseElasticInOut action") return layer @@ -432,38 +458,41 @@ local function SpriteEaseBounce() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseBounceIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseBounceIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseBounceOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseBounceOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("Bounce In - Out actions") return layer @@ -478,29 +507,31 @@ local function SpriteEaseBounceInOut() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease = CCEaseBounceInOut:create(createSimpleMoveBy()) + local move_ease = cc.EaseBounceInOut:create(createSimpleMoveBy()) local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) Helper.titleLabel:setString("EaseBounceInOut action") return layer @@ -515,38 +546,41 @@ local function SpriteEaseBack() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseBackIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseBackIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseBackOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseBackOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("Back In - Out actions") return layer @@ -561,29 +595,31 @@ local function SpriteEaseBackInOut() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease = CCEaseBackInOut:create(createSimpleMoveBy()) + local move_ease = cc.EaseBackInOut:create(createSimpleMoveBy()) local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease,createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) Helper.titleLabel:setString("EaseBackInOut action") return layer @@ -614,22 +650,22 @@ end local function SpeedTest() local layer = getBaseLayer() - local jump1 = CCJumpBy:create(4, CCPoint(- s.width + 80, 0), 100, 4) + local jump1 = cc.JumpBy:create(4, cc.p(- s.width + 80, 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 seq3_1 = CCSequence:createWithTwoActions(jump2, jump1) - local seq3_2 = CCSequence:createWithTwoActions(rot1, rot2) + local seq3_1 = cc.Sequence:create(jump2, jump1) + local seq3_2 = cc.Sequence:create(rot1, rot2) - local spawn = CCSpawn:createWithTwoActions(seq3_1, seq3_2) - SpeedTest_action1 = CCSpeed:create(CCRepeatForever:create(spawn), 1.0) + local spawn = cc.Spawn:create(seq3_1, seq3_2) + SpeedTest_action1 = cc.Speed:create(cc.RepeatForever:create(spawn), 1.0) - local spawn2 = tolua.cast(spawn:clone(), "CCSpawn") - SpeedTest_action2 = CCSpeed:create(CCRepeatForever:create(spawn2), 1.0) + local spawn2 = tolua.cast(spawn:clone(), "Spawn") + SpeedTest_action2 = cc.Speed:create(cc.RepeatForever:create(spawn2), 1.0) - local spawn3 = tolua.cast(spawn:clone(), "CCSpawn") - SpeedTest_action3 = CCSpeed:create(CCRepeatForever:create(spawn3), 1.0) + local spawn3 = tolua.cast(spawn:clone(), "Spawn") + SpeedTest_action3 = cc.Speed:create(cc.RepeatForever:create(spawn3), 1.0) grossini:runAction(SpeedTest_action2) tamara:runAction(SpeedTest_action3) @@ -642,7 +678,7 @@ local function SpeedTest() end function EaseActionsTest() - local scene = CCScene:create() + local scene = cc.Scene:create() cclog("EaseActionsTest") Helper.createFunctionTable = { diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua index 392ca18048..ec1db2e6d1 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua @@ -1,28 +1,28 @@ -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() ------------------------------------ -- SpriteProgressToRadial ------------------------------------ local function SpriteProgressToRadial() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to1 = CCProgressTo:create(2, 100) - local to2 = CCProgressTo:create(2, 100) + local to1 = cc.ProgressTo:create(2, 100) + local to2 = cc.ProgressTo:create(2, 100) - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeRadial) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(to1)) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_RADIAL) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(to1)) layer:addChild(left) - local right = CCProgressTimer:create(CCSprite:create(s_pPathBlock)) - right:setType(kCCProgressTimerTypeRadial) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathBlock)) + right:setType(cc.PROGRESS_TIMER_TYPE_RADIAL) -- Makes the ridial CCW - right:setReverseProgress(true) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(to2)) + right:setReverseDirection(true) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(to2)) layer:addChild(right) Helper.subtitleLabel:setString("ProgressTo Radial") @@ -33,30 +33,30 @@ end -- SpriteProgressToHorizontal ------------------------------------ local function SpriteProgressToHorizontal() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to1 = CCProgressTo:create(2, 100) - local to2 = CCProgressTo:create(2, 100) + local to1 = cc.ProgressTo:create(2, 100) + local to2 = cc.ProgressTo:create(2, 100) - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeBar) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the left since the midpoint is 0 for the x - left:setMidpoint(CCPoint(0, 0)) + left:setMidpoint(cc.p(0, 0)) -- Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - left:setBarChangeRate(CCPoint(1, 0)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(to1)) + left:setBarChangeRate(cc.p(1, 0)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(to1)) layer:addChild(left) - local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - right:setType(kCCProgressTimerTypeBar) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the left since the midpoint is 1 for the x - right:setMidpoint(CCPoint(1, 0)) + right:setMidpoint(cc.p(1, 0)) -- Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - right:setBarChangeRate(CCPoint(1, 0)) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(to2)) + right:setBarChangeRate(cc.p(1, 0)) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(to2)) layer:addChild(right) Helper.subtitleLabel:setString("ProgressTo Horizontal") @@ -67,31 +67,31 @@ end -- SpriteProgressToVertical ------------------------------------ local function SpriteProgressToVertical() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to1 = CCProgressTo:create(2, 100) - local to2 = CCProgressTo:create(2, 100) + local to1 = cc.ProgressTo:create(2, 100) + local to2 = cc.ProgressTo:create(2, 100) - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeBar) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPoint(0,0)) + left:setMidpoint(cc.p(0,0)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPoint(0, 1)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(to1)) + left:setBarChangeRate(cc.p(0, 1)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(to1)) layer:addChild(left) - local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - right:setType(kCCProgressTimerTypeBar) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPoint(0, 1)) + right:setMidpoint(cc.p(0, 1)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPoint(0, 1)) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(to2)) + right:setBarChangeRate(cc.p(0, 1)) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(to2)) layer:addChild(right) Helper.subtitleLabel:setString("ProgressTo Vertical") @@ -102,30 +102,30 @@ end -- SpriteProgressToRadialMidpointChanged ------------------------------------ local function SpriteProgressToRadialMidpointChanged() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local action = CCProgressTo:create(2, 100) + local action = cc.ProgressTo:create(2, 100) -- Our image on the left should be a radial progress indicator, clockwise - local left = CCProgressTimer:create(CCSprite:create(s_pPathBlock)) - left:setType(kCCProgressTimerTypeRadial) - left:setMidpoint(CCPoint(0.25, 0.75)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathBlock)) + left:setType(cc.PROGRESS_TIMER_TYPE_RADIAL) + left:setMidpoint(cc.p(0.25, 0.75)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(left) -- Our image on the left should be a radial progress indicator, counter clockwise - local right = CCProgressTimer:create(CCSprite:create(s_pPathBlock)) - right:setType(kCCProgressTimerTypeRadial) - right:setMidpoint(CCPoint(0.75, 0.25)) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathBlock)) + right:setType(cc.PROGRESS_TIMER_TYPE_RADIAL) + right:setMidpoint(cc.p(0.75, 0.25)) --[[ Note the reverse property (default=NO) is only added to the right image. That's how we get a counter clockwise progress. ]] - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(right) Helper.subtitleLabel:setString("Radial w/ Different Midpoints") @@ -136,40 +136,40 @@ end -- SpriteProgressBarVarious ------------------------------------ local function SpriteProgressBarVarious() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to = CCProgressTo:create(2, 100) + local to = cc.ProgressTo:create(2, 100) - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeBar) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPoint(0.5, 0.5)) + left:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPoint(1, 0)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + left:setBarChangeRate(cc.p(1, 0)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(left) - local middle = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - middle:setType(kCCProgressTimerTypeBar) + local middle = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + middle:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPoint(0.5, 0.5)) + middle:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPoint(1, 1)) - middle:setPosition(CCPoint(s.width/2, s.height/2)) - middle:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + middle:setBarChangeRate(cc.p(1, 1)) + middle:setPosition(cc.p(s.width/2, s.height/2)) + middle:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(middle) - local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - right:setType(kCCProgressTimerTypeBar) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPoint(0.5, 0.5)) + right:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPoint(0, 1)) - right:setPosition(CCPoint(s.width-100, s.height/2)) - right:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + right:setBarChangeRate(cc.p(0, 1)) + right:setPosition(cc.p(s.width-100, s.height/2)) + right:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(right) Helper.subtitleLabel:setString("ProgressTo Bar Mid") @@ -180,65 +180,60 @@ end -- SpriteProgressBarTintAndFade ------------------------------------ local function SpriteProgressBarTintAndFade() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to = CCProgressTo:create(6, 100) + local to = cc.ProgressTo:create(6, 100) + --[[ local array = CCArray:create() array:addObject(CCTintTo:create(1, 255, 0, 0)) array:addObject(CCTintTo:create(1, 0, 255, 0)) array:addObject(CCTintTo:create(1, 0, 0, 255)) - local tint = CCSequence:create(array) - local fade = CCSequence:createWithTwoActions( - CCFadeTo:create(1.0, 0), - CCFadeTo:create(1.0, 255)) - - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeBar) + ]]-- + local tint = cc.Sequence:create(cc.TintTo:create(1, 255, 0, 0), cc.TintTo:create(1, 0, 255, 0), cc.TintTo:create(1, 0, 0, 255)) + local fade = cc.Sequence:create(cc.FadeTo:create(1.0, 0),cc.FadeTo:create(1.0, 255)) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPoint(0.5, 0.5)) + left:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPoint(1, 0)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) - left:runAction(CCRepeatForever:create(CCSequence:create(array))) + left:setBarChangeRate(cc.p(1, 0)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) + left:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.TintTo:create(1, 255, 0, 0), cc.TintTo:create(1, 0, 255, 0), cc.TintTo:create(1, 0, 0, 255)))) layer:addChild(left) - left:addChild(CCLabelTTF:create("Tint", "Marker Felt", 20.0)) + left:addChild(cc.LabelTTF:create("Tint", "Marker Felt", 20.0)) - local middle = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - middle:setType(kCCProgressTimerTypeBar) + local middle = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + middle:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPoint(0.5, 0.5)) + middle:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPoint(1, 1)) - middle:setPosition(CCPoint(s.width / 2, s.height / 2)) - middle:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) + middle:setBarChangeRate(cc.p(1, 1)) + middle:setPosition(cc.p(s.width / 2, s.height / 2)) + middle:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) - local fade2 = CCSequence:createWithTwoActions( - CCFadeTo:create(1.0, 0), - CCFadeTo:create(1.0, 255)) - middle:runAction(CCRepeatForever:create(fade2)) + local fade2 = cc.Sequence:create(cc.FadeTo:create(1.0, 0), cc.FadeTo:create(1.0, 255)) + middle:runAction(cc.RepeatForever:create(fade2)) layer:addChild(middle) - middle:addChild(CCLabelTTF:create("Fade", "Marker Felt", 20.0)) + middle:addChild(cc.LabelTTF:create("Fade", "Marker Felt", 20.0)) - local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - right:setType(kCCProgressTimerTypeBar) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPoint(0.5, 0.5)) + right:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPoint(0, 1)) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) - right:runAction(CCRepeatForever:create(CCSequence:create(array))) - right:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions( - CCFadeTo:create(1.0, 0), - CCFadeTo:create(1.0, 255)))) + right:setBarChangeRate(cc.p(0, 1)) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) + right:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.TintTo:create(1, 255, 0, 0), cc.TintTo:create(1, 0, 255, 0), cc.TintTo:create(1, 0, 0, 255)))) + right:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(1.0, 0), cc.FadeTo:create(1.0, 255)))) layer:addChild(right) - right:addChild(CCLabelTTF:create("Tint and Fade", "Marker Felt", 20.0)) + right:addChild(cc.LabelTTF:create("Tint and Fade", "Marker Felt", 20.0)) Helper.subtitleLabel:setString("ProgressTo Bar Mid") return layer @@ -248,41 +243,41 @@ end -- SpriteProgressWithSpriteFrame ------------------------------------ local function SpriteProgressWithSpriteFrame() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to = CCProgressTo:create(6, 100) + local to = cc.ProgressTo:create(6, 100) - CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini.plist") + cc.SpriteFrameCache:getInstance():addSpriteFrames("zwoptex/grossini.plist") - local left = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_01.png")) - left:setType(kCCProgressTimerTypeBar) + local left = cc.ProgressTimer:create(cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png")) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPoint(0.5, 0.5)) + left:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPoint(1, 0)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) + left:setBarChangeRate(cc.p(1, 0)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) layer:addChild(left) - local middle = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_02.png")) - middle:setType(kCCProgressTimerTypeBar) + local middle = cc.ProgressTimer:create(cc.Sprite:createWithSpriteFrameName("grossini_dance_02.png")) + middle:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPoint(0.5, 0.5)) + middle:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPoint(1, 1)) - middle:setPosition(CCPoint(s.width / 2, s.height / 2)) - middle:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) + middle:setBarChangeRate(cc.p(1, 1)) + middle:setPosition(cc.p(s.width / 2, s.height / 2)) + middle:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) layer:addChild(middle) - local right = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_03.png")) - right:setType(kCCProgressTimerTypeRadial) + local right = cc.ProgressTimer:create(cc.Sprite:createWithSpriteFrameName("grossini_dance_03.png")) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPoint(0.5, 0.5)) + right:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPoint(0, 1)) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) + right:setBarChangeRate(cc.p(0, 1)) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) layer:addChild(right) Helper.subtitleLabel:setString("Progress With Sprite Frame") @@ -290,7 +285,7 @@ local function SpriteProgressWithSpriteFrame() end function ProgressActionsTest() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { SpriteProgressToRadial, @@ -305,5 +300,5 @@ function ProgressActionsTest() scene:addChild(SpriteProgressToRadial()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua index bfd2c86334..f866def795 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua @@ -1,17 +1,17 @@ -local size = CCDirector:getInstance():getWinSize() +local size = cc.Director:getInstance():getWinSize() local function initWithLayer(layer) - grossini = CCSprite:create(s_pPathGrossini) - tamara = CCSprite:create(s_pPathSister1) - kathia = CCSprite:create(s_pPathSister2) + grossini = cc.Sprite:create(s_pPathGrossini) + tamara = cc.Sprite:create(s_pPathSister1) + kathia = cc.Sprite:create(s_pPathSister2) layer:addChild(grossini, 1) layer:addChild(tamara, 2) layer:addChild(kathia, 3) - grossini:setPosition(CCPoint(size.width / 2, size.height / 3)) - tamara:setPosition(CCPoint(size.width / 2, 2 * size.height / 3)) - kathia:setPosition(CCPoint(size.width / 2, size.height / 2)) + grossini:setPosition(cc.p(size.width / 2, size.height / 3)) + tamara:setPosition(cc.p(size.width / 2, 2 * size.height / 3)) + kathia:setPosition(cc.p(size.width / 2, size.height / 2)) Helper.initWithLayer(layer) end @@ -25,15 +25,15 @@ local function centerSprites(numberOfSprites) elseif numberOfSprites == 1 then tamara:setVisible(false) kathia:setVisible(false) - grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) + grossini:setPosition(cc.p(size.width / 2, size.height / 2)) elseif numberOfSprites == 2 then - kathia:setPosition(CCPoint(size.width / 3, size.height / 2)) - tamara:setPosition(CCPoint(2 * size.width / 3, size.height / 2)) + kathia:setPosition(cc.p(size.width / 3, size.height / 2)) + tamara:setPosition(cc.p(2 * size.width / 3, size.height / 2)) grossini:setVisible(false) elseif numberOfSprites == 3 then - grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) - tamara:setPosition(CCPoint(size.width / 4, size.height / 2)) - kathia:setPosition(CCPoint(3 * size.width / 4, size.height / 2)) + grossini:setPosition(cc.p(size.width / 2, size.height / 2)) + tamara:setPosition(cc.p(size.width / 4, size.height / 2)) + kathia:setPosition(cc.p(3 * size.width / 4, size.height / 2)) end end @@ -41,15 +41,15 @@ local function alignSpritesLeft(numberOfSprites) if numberOfSprites == 1 then tamara:setVisible(false) kathia:setVisible(false) - grossini:setPosition(CCPoint(60, size.height / 2)) + grossini:setPosition(cc.p(60, size.height / 2)) elseif numberOfSprites == 2 then - kathia:setPosition(CCPoint(60, size.height / 3)) - tamara:setPosition(CCPoint(60, 2 * size.height / 3)) + kathia:setPosition(cc.p(60, size.height / 3)) + tamara:setPosition(cc.p(60, 2 * size.height / 3)) grossini:setVisible(false) elseif numberOfSprites == 3 then - grossini:setPosition(CCPoint(60, size.height / 2)) - tamara:setPosition(CCPoint(60, 2 * size.height / 3)) - kathia:setPosition(CCPoint(60, size.height / 3)) + grossini:setPosition(cc.p(60, size.height / 2)) + tamara:setPosition(cc.p(60, 2 * size.height / 3)) + kathia:setPosition(cc.p(60, size.height / 3)) end end @@ -58,20 +58,20 @@ end -- ActionManual -------------------------------------- local function ActionManual() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) tamara:setScaleX(2.5) tamara:setScaleY(-1.0) - tamara:setPosition(CCPoint(100, 70)) + tamara:setPosition(cc.p(100, 70)) tamara:setOpacity(128) grossini:setRotation(120) - grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) - grossini:setColor(Color3B(255, 0, 0)) + grossini:setPosition(cc.p(size.width / 2, size.height / 2)) + grossini:setColor(cc.c3b(255, 0, 0)) - kathia:setPosition(CCPoint(size.width - 100, size.height / 2)) - kathia:setColor(Color3B(0, 0, 255)) + kathia:setPosition(cc.p(size.width - 100, size.height / 2)) + kathia:setColor(cc.c3b(0, 0, 255)) Helper.subtitleLabel:setString("Manual Transformation") return layer @@ -81,16 +81,16 @@ end -- ActionMove -------------------------------------- local function ActionMove() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionBy = CCMoveBy:create(2, CCPoint(80, 80)) + local actionBy = cc.MoveBy:create(2, cc.p(80, 80)) local actionByBack = actionBy:reverse() - tamara:runAction(CCMoveTo:create(2, CCPoint(size.width - 40, size.height - 40))) - grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) - kathia:runAction(CCMoveTo:create(1, CCPoint(40, 40))) + tamara:runAction(cc.MoveTo:create(2, cc.p(size.width - 40, size.height - 40))) + grossini:runAction(cc.Sequence:create(actionBy, actionByBack)) + kathia:runAction(cc.MoveTo:create(1, cc.p(40, 40))) Helper.subtitleLabel:setString("MoveTo / MoveBy") return layer @@ -100,18 +100,18 @@ end -- ActionScale -------------------------------------- local function ActionScale() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionTo = CCScaleTo:create(2.0, 0.5) - local actionBy = CCScaleBy:create(2.0, 1.0, 10.0) - local actionBy2 = CCScaleBy:create(2.0, 5.0, 1.0) + local actionTo = cc.ScaleTo:create(2.0, 0.5) + local actionBy = cc.ScaleBy:create(2.0, 1.0, 10.0) + local actionBy2 = cc.ScaleBy:create(2.0, 5.0, 1.0) grossini:runAction(actionTo) - tamara:runAction(CCSequence:createWithTwoActions(actionBy, actionBy:reverse())) - kathia:runAction(CCSequence:createWithTwoActions(actionBy2, actionBy2:reverse())) + tamara:runAction(cc.Sequence:create(actionBy, actionBy:reverse())) + kathia:runAction(cc.Sequence:create(actionBy2, actionBy2:reverse())) Helper.subtitleLabel:setString("ScaleTo / ScaleBy") return layer @@ -121,23 +121,23 @@ end -- ActionRotate -------------------------------------- local function ActionRotate() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionTo = CCRotateTo:create( 2, 45) - local actionTo2 = CCRotateTo:create( 2, -45) - local actionTo0 = CCRotateTo:create(2 , 0) - tamara:runAction(CCSequence:createWithTwoActions(actionTo, actionTo0)) + local actionTo = cc.RotateTo:create( 2, 45) + local actionTo2 = cc.RotateTo:create( 2, -45) + local actionTo0 = cc.RotateTo:create(2 , 0) + tamara:runAction(cc.Sequence:create(actionTo, actionTo0)) - local actionBy = CCRotateBy:create(2 , 360) + local actionBy = cc.RotateBy:create(2 , 360) local actionByBack = actionBy:reverse() - grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) + grossini:runAction(cc.Sequence:create(actionBy, actionByBack)) - local action0Retain = CCRotateTo:create(2 , 0) + local action0Retain = cc.RotateTo:create(2 , 0) - kathia:runAction(CCSequence:createWithTwoActions(actionTo2, action0Retain)) + kathia:runAction(cc.Sequence:create(actionTo2, action0Retain)) Helper.subtitleLabel:setString("RotateTo / RotateBy") return layer @@ -147,20 +147,20 @@ end -- ActionSkew -------------------------------------- local function ActionSkew() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionTo = CCSkewTo:create(2, 37.2, -37.2) - local actionToBack = CCSkewTo:create(2, 0, 0) - local actionBy = CCSkewBy:create(2, 0.0, -90.0) - local actionBy2 = CCSkewBy:create(2, 45.0, 45.0) + local actionTo = cc.SkewTo:create(2, 37.2, -37.2) + local actionToBack = cc.SkewTo:create(2, 0, 0) + local actionBy = cc.SkewBy:create(2, 0.0, -90.0) + local actionBy2 = cc.SkewBy:create(2, 45.0, 45.0) local actionByBack = actionBy:reverse() - tamara:runAction(CCSequence:createWithTwoActions(actionTo, actionToBack)) - grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) - kathia:runAction(CCSequence:createWithTwoActions(actionBy2, actionBy2:reverse())) + tamara:runAction(cc.Sequence:create(actionTo, actionToBack)) + grossini:runAction(cc.Sequence:create(actionBy, actionByBack)) + kathia:runAction(cc.Sequence:create(actionBy2, actionBy2:reverse())) Helper.subtitleLabel:setString("SkewTo / SkewBy") return layer @@ -169,42 +169,42 @@ end --ActionRotationalSkewVSStandardSkew local function ActionRotationalSkewVSStandardSkew() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) - tamara:removeFromParentAndCleanup(true); - grossini:removeFromParentAndCleanup(true); - kathia:removeFromParentAndCleanup(true); + tamara:removeFromParent(true); + grossini:removeFromParent(true); + kathia:removeFromParent(true); - local s = CCDirector:getInstance():getWinSize(); - local boxSize = CCSize(100.0, 100.0); - local box = CCLayerColor:create(Color4B(255,255,0,255)); - box:setAnchorPoint(CCPoint(0.5,0.5)); + local s = cc.Director:getInstance():getWinSize(); + local boxSize = cc.size(100.0, 100.0); + local box = cc.LayerColor:create(cc.c4b(255,255,0,255)); + box:setAnchorPoint(cc.p(0.5,0.5)); box:setContentSize( boxSize ); box:ignoreAnchorPointForPosition(false); - box:setPosition(CCPoint(s.width/2, s.height - 100 - box:getContentSize().height/2)); + box:setPosition(cc.p(s.width/2, s.height - 100 - box:getContentSize().height/2)); layer:addChild(box); - local label = CCLabelTTF:create("Standard cocos2d Skew", "Marker Felt", 16); - label:setPosition(CCPoint(s.width/2, s.height - 100 + label:getContentSize().height)); + local label = cc.LabelTTF:create("Standard cocos2d Skew", "Marker Felt", 16); + label:setPosition(cc.p(s.width/2, s.height - 100 + label:getContentSize().height)); layer:addChild(label); - local actionTo = CCSkewBy:create(2, 360, 0); - local actionToBack = CCSkewBy:create(2, -360, 0); - local seq = CCSequence:createWithTwoActions(actionTo, actionToBack) + local actionTo = cc.SkewBy:create(2, 360, 0); + local actionToBack = cc.SkewBy:create(2, -360, 0); + local seq = cc.Sequence:create(actionTo, actionToBack) box:runAction(seq); - box = CCLayerColor:create(Color4B(255,255,0,255)); - box:setAnchorPoint(CCPoint(0.5,0.5)); + box = cc.LayerColor:create(cc.c4b(255,255,0,255)); + box:setAnchorPoint(cc.p(0.5,0.5)); box:setContentSize(boxSize); box:ignoreAnchorPointForPosition(false); - box:setPosition(CCPoint(s.width/2, s.height - 250 - box:getContentSize().height/2)); + box:setPosition(cc.p(s.width/2, s.height - 250 - box:getContentSize().height/2)); layer:addChild(box); - label = CCLabelTTF:create("Rotational Skew", "Marker Felt", 16); - label:setPosition(CCPoint(s.width/2, s.height - 250 + label:getContentSize().height/2)); + label = cc.LabelTTF:create("Rotational Skew", "Marker Felt", 16); + label:setPosition(cc.p(s.width/2, s.height - 250 + label:getContentSize().height/2)); layer:addChild(label); - local actionTo2 = CCRotateBy:create(2, 360); - local actionToBack2 = CCRotateBy:create(2, -360); - seq = CCSequence:createWithTwoActions(actionTo2, actionToBack2) + local actionTo2 = cc.RotateBy:create(2, 360); + local actionToBack2 = cc.RotateBy:create(2, -360); + seq = cc.Sequence:create(actionTo2, actionToBack2) box:runAction(seq); Helper.subtitleLabel:setString("Skew Comparison") @@ -215,45 +215,45 @@ end -- ActionSkewRotate -------------------------------------- local function ActionSkewRotate() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) - tamara:removeFromParentAndCleanup(true) - grossini:removeFromParentAndCleanup(true) - kathia:removeFromParentAndCleanup(true) + tamara:removeFromParent(true) + grossini:removeFromParent(true) + kathia:removeFromParent(true) - local boxSize = CCSize(100.0, 100.0) + local boxSize = cc.size(100.0, 100.0) - local box = CCLayerColor:create(Color4B(255, 255, 0, 255)) - box:setAnchorPoint(CCPoint(0, 0)) + local box = cc.LayerColor:create(cc.c4b(255, 255, 0, 255)) + box:setAnchorPoint(cc.p(0, 0)) box:setPosition(190, 110) box:setContentSize(boxSize) local markrside = 10.0 - local uL = CCLayerColor:create(Color4B(255, 0, 0, 255)) + local uL = cc.LayerColor:create(cc.c4b(255, 0, 0, 255)) box:addChild(uL) - uL:setContentSize(CCSize(markrside, markrside)) + uL:setContentSize(cc.size(markrside, markrside)) uL:setPosition(0, boxSize.height - markrside) - uL:setAnchorPoint(CCPoint(0, 0)) + uL:setAnchorPoint(cc.p(0, 0)) - local uR = CCLayerColor:create(Color4B(0, 0, 255, 255)) + local uR = cc.LayerColor:create(cc.c4b(0, 0, 255, 255)) box:addChild(uR) - uR:setContentSize(CCSize(markrside, markrside)) + uR:setContentSize(cc.size(markrside, markrside)) uR:setPosition(boxSize.width - markrside, boxSize.height - markrside) - uR:setAnchorPoint(CCPoint(0, 0)) + uR:setAnchorPoint(cc.p(0, 0)) layer:addChild(box) - local actionTo = CCSkewTo:create(2, 0, 2) - local rotateTo = CCRotateTo:create(2, 61.0) - local actionScaleTo = CCScaleTo:create(2, -0.44, 0.47) + local actionTo = cc.SkewTo:create(2, 0, 2) + local rotateTo = cc.RotateTo:create(2, 61.0) + local actionScaleTo = cc.ScaleTo:create(2, -0.44, 0.47) - local actionScaleToBack = CCScaleTo:create(2, 1.0, 1.0) - local rotateToBack = CCRotateTo:create(2, 0) - local actionToBack = CCSkewTo:create(2, 0, 0) + local actionScaleToBack = cc.ScaleTo:create(2, 1.0, 1.0) + local rotateToBack = cc.RotateTo:create(2, 0) + local actionToBack = cc.SkewTo:create(2, 0, 0) - box:runAction(CCSequence:createWithTwoActions(actionTo, actionToBack)) - box:runAction(CCSequence:createWithTwoActions(rotateTo, rotateToBack)) - box:runAction(CCSequence:createWithTwoActions(actionScaleTo, actionScaleToBack)) + box:runAction(cc.Sequence:create(actionTo, actionToBack)) + box:runAction(cc.Sequence:create(rotateTo, rotateToBack)) + box:runAction(cc.Sequence:create(actionScaleTo, actionScaleToBack)) Helper.subtitleLabel:setString("Skew + Rotate + Scale") return layer @@ -263,19 +263,19 @@ end -- ActionJump -------------------------------------- local function ActionJump() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionTo = CCJumpTo:create(2, CCPoint(300,300), 50, 4) - local actionBy = CCJumpBy:create(2, CCPoint(300,0), 50, 4) - local actionUp = CCJumpBy:create(2, CCPoint(0,0), 80, 4) + local actionTo = cc.JumpTo:create(2, cc.p(300,300), 50, 4) + local actionBy = cc.JumpBy:create(2, cc.p(300,0), 50, 4) + local actionUp = cc.JumpBy:create(2, cc.p(0,0), 80, 4) local actionByBack = actionBy:reverse() tamara:runAction(actionTo) - grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) - kathia:runAction(CCRepeatForever:create(actionUp)) + grossini:runAction(cc.Sequence:create(actionBy, actionByBack)) + kathia:runAction(cc.RepeatForever:create(actionUp)) Helper.subtitleLabel:setString("JumpTo / JumpBy") return layer @@ -285,52 +285,59 @@ end -- ActionCardinalSpline -------------------------------------- local function ActionCardinalSpline() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - - local array = CCPointArray:create(20) - array:addControlPoint(CCPoint(0, 0)) - array:addControlPoint(CCPoint(size.width / 2 - 30, 0)) - array:addControlPoint(CCPoint(size.width / 2 - 30, size.height - 80)) - array:addControlPoint(CCPoint(0, size.height - 80)) - array:addControlPoint(CCPoint(0, 0)) - - local action = CCCardinalSplineBy:create(3, array, 0) +--[[ + local array = cc.pArray:create(20) + array:addControlPoint(cc.p(0, 0)) + array:addControlPoint(cc.p(size.width / 2 - 30, 0)) + array:addControlPoint(cc.p(size.width / 2 - 30, size.height - 80)) + array:addControlPoint(cc.p(0, size.height - 80)) + array:addControlPoint(cc.p(0, 0)) +]]-- + local array = { + cc.p(0, 0), + cc.p(size.width / 2 - 30, 0), + cc.p(size.width / 2 - 30, size.height - 80), + cc.p(0, size.height - 80), + cc.p(0, 0), + } + local action = cc.CardinalSplineBy:create(3, array, 0) local reverse = action:reverse() - local seq = CCSequence:createWithTwoActions(action, reverse) + local seq = cc.Sequence:create(action, reverse) - tamara:setPosition(CCPoint(50, 50)) + tamara:setPosition(cc.p(50, 50)) tamara:runAction(seq) - local action2 = CCCardinalSplineBy:create(3, array, 1) + local action2 = cc.CardinalSplineBy:create(3, array, 1) local reverse2 = action2:reverse() - local seq2 = CCSequence:createWithTwoActions(action2, reverse2) + local seq2 = cc.Sequence:create(action2, reverse2) - kathia:setPosition(CCPoint(size.width / 2, 50)) + kathia:setPosition(cc.p(size.width / 2, 50)) kathia:runAction(seq2) - +--[[ local function drawCardinalSpline() kmGLPushMatrix() kmGLTranslatef(50, 50, 0) - CCDrawPrimitives.ccDrawCardinalSpline(array, 0, 100) + cc.DrawPrimitives.ccDrawCardinalSpline(array, 0, 100) kmGLPopMatrix() kmGLPushMatrix() kmGLTranslatef(size.width / 2, 50, 0) - CCDrawPrimitives.ccDrawCardinalSpline(array, 1, 100) + cc.DrawPrimitives.ccDrawCardinalSpline(array, 1, 100) kmGLPopMatrix() end array:retain() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(size.width, size.height)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(size.width, size.height)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) glNode:registerScriptDrawHandler(drawCardinalSpline) layer:addChild(glNode,-10) glNode:setPosition( size.width / 2, size.height / 2) - +]]-- Helper.titleLabel:setString("CardinalSplineBy / CardinalSplineAt") Helper.subtitleLabel:setString("Cardinal Spline paths.\nTesting different tensions for one array") return layer @@ -340,56 +347,75 @@ end -- ActionCatmullRom -------------------------------------- local function ActionCatmullRom() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - tamara:setPosition(CCPoint(50, 50)) + tamara:setPosition(cc.p(50, 50)) +--[[ + local array = cc.pArray:create(20) + array:addControlPoint(cc.p(0, 0)) + array:addControlPoint(cc.p(80, 80)) + array:addControlPoint(cc.p(size.width - 80, 80)) + array:addControlPoint(cc.p(size.width - 80, size.height - 80)) + array:addControlPoint(cc.p(80, size.height - 80)) + array:addControlPoint(cc.p(80, 80)) + array:addControlPoint(cc.p(size.width / 2, size.height / 2)) + ]]-- + local array = { + cc.p(0, 0), + cc.p(80, 80), + cc.p(size.width - 80, 80), + cc.p(size.width - 80, size.height - 80), + cc.p(80, size.height - 80), + cc.p(80, 80), + cc.p(size.width / 2, size.height / 2), + } - local array = CCPointArray:create(20) - array:addControlPoint(CCPoint(0, 0)) - array:addControlPoint(CCPoint(80, 80)) - array:addControlPoint(CCPoint(size.width - 80, 80)) - array:addControlPoint(CCPoint(size.width - 80, size.height - 80)) - array:addControlPoint(CCPoint(80, size.height - 80)) - array:addControlPoint(CCPoint(80, 80)) - array:addControlPoint(CCPoint(size.width / 2, size.height / 2)) - - local action = CCCatmullRomBy:create(3, array) + local action = cc.CatmullRomBy:create(3, array) local reverse = action:reverse() - local seq = CCSequence:createWithTwoActions(action, reverse) + local seq = cc.Sequence:create(action, reverse) tamara:runAction(seq) +--[[ + local array2 = cc.pArray:create(20) + array2:addControlPoint(cc.p(size.width / 2, 30)) + array2:addControlPoint(cc.p(size.width -80, 30)) + array2:addControlPoint(cc.p(size.width - 80, size.height - 80)) + array2:addControlPoint(cc.p(size.width / 2, size.height - 80)) + array2:addControlPoint(cc.p(size.width / 2, 30)) + ]]-- + local array2 = { + cc.p(size.width / 2, 30), + cc.p(size.width -80, 30), + cc.p(size.width - 80, size.height - 80), + cc.p(size.width / 2, size.height - 80), + cc.p(size.width / 2, 30), + } - local array2 = CCPointArray:create(20) - array2:addControlPoint(CCPoint(size.width / 2, 30)) - array2:addControlPoint(CCPoint(size.width -80, 30)) - array2:addControlPoint(CCPoint(size.width - 80, size.height - 80)) - array2:addControlPoint(CCPoint(size.width / 2, size.height - 80)) - array2:addControlPoint(CCPoint(size.width / 2, 30)) - - local action2 = CCCatmullRomTo:create(3, array2) + local action2 = cc.CatmullRomTo:create(3, array2) local reverse2 = action2:reverse() - local seq2 = CCSequence:createWithTwoActions(action2, reverse2) + local seq2 = cc.Sequence:create(action2, reverse2) kathia:runAction(seq2) - +--[[ local function drawCatmullRom() kmGLPushMatrix() kmGLTranslatef(50, 50, 0) - CCDrawPrimitives.ccDrawCatmullRom(array, 50) + cc.DrawPrimitives.ccDrawCatmullRom(array, 50) kmGLPopMatrix() - CCDrawPrimitives.ccDrawCatmullRom(array2,50) + cc.DrawPrimitives.ccDrawCatmullRom(array2,50) end array:retain() array2:retain() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(size.width, size.height)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(size.width, size.height)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) glNode:registerScriptDrawHandler(drawCatmullRom) layer:addChild(glNode,-10) glNode:setPosition( size.width / 2, size.height / 2) + ]]-- Helper.titleLabel:setString("CatmullRomBy / CatmullRomTo") Helper.subtitleLabel:setString("Catmull Rom spline paths. Testing reverse too") @@ -400,33 +426,46 @@ end -- ActionBezier -------------------------------------- local function ActionBezier() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) -- sprite 1 + --[[ local bezier = ccBezierConfig() - bezier.controlPoint_1 = CCPoint(0, size.height / 2) - bezier.controlPoint_2 = CCPoint(300, - size.height / 2) - bezier.endPosition = CCPoint(300, 100) - - local bezierForward = CCBezierBy:create(3, bezier) + bezier.controlPoint_1 = cc.p(0, size.height / 2) + bezier.controlPoint_2 = cc.p(300, - size.height / 2) + bezier.endPosition = cc.p(300, 100) + ]]-- + local bezier = { + cc.p(0, size.height / 2), + cc.p(300, - size.height / 2), + cc.p(300, 100), + } + local bezierForward = cc.BezierBy:create(3, bezier) local bezierBack = bezierForward:reverse() - local rep = CCRepeatForever:create(CCSequence:createWithTwoActions(bezierForward, bezierBack)) + local rep = cc.RepeatForever:create(cc.Sequence:create(bezierForward, bezierBack)) -- sprite 2 - tamara:setPosition(CCPoint(80,160)) + tamara:setPosition(cc.p(80,160)) + --[[ local bezier2 = ccBezierConfig() - bezier2.controlPoint_1 = CCPoint(100, size.height / 2) - bezier2.controlPoint_2 = CCPoint(200, - size.height / 2) - bezier2.endPosition = CCPoint(240, 160) + bezier2.controlPoint_1 = cc.p(100, size.height / 2) + bezier2.controlPoint_2 = cc.p(200, - size.height / 2) + bezier2.endPosition = cc.p(240, 160) + ]]-- + local bezier2 ={ + cc.p(100, size.height / 2), + cc.p(200, - size.height / 2), + cc.p(240, 160) + } - local bezierTo1 = CCBezierTo:create(2, bezier2) + local bezierTo1 = cc.BezierTo:create(2, bezier2) -- sprite 3 - kathia:setPosition(CCPoint(400,160)) - local bezierTo2 = CCBezierTo:create(2, bezier2) + kathia:setPosition(cc.p(400,160)) + local bezierTo2 = cc.BezierTo:create(2, bezier2) grossini:runAction(rep) tamara:runAction(bezierTo1) @@ -440,13 +479,13 @@ end -- ActionBlink -------------------------------------- local function ActionBlink() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local action1 = CCBlink:create(2, 10) - local action2 = CCBlink:create(2, 5) + local action1 = cc.Blink:create(2, 10) + local action2 = cc.Blink:create(2, 5) tamara:runAction(action1) kathia:runAction(action2) @@ -460,20 +499,20 @@ end -- ActionFade -------------------------------------- local function ActionFade() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) tamara:setOpacity(0) - local action1 = CCFadeIn:create(1) + local action1 = cc.FadeIn:create(1) local action1Back = action1:reverse() - local action2 = CCFadeOut:create(1) + local action2 = cc.FadeOut:create(1) local action2Back = action2:reverse() - tamara:runAction(CCSequence:createWithTwoActions( action1, action1Back)) - kathia:runAction(CCSequence:createWithTwoActions( action2, action2Back)) + tamara:runAction(cc.Sequence:create( action1, action1Back)) + kathia:runAction(cc.Sequence:create( action2, action2Back)) Helper.subtitleLabel:setString("FadeIn / FadeOut") @@ -484,17 +523,17 @@ end -- ActionTint -------------------------------------- local function ActionTint() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local action1 = CCTintTo:create(2, 255, 0, 255) - local action2 = CCTintBy:create(2, -127, -255, -127) + local action1 = cc.TintTo:create(2, 255, 0, 255) + local action2 = cc.TintBy:create(2, -127, -255, -127) local action2Back = action2:reverse() tamara:runAction(action1) - kathia:runAction(CCSequence:createWithTwoActions(action2, action2Back)) + kathia:runAction(cc.Sequence:create(action2, action2Back)) Helper.subtitleLabel:setString("TintTo / TintBy") @@ -505,12 +544,12 @@ end -- ActionAnimate -------------------------------------- local function ActionAnimate() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local animation = CCAnimation:create() + local animation = cc.Animation:create() local number, name for i = 1, 14 do if i < 10 then @@ -519,27 +558,27 @@ local function ActionAnimate() number = i end name = "Images/grossini_dance_"..number..".png" - animation:addSpriteFrameWithFileName(name) + animation:addSpriteFrameWithFile(name) end -- should last 2.8 seconds. And there are 14 frames. animation:setDelayPerUnit(2.8 / 14.0) animation:setRestoreOriginalFrame(true) - local action = CCAnimate:create(animation) - grossini:runAction(CCSequence:createWithTwoActions(action, action:reverse())) + local action = cc.Animate:create(animation) + grossini:runAction(cc.Sequence:create(action, action:reverse())) - local cache = CCAnimationCache:getInstance() - cache:addAnimationsWithFile("animations/animations-2.plist") - local animation2 = cache:animationByName("dance_1") + local cache = cc.AnimationCache:getInstance() + cache:addAnimations("animations/animations-2.plist") + local animation2 = cache:getAnimation("dance_1") - local action2 = CCAnimate:create(animation2) - tamara:runAction(CCSequence:createWithTwoActions(action2, action2:reverse())) + local action2 = cc.Animate:create(animation2) + tamara:runAction(cc.Sequence:create(action2, action2:reverse())) local animation3 = animation2:clone() -- problem - tolua.cast(animation3,"CCAnimation"):setLoops(4) + tolua.cast(animation3,"Animation"):setLoops(4) - local action3 = CCAnimate:create(animation3) + local action3 = cc.Animate:create(animation3) kathia:runAction(action3) Helper.titleLabel:setString("Animation") @@ -552,14 +591,14 @@ end -- ActionSequence -------------------------------------- local function ActionSequence() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local action = CCSequence:createWithTwoActions( - CCMoveBy:create(2, CCPoint(240,0)), - CCRotateBy:create(2, 540)) + local action = cc.Sequence:create( + cc.MoveBy:create(2, cc.p(240,0)), + cc.RotateBy:create(2, 540)) grossini:runAction(action) @@ -574,42 +613,44 @@ end local actionSequenceLayer = nil local function ActionSequenceCallback1() - local label = CCLabelTTF:create("callback 1 called", "Marker Felt", 16) + local label = cc.LabelTTF:create("callback 1 called", "Marker Felt", 16) label:setPosition(size.width / 4, size.height / 2) actionSequenceLayer:addChild(label) end local function ActionSequenceCallback2(sender) - local label = CCLabelTTF:create("callback 2 called", "Marker Felt", 16) - label:setPosition(CCPoint(size.width / 4 * 2, size.height / 2)) + local label = cc.LabelTTF:create("callback 2 called", "Marker Felt", 16) + label:setPosition(cc.p(size.width / 4 * 2, size.height / 2)) actionSequenceLayer:addChild(label) end local function ActionSequenceCallback3(sender) - local label = CCLabelTTF:create("callback 3 called", "Marker Felt", 16) - label:setPosition(CCPoint(size.width / 4 * 3, size.height / 2)) + local label = cc.LabelTTF:create("callback 3 called", "Marker Felt", 16) + label:setPosition(cc.p(size.width / 4 * 3, size.height / 2)) actionSequenceLayer:addChild(label) end local function ActionSequence2() - actionSequenceLayer = CCLayer:create() + actionSequenceLayer = cc.Layer:create() initWithLayer(actionSequenceLayer) alignSpritesLeft(1) grossini:setVisible(false) - local array = CCArray:create() - array:addObject(CCPlace:create(CCPoint(200,200))) - array:addObject(CCShow:create()) - array:addObject(CCMoveBy:create(1, CCPoint(100,0))) - array:addObject(CCCallFunc:create(ActionSequenceCallback1)) - array:addObject(CCCallFunc:create(ActionSequenceCallback2)) - array:addObject(CCCallFunc:create(ActionSequenceCallback3)) + --[[ + local array = cc.Array:create() + array:addObject(cc.Place:create(cc.p(200,200))) + array:addObject(cc.Show:create()) + array:addObject(cc.MoveBy:create(1, cc.p(100,0))) + array:addObject(cc.CallFunc:create(ActionSequenceCallback1)) + array:addObject(cc.CallFunc:create(ActionSequenceCallback2)) + array:addObject(cc.CallFunc:create(ActionSequenceCallback3)) + ]]-- - local action = CCSequence:create(array) + local action = cc.Sequence:create(cc.Place:create(cc.p(200,200)),cc.Show:create(),cc.MoveBy:create(1, cc.p(100,0)), cc.CallFunc:create(ActionSequenceCallback1),cc.CallFunc:create(ActionSequenceCallback2),cc.CallFunc:create(ActionSequenceCallback3)) grossini:runAction(action) @@ -621,14 +662,14 @@ end -- ActionSpawn -------------------------------------- local function ActionSpawn() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local action = CCSpawn:createWithTwoActions( - CCJumpBy:create(2, CCPoint(300,0), 50, 4), - CCRotateBy:create( 2, 720)) + local action = cc.Spawn:create( + cc.JumpBy:create(2, cc.p(300,0), 50, 4), + cc.RotateBy:create( 2, 720)) grossini:runAction(action) @@ -641,13 +682,13 @@ end -- ActionReverse -------------------------------------- local function ActionReverse() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local jump = CCJumpBy:create(2, CCPoint(300,0), 50, 4) - local action = CCSequence:createWithTwoActions(jump, jump:reverse()) + local jump = cc.JumpBy:create(2, cc.p(300,0), 50, 4) + local action = cc.Sequence:create(jump, jump:reverse()) grossini:runAction(action) @@ -660,17 +701,19 @@ end -- ActionDelaytime -------------------------------------- local function ActionDelaytime() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local move = CCMoveBy:create(1, CCPoint(150,0)) - local array = CCArray:create() + local move = cc.MoveBy:create(1, cc.p(150,0)) + --[[ + local array = cc.Array:create() array:addObject(move) - array:addObject(CCDelayTime:create(2)) + array:addObject(cc.DelayTime:create(2)) array:addObject(move) - local action = CCSequence:create(array) + ]]-- + local action = cc.Sequence:create(move, cc.DelayTime:create(2), move) grossini:runAction(action) @@ -682,16 +725,16 @@ end -- ActionRepeat -------------------------------------- local function ActionRepeat() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(2) - local a1 = CCMoveBy:create(1, CCPoint(150,0)) - local action1 = CCRepeat:create(CCSequence:createWithTwoActions(CCPlace:create(CCPoint(60,60)), a1), 3) + local a1 = cc.MoveBy:create(1, cc.p(150,0)) + local action1 = cc.Repeat:create(cc.Sequence:create(cc.Place:create(cc.p(60,60)), a1), 3) - local a2 = CCMoveBy:create(1, CCPoint(150,0)) - local action2 = CCRepeatForever:create(CCSequence:createWithTwoActions(a2, a1:reverse())) + local a2 = cc.MoveBy:create(1, cc.p(150,0)) + local action2 = cc.RepeatForever:create(cc.Sequence:create(a2, a1:reverse())) kathia:runAction(action1) tamara:runAction(action2) @@ -704,20 +747,20 @@ end -- ActionRepeatForever -------------------------------------- local function repeatForever(sender) - local repeatAction = CCRepeatForever:create(CCRotateBy:create(1.0, 360)) + local repeatAction = cc.RepeatForever:create(cc.RotateBy:create(1.0, 360)) sender:runAction(repeatAction) end local function ActionRepeatForever() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(1) - local action = CCSequence:createWithTwoActions( - CCDelayTime:create(1), - CCCallFunc:create(repeatForever) ) + local action = cc.Sequence:create( + cc.DelayTime:create(1), + cc.CallFunc:create(repeatForever) ) grossini:runAction(action) @@ -729,16 +772,16 @@ end -- ActionRotateToRepeat -------------------------------------- local function ActionRotateToRepeat() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local act1 = CCRotateTo:create(1, 90) - local act2 = CCRotateTo:create(1, 0) - local seq = CCSequence:createWithTwoActions(act1, act2) - local rep1 = CCRepeatForever:create(seq) - local rep2 = CCRepeat:create(tolua.cast(seq:clone(), "CCSequence"), 10) + local act1 = cc.RotateTo:create(1, 90) + local act2 = cc.RotateTo:create(1, 0) + local seq = cc.Sequence:create(act1, act2) + local rep1 = cc.RepeatForever:create(seq) + local rep2 = cc.Repeat:create(tolua.cast(seq:clone(), "Sequence"), 10) tamara:runAction(rep1) kathia:runAction(rep2) @@ -752,22 +795,22 @@ end -- ActionRotateJerk -------------------------------------- local function ActionRotateJerk() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local seq = CCSequence:createWithTwoActions( - CCRotateTo:create(0.5, -20), - CCRotateTo:create(0.5, 20)) + local seq = cc.Sequence:create( + cc.RotateTo:create(0.5, -20), + cc.RotateTo:create(0.5, 20)) - local rep1 = CCRepeat:create(seq, 10) + local rep1 = cc.Repeat:create(seq, 10) - local seq2 = CCSequence:createWithTwoActions( - CCRotateTo:create(0.5, -20), - CCRotateTo:create(0.5, 20)) + local seq2 = cc.Sequence:create( + cc.RotateTo:create(0.5, -20), + cc.RotateTo:create(0.5, 20)) - local rep2 = CCRepeatForever:create(seq2) + local rep2 = cc.RepeatForever:create(seq2) tamara:runAction(rep1) kathia:runAction(rep2) @@ -782,47 +825,49 @@ end local callFuncLayer = nil local function CallFucnCallback1() - local label = CCLabelTTF:create("callback 1 called", "Marker Felt", 16) + local label = cc.LabelTTF:create("callback 1 called", "Marker Felt", 16) label:setPosition(size.width / 4, size.height / 2) callFuncLayer:addChild(label) end local function CallFucnCallback2(sender) - local label = CCLabelTTF:create("callback 2 called", "Marker Felt", 16) + local label = cc.LabelTTF:create("callback 2 called", "Marker Felt", 16) label:setPosition(size.width / 4 * 2, size.height / 2) callFuncLayer:addChild(label) end local function CallFucnCallback3(sender) - local label = CCLabelTTF:create("callback 3 called", "Marker Felt", 16) + local label = cc.LabelTTF:create("callback 3 called", "Marker Felt", 16) label:setPosition(size.width / 4 * 3, size.height / 2) callFuncLayer:addChild(label) end local function ActionCallFunc() - callFuncLayer = CCLayer:create() + callFuncLayer = cc.Layer:create() initWithLayer(callFuncLayer) centerSprites(3) - local action = CCSequence:createWithTwoActions( - CCMoveBy:create(2, CCPoint(200,0)), - CCCallFunc:create(CallFucnCallback1) ) - - local array = CCArray:create() - array:addObject(CCScaleBy:create(2, 2)) - array:addObject(CCFadeOut:create(2)) - array:addObject(CCCallFunc:create(CallFucnCallback2)) - local action2 = CCSequence:create(array) - - local array2 = CCArray:create() - array2:addObject(CCRotateBy:create(3 , 360)) - array2:addObject(CCFadeOut:create(2)) - array2:addObject(CCCallFunc:create(CallFucnCallback3)) - local action3 = CCSequence:create(array2) + local action = cc.Sequence:create( + cc.MoveBy:create(2, cc.p(200,0)), + cc.CallFunc:create(CallFucnCallback1) ) +--[[ + local array = cc.Array:create() + array:addObject(cc.ScaleBy:create(2, 2)) + array:addObject(cc.FadeOut:create(2)) + array:addObject(cc.CallFunc:create(CallFucnCallback2)) + ]]-- + local action2 = cc.Sequence:create(cc.ScaleBy:create(2, 2),cc.FadeOut:create(2),cc.CallFunc:create(CallFucnCallback2)) +--[[ + local array2 = cc.Array:create() + array2:addObject(cc.RotateBy:create(3 , 360)) + array2:addObject(cc.FadeOut:create(2)) + array2:addObject(cc.CallFunc:create(CallFucnCallback3)) + ]]-- + local action3 = cc.Sequence:create(cc.RotateBy:create(3 , 360),cc.FadeOut:create(2),cc.CallFunc:create(CallFucnCallback3)) grossini:runAction(action) tamara:runAction(action2) @@ -838,14 +883,14 @@ end -- passing more than one param to lua script -------------------------------------- local function ActionCallFuncND() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(1) Helper.titleLabel:setString("CallFuncND + auto remove") - Helper.subtitleLabel:setString("CallFuncND + removeFromParentAndCleanup. Grossini dissapears in 2s") + Helper.subtitleLabel:setString("CallFuncND + removeFromParent. Grossini dissapears in 2s") return layer end @@ -853,19 +898,21 @@ end -- ActionReverseSequence -------------------------------------- local function ActionReverseSequence() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local move1 = CCMoveBy:create(1, CCPoint(250,0)) - local move2 = CCMoveBy:create(1, CCPoint(0,50)) - local array = CCArray:create() + local move1 = cc.MoveBy:create(1, cc.p(250,0)) + local move2 = cc.MoveBy:create(1, cc.p(0,50)) + --[[ + local array = cc.Array:create() array:addObject(move1) array:addObject(move2) array:addObject(move1:reverse()) - local seq = CCSequence:create(array) - local action = CCSequence:createWithTwoActions(seq, seq:reverse()) + ]]-- + local seq = cc.Sequence:create(move1, move2, move1:reverse()) + local action = cc.Sequence:create(seq, seq:reverse()) grossini:runAction(action) @@ -877,40 +924,44 @@ end -- ActionReverseSequence2 -------------------------------------- local function ActionReverseSequence2() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(2) -- Test: -- Sequence should work both with IntervalAction and InstantActions - local move1 = CCMoveBy:create(1, CCPoint(250,0)) - local move2 = CCMoveBy:create(1, CCPoint(0,50)) - local tog1 = CCToggleVisibility:create() - local tog2 = CCToggleVisibility:create() - local array = CCArray:createWithCapacity(10) + local move1 = cc.MoveBy:create(1, cc.p(250,0)) + local move2 = cc.MoveBy:create(1, cc.p(0,50)) + local tog1 = cc.ToggleVisibility:create() + local tog2 = cc.ToggleVisibility:create() + --[[ + local array = cc.Array:createWithCapacity(10) array:addObject(move1) array:addObject(tog1) array:addObject(move2) array:addObject(tog2) array:addObject(move1:reverse()) - local seq = CCSequence:create(array) - local action = CCRepeat:create(CCSequence:createWithTwoActions(seq, seq:reverse()), 3) + ]]-- + local seq = cc.Sequence:create(move1, tog1, move2, tog2, move1:reverse()) + local action = cc.Repeat:create(cc.Sequence:create(seq, seq:reverse()), 3) -- Test: -- Also test that the reverse of Hide is Show, and vice-versa kathia:runAction(action) - local move_tamara = CCMoveBy:create(1, CCPoint(100,0)) - local move_tamara2 = CCMoveBy:create(1, CCPoint(50,0)) - local hide = CCHide:create() - local array2 = CCArray:createWithCapacity(10) + local move_tamara = cc.MoveBy:create(1, cc.p(100,0)) + local move_tamara2 = cc.MoveBy:create(1, cc.p(50,0)) + local hide = cc.Hide:create() + --[[ + local array2 = cc.Array:createWithCapacity(10) array2:addObject(move_tamara) array2:addObject(hide) array2:addObject(move_tamara2) - local seq_tamara = CCSequence:create(array2) + ]]-- + local seq_tamara = cc.Sequence:create(move_tamara, hide, move_tamara2) local seq_back = seq_tamara:reverse() - tamara:runAction(CCSequence:createWithTwoActions(seq_tamara, seq_back)) + tamara:runAction(cc.Sequence:create(seq_tamara, seq_back)) Helper.subtitleLabel:setString("Reverse a sequence2") return layer @@ -920,31 +971,31 @@ end -- ActionOrbit -------------------------------------- local function ActionOrbit() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local orbit1 = CCOrbitCamera:create(2,1, 0, 0, 180, 0, 0) - local action1 = CCSequence:createWithTwoActions(orbit1, orbit1:reverse()) + local orbit1 = cc.OrbitCamera:create(2,1, 0, 0, 180, 0, 0) + local action1 = cc.Sequence:create(orbit1, orbit1:reverse()) - local orbit2 = CCOrbitCamera:create(2,1, 0, 0, 180, -45, 0) - local action2 = CCSequence:createWithTwoActions(orbit2, orbit2:reverse()) + local orbit2 = cc.OrbitCamera:create(2,1, 0, 0, 180, -45, 0) + local action2 = cc.Sequence:create(orbit2, orbit2:reverse()) - local orbit3 = CCOrbitCamera:create(2,1, 0, 0, 180, 90, 0) - local action3 = CCSequence:createWithTwoActions(orbit3, orbit3:reverse()) + local orbit3 = cc.OrbitCamera:create(2,1, 0, 0, 180, 90, 0) + local action3 = cc.Sequence:create(orbit3, orbit3:reverse()) - kathia:runAction(CCRepeatForever:create(action1)) - tamara:runAction(CCRepeatForever:create(action2)) - grossini:runAction(CCRepeatForever:create(action3)) + kathia:runAction(cc.RepeatForever:create(action1)) + tamara:runAction(cc.RepeatForever:create(action2)) + grossini:runAction(cc.RepeatForever:create(action3)) - local move = CCMoveBy:create(3, CCPoint(100,-100)) + local move = cc.MoveBy:create(3, cc.p(100,-100)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - local rfe = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(move, move_back) + local rfe = cc.RepeatForever:create(seq) kathia:runAction(rfe) - tamara:runAction(tolua.cast(rfe:clone(), "CCActionInterval")) - grossini:runAction(tolua.cast(rfe:clone(), "CCActionInterval")) + tamara:runAction(tolua.cast(rfe:clone(), "ActionInterval")) + grossini:runAction(tolua.cast(rfe:clone(), "ActionInterval")) Helper.subtitleLabel:setString("OrbitCamera action") @@ -955,32 +1006,32 @@ end -- ActionFollow -------------------------------------- local function ActionFollow() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(1) - grossini:setPosition(CCPoint(-200, size.height / 2)) - local move = CCMoveBy:create(2, CCPoint(size.width * 3, 0)) + grossini:setPosition(cc.p(-200, size.height / 2)) + local move = cc.MoveBy:create(2, cc.p(size.width * 3, 0)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - local rep = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(move, move_back) + local rep = cc.RepeatForever:create(seq) grossini:runAction(rep) - layer:runAction(CCFollow:create(grossini, CCRect(0, 0, size.width * 2 - 100, size.height))) + layer:runAction(cc.Follow:create(grossini, cc.rect(0, 0, size.width * 2 - 100, size.height))) local function draw() - local winSize = CCDirector:getInstance():getWinSize() + local winSize = cc.Director:getInstance():getWinSize() local x = winSize.width * 2 - 100 local y = winSize.height - local vertices = { CCPoint(5, 5), CCPoint(x - 5, 5), CCPoint(x - 5,y - 5), CCPoint(5,y - 5) } - CCDrawPrimitives.ccDrawPoly(vertices, 4, true) + local vertices = { cc.p(5, 5), cc.p(x - 5, 5), cc.p(x - 5,y - 5), cc.p(5,y - 5) } + gl.DrawPrimitives.ccDrawPoly(vertices, 4, true) end local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(size.width, size.height)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(size.width, size.height)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) glNode:registerScriptDrawHandler(draw) layer:addChild(glNode,-10) glNode:setPosition( size.width / 2, size.height / 2) @@ -993,26 +1044,27 @@ end -- ActionTargeted -------------------------------------- local function ActionTargeted() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local jump1 = CCJumpBy:create(2, CCPoint(0, 0), 100, 3) - local jump2 = CCJumpBy:create(2, CCPoint(0, 0), 100, 3) - local rot1 = CCRotateBy:create(1, 360) - local rot2 = CCRotateBy:create(1, 360) + local jump1 = cc.JumpBy:create(2, cc.p(0, 0), 100, 3) + local jump2 = cc.JumpBy:create(2, cc.p(0, 0), 100, 3) + local rot1 = cc.RotateBy:create(1, 360) + local rot2 = cc.RotateBy:create(1, 360) - local t1 = CCTargetedAction:create(kathia, jump2) - local t2 = CCTargetedAction:create(kathia, rot2) - - local array = CCArray:createWithCapacity(10) + local t1 = cc.TargetedAction:create(kathia, jump2) + local t2 = cc.TargetedAction:create(kathia, rot2) +--[[ + local array = cc.Array:createWithCapacity(10) array:addObject(jump1) array:addObject(t1) array:addObject(rot1) array:addObject(t2) - local seq = CCSequence:create(array) - local always = CCRepeatForever:create(seq) + ]]-- + local seq = cc.Sequence:create(jump1, t1, rot1, t2) + local always = cc.RepeatForever:create(seq) tamara:runAction(always) @@ -1032,10 +1084,10 @@ local PauseResumeActions_resumeEntry = nil local function ActionPause(dt) cclog("Pausing") - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() scheduler:unscheduleScriptEntry(PauseResumeActions_pauseEntry) - local director = CCDirector:getInstance() + local director = cc.Director:getInstance() pausedTargets = director:getActionManager():pauseAllRunningActions() pausedTargets:retain() end @@ -1043,10 +1095,10 @@ end local function ActionResume(dt) cclog("Resuming") - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() scheduler:unscheduleScriptEntry(PauseResumeActions_resumeEntry) - local director = CCDirector:getInstance() + local director = cc.Director:getInstance() if pausedTargets ~= nil then -- problem: will crash here. Try fixing me! director:getActionManager():resumeTargets(pausedTargets) @@ -1055,7 +1107,7 @@ local function ActionResume(dt) end local function PauseResumeActions_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then PauseResumeActions_pauseEntry = scheduler:scheduleScriptFunc(ActionPause, 3, false) PauseResumeActions_resumeEntry = scheduler:scheduleScriptFunc(ActionResume, 5, false) @@ -1066,13 +1118,13 @@ local function PauseResumeActions_onEnterOrExit(tag) end local function PauseResumeActions() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - tamara:runAction(CCRepeatForever:create(CCRotateBy:create(3, 360))) - kathia:runAction(CCRepeatForever:create(CCRotateBy:create(3, 360))) + tamara:runAction(cc.RepeatForever:create(cc.RotateBy:create(3, 360))) + kathia:runAction(cc.RepeatForever:create(cc.RotateBy:create(3, 360))) layer:registerScriptHandler(PauseResumeActions_onEnterOrExit) @@ -1093,15 +1145,15 @@ local function Issue1305_log(sender) end local function addSprite(dt) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() scheduler:unscheduleScriptEntry(Issue1305_entry) - spriteTmp:setPosition(CCPoint(250, 250)) + spriteTmp:setPosition(cc.p(250, 250)) Issue1305_layer:addChild(spriteTmp) end local function Issue1305_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then Issue1305_entry = scheduler:scheduleScriptFunc(addSprite, 2, false) elseif tag == "exit" then @@ -1110,13 +1162,13 @@ local function Issue1305_onEnterOrExit(tag) end local function ActionIssue1305() - Issue1305_layer = CCLayer:create() + Issue1305_layer = cc.Layer:create() initWithLayer(Issue1305_layer) centerSprites(0) - spriteTmp = CCSprite:create("Images/grossini.png") - spriteTmp:runAction(CCCallFunc:create(Issue1305_log)) + spriteTmp = cc.Sprite:create("Images/grossini.png") + spriteTmp:runAction(cc.CallFunc:create(Issue1305_log)) Issue1305_layer:registerScriptHandler(Issue1305_onEnterOrExit) @@ -1145,25 +1197,25 @@ local function Issue1305_2_log4() end local function ActionIssue1305_2() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(0) - local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(CCPoint(200,200)) + local spr = cc.Sprite:create("Images/grossini.png") + spr:setPosition(cc.p(200,200)) layer:addChild(spr) - local act1 = CCMoveBy:create(2 ,CCPoint(0, 100)) - local act2 = CCCallFunc:create(Issue1305_2_log1) - local act3 = CCMoveBy:create(2, CCPoint(0, -100)) - local act4 = CCCallFunc:create(Issue1305_2_log2) - local act5 = CCMoveBy:create(2, CCPoint(100, -100)) - local act6 = CCCallFunc:create(Issue1305_2_log3) - local act7 = CCMoveBy:create(2, CCPoint(-100, 0)) - local act8 = CCCallFunc:create(Issue1305_2_log4) - - local array = CCArray:create() + local act1 = cc.MoveBy:create(2 ,cc.p(0, 100)) + local act2 = cc.CallFunc:create(Issue1305_2_log1) + local act3 = cc.MoveBy:create(2, cc.p(0, -100)) + local act4 = cc.CallFunc:create(Issue1305_2_log2) + local act5 = cc.MoveBy:create(2, cc.p(100, -100)) + local act6 = cc.CallFunc:create(Issue1305_2_log3) + local act7 = cc.MoveBy:create(2, cc.p(-100, 0)) + local act8 = cc.CallFunc:create(Issue1305_2_log4) +--[[ + local array = cc.Array:create() array:addObject(act1) array:addObject(act2) array:addObject(act3) @@ -1172,9 +1224,10 @@ local function ActionIssue1305_2() array:addObject(act6) array:addObject(act7) array:addObject(act8) - local actF = CCSequence:create(array) + ]]-- + local actF = cc.Sequence:create(act1, act2, act3, act4, act5, act6, act7, act8) - CCDirector:getInstance():getActionManager():addAction(actF ,spr, false) + cc.Director:getInstance():getActionManager():addAction(actF ,spr, false) Helper.titleLabel:setString("Issue 1305 #2") Helper.subtitleLabel:setString("See console. You should only see one message for each block") @@ -1185,19 +1238,19 @@ end -- ActionIssue1288 -------------------------------------- local function ActionIssue1288() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(0) - local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(CCPoint(100, 100)) + local spr = cc.Sprite:create("Images/grossini.png") + spr:setPosition(cc.p(100, 100)) layer:addChild(spr) - local act1 = CCMoveBy:create(0.5, CCPoint(100, 0)) + local act1 = cc.MoveBy:create(0.5, cc.p(100, 0)) local act2 = act1:reverse() - local act3 = CCSequence:createWithTwoActions(act1, act2) - local act4 = CCRepeat:create(act3, 2) + local act3 = cc.Sequence:create(act1, act2) + local act4 = cc.Repeat:create(act3, 2) spr:runAction(act4) @@ -1210,17 +1263,17 @@ end -- ActionIssue1288_2 -------------------------------------- local function ActionIssue1288_2() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(0) - local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(CCPoint(100, 100)) + local spr = cc.Sprite:create("Images/grossini.png") + spr:setPosition(cc.p(100, 100)) layer:addChild(spr) - local act1 = CCMoveBy:create(0.5, CCPoint(100, 0)) - spr:runAction(CCRepeat:create(act1, 1)) + local act1 = cc.MoveBy:create(0.5, cc.p(100, 0)) + spr:runAction(cc.Repeat:create(act1, 1)) Helper.titleLabel:setString("Issue 1288 #2") Helper.subtitleLabel:setString("Sprite should move 100 pixels, and stay there") @@ -1235,26 +1288,26 @@ local function logSprRotation(sender) end local function ActionIssue1327() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(0) - local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(CCPoint(100, 100)) + local spr = cc.Sprite:create("Images/grossini.png") + spr:setPosition(cc.p(100, 100)) layer:addChild(spr) - local act1 = CCCallFunc:create(logSprRotation) - local act2 = CCRotateBy:create(0.25, 45) - local act3 = CCCallFunc:create(logSprRotation) - local act4 = CCRotateBy:create(0.25, 45) - local act5 = CCCallFunc:create(logSprRotation) - local act6 = CCRotateBy:create(0.25, 45) - local act7 = CCCallFunc:create(logSprRotation) - local act8 = CCRotateBy:create(0.25, 45) - local act9 = CCCallFunc:create(logSprRotation) - - local array = CCArray:create() + local act1 = cc.CallFunc:create(logSprRotation) + local act2 = cc.RotateBy:create(0.25, 45) + local act3 = cc.CallFunc:create(logSprRotation) + local act4 = cc.RotateBy:create(0.25, 45) + local act5 = cc.CallFunc:create(logSprRotation) + local act6 = cc.RotateBy:create(0.25, 45) + local act7 = cc.CallFunc:create(logSprRotation) + local act8 = cc.RotateBy:create(0.25, 45) + local act9 = cc.CallFunc:create(logSprRotation) +--[[ + local array = cc.Array:create() array:addObject(act1) array:addObject(act2) array:addObject(act3) @@ -1264,7 +1317,8 @@ local function ActionIssue1327() array:addObject(act7) array:addObject(act8) array:addObject(act9) - spr:runAction(CCSequence:create(array)) + ]]-- + spr:runAction(cc.Sequence:create(act1, act2, act3, act4, act5, act6, act7,act8, act9)) Helper.titleLabel:setString("Issue 1327") Helper.subtitleLabel:setString("See console: You should see: 0, 45, 90, 135, 180") @@ -1273,7 +1327,7 @@ end function ActionsTest() cclog("ActionsTest") - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { ActionManual, diff --git a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua index 2554843571..523c061e08 100644 --- a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua +++ b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua @@ -1,65 +1,72 @@ require "luaScript/extern" +require "Cocos2d" VisibleRect = class("VisibleRect") VisibleRect.__index = VisibleRect -VisibleRect.s_visibleRect = CCRect:new() +VisibleRect.s_visibleRect = cc.rect(0,0,0,0) function VisibleRect:lazyInit() - if (self.s_visibleRect.size.width == 0.0 and self.s_visibleRect.size.height == 0.0) then - local pEGLView = CCEGLView:getInstance(); - self.s_visibleRect.origin = pEGLView:getVisibleOrigin(); - self.s_visibleRect.size = pEGLView:getVisibleSize(); + if (self.s_visibleRect.width == 0.0 and self.s_visibleRect.height == 0.0) then + --[[ + local pEGLView = cc.EGLView:getInstance() + local origin = pEGLView:getVisibleOrigin() + ]]-- + self.s_visibleRect.x = 0 + self.s_visibleRect.y = 0 + local size = cc.Director:getInstance():getWinSize() + self.s_visibleRect.width = size.width + self.s_visibleRect.height = size.height end end function VisibleRect:getVisibleRect() - self:lazyInit(); - return CCRect(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y, self.s_visibleRect.size.width, self.s_visibleRect.size.height); + self:lazyInit() + return cc.Rect(self.s_visibleRect.x, self.s_visibleRect.y, self.s_visibleRect.width, self.s_visibleRect.height) end function VisibleRect:left() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + self:lazyInit() + return cc.p(self.s_visibleRect.x, self.s_visibleRect.y+self.s_visibleRect.height/2) end function VisibleRect:right() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width, self.s_visibleRect.y+self.s_visibleRect.height/2) end function VisibleRect:top() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width/2, self.s_visibleRect.y+self.s_visibleRect.height) end function VisibleRect:bottom() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width/2, self.s_visibleRect.y) end function VisibleRect:center() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width/2, self.s_visibleRect.y+self.s_visibleRect.height/2) end function VisibleRect:leftTop() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + self:lazyInit() + return cc.p(self.s_visibleRect.x, self.s_visibleRect.y+self.s_visibleRect.height) end function VisibleRect:rightTop() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width, self.s_visibleRect.y+self.s_visibleRect.height) end function VisibleRect:leftBottom() - self:lazyInit(); - return self.s_visibleRect.origin; + self:lazyInit() + return cc.p(self.s_visibleRect.x,self.s_visibleRect.y) end function VisibleRect:rightBottom() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width, self.s_visibleRect.y) end diff --git a/samples/Lua/TestLua/Resources/luaScript/controller.lua b/samples/Lua/TestLua/Resources/luaScript/controller.lua index 26a4954403..7a8151f331 100644 --- a/samples/Lua/TestLua/Resources/luaScript/controller.lua +++ b/samples/Lua/TestLua/Resources/luaScript/controller.lua @@ -8,6 +8,6 @@ require "luaScript/mainMenu" -- run -local scene = CCScene:create() +local scene = cc.Scene:create() scene:addChild(CreateTestMenu()) -CCDirector:getInstance():runWithScene(scene) +cc.Director:getInstance():runWithScene(scene) diff --git a/samples/Lua/TestLua/Resources/luaScript/helper.lua b/samples/Lua/TestLua/Resources/luaScript/helper.lua index 04b9bc9a47..911924f1fe 100644 --- a/samples/Lua/TestLua/Resources/luaScript/helper.lua +++ b/samples/Lua/TestLua/Resources/luaScript/helper.lua @@ -1,14 +1,16 @@ +require "Cocos2d" + CC_CONTENT_SCALE_FACTOR = function() - return CCDirector:getInstance():getContentScaleFactor() + return cc.Director:getInstance():getContentScaleFactor() end CC_POINT_PIXELS_TO_POINTS = function(pixels) - return CCPoint(pixels.x/CC_CONTENT_SCALE_FACTOR(), pixels.y/CC_CONTENT_SCALE_FACTOR()) + return cc.p(pixels.x/CC_CONTENT_SCALE_FACTOR(), pixels.y/CC_CONTENT_SCALE_FACTOR()) end CC_POINT_POINTS_TO_PIXELS = function(points) - return CCPoint(points.x*CC_CONTENT_SCALE_FACTOR(), points.y*CC_CONTENT_SCALE_FACTOR()) + return cc.p(points.x*CC_CONTENT_SCALE_FACTOR(), points.y*CC_CONTENT_SCALE_FACTOR()) end @@ -29,20 +31,20 @@ end -- back menu callback local function MainMenuCallback() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(CreateTestMenu()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end -- add the menu item for back to main menu function CreateBackMenuItem() - local label = CCLabelTTF:create("MainMenu", "Arial", 20) - local MenuItem = CCMenuItemLabel:create(label) + local label = cc.LabelTTF:create("MainMenu", "Arial", 20) + local MenuItem = cc.MenuItemLabel:create(label) MenuItem:registerScriptTapHandler(MainMenuCallback) - local s = CCDirector:getInstance():getWinSize() - local Menu = CCMenu:create() + local s = cc.Director:getInstance():getWinSize() + local Menu = cc.Menu:create() Menu:addChild(MenuItem) Menu:setPosition(0, 0) MenuItem:setPosition(s.width - 50, 25) @@ -80,50 +82,50 @@ function Helper.restartAction() end function Helper.newScene() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.currentLayer = Helper.createFunctionTable[Helper.index]() scene:addChild(Helper.currentLayer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end function Helper.initWithLayer(layer) Helper.currentLayer = layer - local size = CCDirector:getInstance():getWinSize() - Helper.titleLabel = CCLabelTTF:create("", "Arial", 28) + local size = cc.Director:getInstance():getWinSize() + Helper.titleLabel = cc.LabelTTF:create("", "Arial", 28) layer:addChild(Helper.titleLabel, 1) Helper.titleLabel:setPosition(size.width / 2, size.height - 50) - Helper.subtitleLabel = CCLabelTTF:create("", "Thonburi", 16) + Helper.subtitleLabel = cc.LabelTTF:create("", "Thonburi", 16) layer:addChild(Helper.subtitleLabel, 1) Helper.subtitleLabel:setPosition(size.width / 2, size.height - 80) -- 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(Helper.backAction) item2:registerScriptTapHandler(Helper.restartAction) item3:registerScriptTapHandler(Helper.nextAction) - 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(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)) + menu:setPosition(cc.p(0, 0)) + 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)) layer:addChild(menu, 1) - local background = CCLayer:create() + local background = cc.Layer:create() layer:addChild(background, -10) end function createTestLayer(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 diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index c0ba606bca..b62b0528f0 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -1,14 +1,23 @@ + + +require "Cocos2d" +require "Cocos2dConstants" +require "Opengl" +require "OpenglConstants" require "luaScript/helper" require "luaScript/testResource" -require "luaScript/ActionsTest/ActionsTest" -require "luaScript/TransitionsTest/TransitionsTest" +require "luaScript/ActionManagerTest/ActionManagerTest" +require "luaScript/ActionsEaseTest/ActionsEaseTest" require "luaScript/ActionsProgressTest/ActionsProgressTest" +require "luaScript/ActionsTest/ActionsTest" + +--[[ +require "luaScript/TransitionsTest/TransitionsTest" require "luaScript/EffectsTest/EffectsTest" require "luaScript/ClickAndMoveTest/ClickAndMoveTest" require "luaScript/RotateWorldTest/RotateWorldTest" require "luaScript/ParticleTest/ParticleTest" -require "luaScript/ActionsEaseTest/ActionsEaseTest" require "luaScript/MotionStreakTest/MotionStreakTest" require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest" require "luaScript/NodeTest/NodeTest" @@ -19,7 +28,7 @@ require "luaScript/PerformanceTest/PerformanceTest" require "luaScript/LabelTest/LabelTest" require "luaScript/ParallaxTest/ParallaxTest" require "luaScript/TileMapTest/TileMapTest" -require "luaScript/ActionManagerTest/ActionManagerTest" + require "luaScript/MenuTest/MenuTest" require "luaScript/IntervalTest/IntervalTest" require "luaScript/SceneTest/SceneTest" @@ -36,7 +45,7 @@ require "luaScript/ExtensionTest/ExtensionTest" require "luaScript/AccelerometerTest/AccelerometerTest" require "luaScript/KeypadTest/KeypadTest" require "luaScript/OpenGLTest/OpenGLTest" - +]]-- local LINE_SPACE = 40 @@ -96,15 +105,15 @@ local TESTS_COUNT = table.getn(_allTests) -- create scene local function CreateTestScene(nIdx) local scene = _allTests[nIdx].create_func() - CCDirector:getInstance():purgeCachedData() + cc.Director:getInstance():purgeCachedData() return scene end -- create menu function CreateTestMenu() - local menuLayer = CCLayer:create() + local menuLayer = cc.Layer:create() local function closeCallback() - CCDirector:getInstance():endToLua() + cc.Director:getInstance():endToLua() end local function menuCallback(tag) @@ -112,37 +121,37 @@ function CreateTestMenu() local Idx = tag - 10000 local testScene = CreateTestScene(Idx) if testScene then - CCDirector:getInstance():replaceScene(testScene) + cc.Director:getInstance():replaceScene(testScene) end end -- add close menu - local s = CCDirector:getInstance():getWinSize() - local CloseItem = CCMenuItemImage:create(s_pPathClose, s_pPathClose) + local s = cc.Director:getInstance():getWinSize() + local CloseItem = cc.MenuItemImage:create(s_pPathClose, s_pPathClose) CloseItem:registerScriptTapHandler(closeCallback) - CloseItem:setPosition(CCPoint(s.width - 30, s.height - 30)) + CloseItem:setPosition(cc.p(s.width - 30, s.height - 30)) - local CloseMenu = CCMenu:create() + local CloseMenu = cc.Menu:create() CloseMenu:setPosition(0, 0) CloseMenu:addChild(CloseItem) menuLayer:addChild(CloseMenu) -- add menu items for tests - local MainMenu = CCMenu:create() + local MainMenu = cc.Menu:create() local index = 0 local obj = nil for index, obj in pairs(_allTests) do - local testLabel = CCLabelTTF:create(obj.name, "Arial", 24) - local testMenuItem = CCMenuItemLabel:create(testLabel) + local testLabel = cc.LabelTTF:create(obj.name, "Arial", 24) + local testMenuItem = cc.MenuItemLabel:create(testLabel) if not obj.isSupported then testMenuItem:setEnabled(false) end testMenuItem:registerScriptTapHandler(menuCallback) - testMenuItem:setPosition(CCPoint(s.width / 2, (s.height - (index) * LINE_SPACE))) + testMenuItem:setPosition(cc.p(s.width / 2, (s.height - (index) * LINE_SPACE))) MainMenu:addChild(testMenuItem, index + 10000, index + 10000) end - MainMenu:setContentSize(CCSize(s.width, (TESTS_COUNT + 1) * (LINE_SPACE))) + MainMenu:setContentSize(cc.size(s.width, (TESTS_COUNT + 1) * (LINE_SPACE))) MainMenu:setPosition(CurPos.x, CurPos.y) menuLayer:addChild(MainMenu) @@ -155,9 +164,10 @@ function CreateTestMenu() local function onTouchMoved(x, y) local nMoveY = y - BeginPos.y - local curPosx, curPosy = MainMenu:getPosition() + local curPos = MainMenu:getPosition() + local curPosx, curPosy = curPos.x,curPos.y local nextPosy = curPosy + nMoveY - local winSize = CCDirector:getInstance():getWinSize() + local winSize = cc.Director:getInstance():getWinSize() if nextPosy < 0 then MainMenu:setPosition(0, 0) return diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index 543b758f11..98d25f9bbc 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -daaf13ab82feffbd1c8e201d76cb83ed8f2dabca \ No newline at end of file +1cee6156624b42a16c97a0095a036f0b51b68e48 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp index a5b18cb394..7bd6c2a65a 100644 --- a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp @@ -312,7 +312,7 @@ int LuaEngine::handleMenuClickedEvent(void* data) return 0; _stack->pushInt(menuItem->getTag()); - _stack->pushObject(menuItem, "CCMenuItem"); + _stack->pushObject(menuItem, "MenuItem"); int ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return ret; @@ -357,7 +357,7 @@ int LuaEngine::handleCallFuncActionEvent(void* data) Object* target = static_cast(basicScriptData->value); if (NULL != target) { - _stack->pushObject(target, "CCNode"); + _stack->pushObject(target, "Node"); } int ret = _stack->executeFunctionByHandler(handler, target ? 1 : 0); _stack->clean(); diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index a99835927b..e8ff07d4dc 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -126,6 +126,7 @@ bool LuaStack::init(void) }; luaL_register(_state, "_G", global_functions); register_all_cocos2dx(_state); + tolua_opengl_open(_state); register_all_cocos2dx_extension(_state); register_all_cocos2dx_manual(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) @@ -135,7 +136,6 @@ bool LuaStack::init(void) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) tolua_web_socket_open(_state); #endif - tolua_opengl_open(_state); tolua_scroll_view_open(_state); tolua_script_handler_mgr_open(_state); diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp index 5c35fa0199..e26a3d41df 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp @@ -829,6 +829,58 @@ bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue) return ok; } +bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints) +{ + if (NULL == L) + return false; + + bool ok = true; + +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + size_t len = lua_objlen(L, lo); + if (len > 0) + { + Point* array = (Point*)malloc(sizeof(Point) * len); + if (NULL == array) + return false; + for (uint32_t i = 0; i < len; ++i) + { + lua_pushnumber(L,i + 1); + lua_gettable(L,lo); + if (!tolua_istable(L,-1, 0, &tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + lua_pop(L, 1); + free(array); + return false; + } + ok &= luaval_to_point(L, lua_gettop(L), &array[i]); + if (!ok) + { + lua_pop(L, 1); + free(array); + return false; + } + lua_pop(L, 1); + } + + *numPoints = len; + *points = array; + } + } + return ok; +} + void point_to_luaval(lua_State* L,const Point& pt) { if (NULL == L) diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.h b/scripting/lua/cocos2dx_support/LuaBasicConversions.h index 93d868d0e5..bbd6dca25a 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.h +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.h @@ -28,6 +28,7 @@ extern bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outV extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue ); 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); // 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 0d4f20ac67..937b18fb64 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -db5d393a48a8e12b2a8a0fefef11c4bb7c494d56 \ No newline at end of file +b3460818609e566b063e1c9b7404650048c81121 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp index 388eff474b..bf2ff83e2c 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp @@ -15,6 +15,9 @@ extern "C" { static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; bool ok = true; @@ -90,8 +93,48 @@ tolua_lerror: } +static int tolua_cocos2d_MenuItemLabel_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"MenuItemLabel",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + if(1 == argc) + { + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + Node* label = ((Node*) tolua_tousertype(tolua_S,2,0)); + MenuItemLabel* tolua_ret = (MenuItemLabel*) MenuItemLabel::create(label); + 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,"MenuItemLabel"); + return 1; + } + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + static int tolua_cocos2d_Menu_create(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; #if COCOS2D_DEBUG >= 1 @@ -105,13 +148,13 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S) cocos2d::Array* array = cocos2d::Array::create(); if (NULL == array) { - printf("Menu create method create array fail\n"); + CCLOG("Menu create method create array fail\n"); return 0; } uint32_t i = 1; while (i <= argc) { - if (!tolua_isuserdata(tolua_S, 1 + i, 0, &tolua_err) ) + if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err)) { goto tolua_lerror; return 0; @@ -153,6 +196,9 @@ tolua_lerror: //tolua_cocos2d_Menu_create static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; MenuItem* cobj = nullptr; #if COCOS2D_DEBUG >= 1 @@ -184,13 +230,16 @@ static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'registerScriptTapHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; MenuItem* cobj = nullptr; @@ -228,6 +277,9 @@ tolua_lerror: static int tolua_cocos2d_Layer_registerScriptTouchHandler(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; Layer* self = nullptr; @@ -307,6 +359,9 @@ tolua_lerror: static int tolua_cocos2d_Layer_unregisterScriptTouchHandler(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; Layer* self = nullptr; @@ -343,8 +398,11 @@ tolua_lerror: } -static int tolua_cocos2d_Scheduler_scheduleScriptFunc00(lua_State* tolua_S) +static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; Scheduler* self = nullptr; @@ -357,7 +415,7 @@ static int tolua_cocos2d_Scheduler_scheduleScriptFunc00(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc00'\n", NULL); + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc'\n", NULL); return 0; } #endif @@ -393,6 +451,9 @@ tolua_lerror: static int tolua_cocos2d_Scheduler_unscheduleScriptEntry(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; Scheduler* self = nullptr; @@ -434,6 +495,547 @@ tolua_lerror: #endif } +static int tolua_cocos2d_Sequence_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"Sequence",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + if(argc > 0) + { + cocos2d::Array* array = cocos2d::Array::create(); + if (NULL == array) + { + CCLOG("Sequence create method create array fail\n"); + return 0; + } + uint32_t i = 1; + while (i <= argc) + { + if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err)) + { + goto tolua_lerror; + return 0; + } + + cocos2d::Object* item = static_cast(tolua_tousertype(tolua_S, 1 + i, NULL)); + if (NULL != item) + { + array->addObject(item); + ++i; + } + + } + cocos2d::Sequence* tolua_ret = cocos2d::Sequence::create(array); + //issue 2433 uncheck + 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,"Sequence"); + 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 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_CallFunc_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CallFunc",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { +#if COCOS2D_DEBUG >= 1 + if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) + goto tolua_lerror; +#endif + + LUA_FUNCTION funcID = ( toluafix_ref_function(tolua_S,2,0)); + LuaCallFunc* tolua_ret = (LuaCallFunc*) LuaCallFunc::create(funcID); + 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,"CallFunc"); + 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 'create'.",&tolua_err); + return 0; +#endif + +} + +static int tolua_cocos2d_Node_registerScriptHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Node* node = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; +#endif + + node = static_cast(tolua_tousertype(tolua_S,1,0)); + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { +#if COCOS2D_DEBUG >= 1 + if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) + goto tolua_lerror; +#endif + + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)node, handler, ScriptHandlerMgr::kNodeHandler); + + 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 'registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Node_unregisterScriptHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Node* node = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; +#endif + + node = static_cast(tolua_tousertype(tolua_S,1,0)); + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)node, ScriptHandlerMgr::kNodeHandler); + return 0; + } + + 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 'unregisterScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Spawn_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"Spawn",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc > 0) + { + cocos2d::Array* array = cocos2d::Array::create(); + if (NULL == array) + { + CCLOG("Spawn create method create array fail\n"); + return 0; + } + + uint32_t i = 1; + while (i <= argc) + { + if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err)) + { + goto tolua_lerror; + return 0; + } + + cocos2d::Object* item = static_cast(tolua_tousertype(tolua_S, 1 + i, NULL)); + if (NULL != item) + { + array->addObject(item); + ++i; + } + } + + cocos2d::Spawn * tolua_ret = cocos2d::Spawn::create(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,"Spawn"); + 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 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CardinalSplineBy",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 3) + { + double dur = 0.0; + ok &= luaval_to_number(tolua_S, 2, &dur); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + double ten = 0.0; + ok &= luaval_to_number(tolua_S, 4, &ten); + if (!ok) + return false; + + if (num > 0) + { + PointArray* points = PointArray::create(num); + + if (NULL == points) + { + free(arr); + return 0; + } + + for( int i = 0; i < num; i++) { + points->addControlPoint(arr[i]); + } + + free(arr); + CardinalSplineBy* tolua_ret = CardinalSplineBy::create(dur, points, ten); + if (NULL != tolua_ret) + { + 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,"CardinalSplineBy"); + return 1; + } + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3); + 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_CatmullRomBy_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CatmullRomBy",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + double dur = 0.0; + ok &= luaval_to_number(tolua_S, 2, &dur); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + if (num > 0) + { + PointArray* points = PointArray::create(num); + + if (NULL == points) + { + free(arr); + return 0; + } + + for( int i = 0; i < num; i++) { + points->addControlPoint(arr[i]); + } + + free(arr); + CatmullRomBy* tolua_ret = CatmullRomBy::create(dur, points); + if (NULL != tolua_ret) + { + 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,"CatmullRomBy"); + return 1; + } + } + } + + CCLOG("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_CatmullRomTo_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CatmullRomTo",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + double dur = 0.0; + ok &= luaval_to_number(tolua_S, 2, &dur); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + if (num > 0) + { + PointArray* points = PointArray::create(num); + + if (NULL == points) + { + free(arr); + return 0; + } + + for( int i = 0; i < num; i++) { + points->addControlPoint(arr[i]); + } + + free(arr); + CatmullRomTo* tolua_ret = CatmullRomTo::create(dur, points); + if (NULL != tolua_ret) + { + 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,"CatmullRomTo"); + return 1; + } + } + } + + CCLOG("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_BezierBy_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"BezierBy",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + double t = 0.0; + ok &= luaval_to_number(tolua_S, 2, &t); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + if (num < 3) + { + free(arr); + return false; + } + + ccBezierConfig config; + config.controlPoint_1 = arr[0]; + config.controlPoint_2 = arr[1]; + config.endPosition = arr[2]; + free(arr); + + BezierBy* tolua_ret = BezierBy::create(t, config); + if (NULL != tolua_ret) + { + 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,"BezierBy"); + return 1; + } + } + + CCLOG("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_BezierTo_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"BezierTo",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + double t = 0.0; + ok &= luaval_to_number(tolua_S, 2, &t); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + if (num < 3) + { + free(arr); + return false; + } + + ccBezierConfig config; + config.controlPoint_1 = arr[0]; + config.controlPoint_2 = arr[1]; + config.endPosition = arr[2]; + free(arr); + + BezierTo* tolua_ret = BezierTo::create(t, config); + if (NULL != tolua_ret) + { + 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,"BezierTo"); + return 1; + } + } + + CCLOG("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 +} //void lua_extend_cocos2dx_MenuItem //{ // @@ -465,6 +1067,15 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S, "MenuItemLabel"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemLabel_create); + lua_rawset(tolua_S,-3); + } + lua_pushstring(tolua_S, "Menu"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S, -1)) @@ -474,6 +1085,18 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S,"Node"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"registerScriptHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Node_registerScriptHandler); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"unregisterScriptHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unregisterScriptHandler); + lua_rawset(tolua_S, -3); + } + lua_pushstring(tolua_S,"Layer"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -503,11 +1126,86 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"scheduleScriptFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_scheduleScriptFunc00); + lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_scheduleScriptFunc); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "unscheduleScriptEntry"); lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_unscheduleScriptEntry); lua_rawset(tolua_S, -3); } + + lua_pushstring(tolua_S,"Sequence"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Sequence_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"CallFunc"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CallFunc_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"Spawn"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Spawn_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"CardinalSplineBy"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CardinalSplineBy_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"CatmullRomBy"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomBy_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"CatmullRomTo"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomTo_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"BezierBy"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_BezierBy_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"BezierTo"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_BezierTo_create); + lua_rawset(tolua_S,-3); + } + + + return 0; } \ No newline at end of file diff --git a/scripting/lua/script/Cocos2d.lua b/scripting/lua/script/Cocos2d.lua new file mode 100644 index 0000000000..98c1b8e5f8 --- /dev/null +++ b/scripting/lua/script/Cocos2d.lua @@ -0,0 +1,28 @@ +cc = cc or {} + +--Point +function cc.p(_x,_y) + return { x = _x, y = _y } +end + +--Size +function cc.size( _width,_height ) + return { width = _width, height = _height } +end + +--Rect +function cc.rect(_x,_y,_width,_height) + return { x = _x, y = _y, width = _width, height = _height } +end + +--Color3B +function cc.c3b( _r,_g,_b ) + return { r = _r, g = _g, b = _b } +end + +--Color4B +function cc.c4b( _r,_g,_b,_a ) + return { r = _r, g = _g, b = _b, a = _a } +end + + diff --git a/scripting/lua/script/Cocos2dConstants.lua b/scripting/lua/script/Cocos2dConstants.lua index 55828a8f51..a86697dfef 100644 --- a/scripting/lua/script/Cocos2dConstants.lua +++ b/scripting/lua/script/Cocos2dConstants.lua @@ -1,178 +1,165 @@ -local CCConstants = {} +cc = cc or {} -CCConstants.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff -CCConstants.TMX_ORIENTATION_HEX = 0x1 -CCConstants.TMX_ORIENTATION_ISO = 0x2 -CCConstants.TMX_ORIENTATION_ORTHO = 0x0 -CCConstants.Z_COMPRESSION_BZIP2 = 0x1 -CCConstants.Z_COMPRESSION_GZIP = 0x2 -CCConstants.Z_COMPRESSION_NONE = 0x3 -CCConstants.Z_COMPRESSION_ZLIB = 0x0 -CCConstants.BLEND_DST = 0x303 -CCConstants.BLEND_SRC = 0x1 -CCConstants.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0 -CCConstants.DIRECTOR_MAC_THREAD = 0x0 -CCConstants.DIRECTOR_STATS_INTERVAL = 0.1 -CCConstants.ENABLE_BOX2_D_INTEGRATION = 0x0 -CCConstants.ENABLE_DEPRECATED = 0x1 -CCConstants.ENABLE_GL_STATE_CACHE = 0x1 -CCConstants.ENABLE_PROFILERS = 0x0 -CCConstants.ENABLE_STACKABLE_ACTIONS = 0x1 -CCConstants.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0 -CCConstants.GL_ALL = 0x0 -CCConstants.LABELATLAS_DEBUG_DRAW = 0x0 -CCConstants.LABELBMFONT_DEBUG_DRAW = 0x0 -CCConstants.MAC_USE_DISPLAY_LINK_THREAD = 0x0 -CCConstants.MAC_USE_MAIN_THREAD = 0x2 -CCConstants.MAC_USE_OWN_THREAD = 0x1 -CCConstants.NODE_RENDER_SUBPIXEL = 0x1 -CCConstants.PVRMIPMAP_MAX = 0x10 -CCConstants.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1 -CCConstants.SPRITE_DEBUG_DRAW = 0x0 -CCConstants.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0 -CCConstants.TEXTURE_ATLAS_USE_VAO = 0x1 -CCConstants.USE_L_A88_LABELS = 0x1 -CCConstants.ACTION_TAG_INVALID = -1 -CCConstants.DEVICE_MAC = 0x6 -CCConstants.DEVICE_MAC_RETINA_DISPLAY = 0x7 -CCConstants.DEVICEI_PAD = 0x4 -CCConstants.DEVICEI_PAD_RETINA_DISPLAY = 0x5 -CCConstants.DEVICEI_PHONE = 0x0 -CCConstants.DEVICEI_PHONE5 = 0x2 -CCConstants.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3 -CCConstants.DEVICEI_PHONE_RETINA_DISPLAY = 0x1 -CCConstants.DIRECTOR_PROJECTION2_D = 0x0 -CCConstants.DIRECTOR_PROJECTION3_D = 0x1 -CCConstants.DIRECTOR_PROJECTION_CUSTOM = 0x2 -CCConstants.DIRECTOR_PROJECTION_DEFAULT = 0x1 -CCConstants.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1 -CCConstants.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0 -CCConstants.FLIPED_ALL = 0xe0000000 -CCConstants.FLIPPED_MASK = 0x1fffffff -CCConstants.IMAGE_FORMAT_JPEG = 0x0 -CCConstants.IMAGE_FORMAT_PNG = 0x1 -CCConstants.ITEM_SIZE = 0x20 -CCConstants.LABEL_AUTOMATIC_WIDTH = -1 -CCConstants.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1 -CCConstants.LINE_BREAK_MODE_CLIP = 0x2 -CCConstants.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3 -CCConstants.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5 -CCConstants.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4 -CCConstants.LINE_BREAK_MODE_WORD_WRAP = 0x0 -CCConstants.MAC_VERSION_10_6 = 0xa060000 -CCConstants.MAC_VERSION_10_7 = 0xa070000 -CCConstants.MAC_VERSION_10_8 = 0xa080000 -CCConstants.MENU_HANDLER_PRIORITY = -128 -CCConstants.MENU_STATE_TRACKING_TOUCH = 0x1 -CCConstants.MENU_STATE_WAITING = 0x0 -CCConstants.NODE_TAG_INVALID = -1 -CCConstants.PARTICLE_DURATION_INFINITY = -1 -CCConstants.PARTICLE_MODE_GRAVITY = 0x0 -CCConstants.PARTICLE_MODE_RADIUS = 0x1 -CCConstants.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1 -CCConstants.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1 -CCConstants.POSITION_TYPE_FREE = 0x0 -CCConstants.POSITION_TYPE_GROUPED = 0x2 -CCConstants.POSITION_TYPE_RELATIVE = 0x1 -CCConstants.PRIORITY_NON_SYSTEM_MIN = -2147483647 -CCConstants.PRIORITY_SYSTEM = -2147483648 -CCConstants.PROGRESS_TIMER_TYPE_BAR = 0x1 -CCConstants.PROGRESS_TIMER_TYPE_RADIAL = 0x0 -CCConstants.REPEAT_FOREVER = 0xfffffffe -CCConstants.RESOLUTION_MAC = 0x1 -CCConstants.RESOLUTION_MAC_RETINA_DISPLAY = 0x2 -CCConstants.RESOLUTION_UNKNOWN = 0x0 -CCConstants.TMX_TILE_DIAGONAL_FLAG = 0x20000000 -CCConstants.TMX_TILE_HORIZONTAL_FLAG = 0x80000000 -CCConstants.TMX_TILE_VERTICAL_FLAG = 0x40000000 -CCConstants.TEXT_ALIGNMENT_CENTER = 0x1 -CCConstants.TEXT_ALIGNMENT_LEFT = 0x0 -CCConstants.TEXT_ALIGNMENT_RIGHT = 0x2 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x3 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x5 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x4 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0x9 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0x8 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x2 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x7 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x1 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x6 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x0 -CCConstants.TOUCHES_ALL_AT_ONCE = 0x0 -CCConstants.TOUCHES_ONE_BY_ONE = 0x1 -CCConstants.TRANSITION_ORIENTATION_DOWN_OVER = 0x1 -CCConstants.TRANSITION_ORIENTATION_LEFT_OVER = 0x0 -CCConstants.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1 -CCConstants.TRANSITION_ORIENTATION_UP_OVER = 0x0 -CCConstants.UNIFORM_COS_TIME = 0x5 -CCConstants.UNIFORM_MV_MATRIX = 0x1 -CCConstants.UNIFORM_MVP_MATRIX = 0x2 -CCConstants.UNIFORM_P_MATRIX = 0x0 -CCConstants.UNIFORM_RANDOM01 = 0x6 -CCConstants.UNIFORM_SAMPLER = 0x7 -CCConstants.UNIFORM_SIN_TIME = 0x4 -CCConstants.UNIFORM_TIME = 0x3 -CCConstants.UNIFORM_MAX = 0x8 -CCConstants.VERTEX_ATTRIB_FLAG_COLOR = 0x2 -CCConstants.VERTEX_ATTRIB_FLAG_NONE = 0x0 -CCConstants.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7 -CCConstants.VERTEX_ATTRIB_FLAG_POSITION = 0x1 -CCConstants.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4 -CCConstants.VERTEX_ATTRIB_COLOR = 0x1 -CCConstants.VERTEX_ATTRIB_MAX = 0x3 -CCConstants.VERTEX_ATTRIB_POSITION = 0x0 -CCConstants.VERTEX_ATTRIB_TEX_COORDS = 0x2 -CCConstants.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2 -CCConstants.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1 -CCConstants.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0 -CCConstants.OS_VERSION_4_0 = 0x4000000 -CCConstants.OS_VERSION_4_0_1 = 0x4000100 -CCConstants.OS_VERSION_4_1 = 0x4010000 -CCConstants.OS_VERSION_4_2 = 0x4020000 -CCConstants.OS_VERSION_4_2_1 = 0x4020100 -CCConstants.OS_VERSION_4_3 = 0x4030000 -CCConstants.OS_VERSION_4_3_1 = 0x4030100 -CCConstants.OS_VERSION_4_3_2 = 0x4030200 -CCConstants.OS_VERSION_4_3_3 = 0x4030300 -CCConstants.OS_VERSION_4_3_4 = 0x4030400 -CCConstants.OS_VERSION_4_3_5 = 0x4030500 -CCConstants.OS_VERSION_5_0 = 0x5000000 -CCConstants.OS_VERSION_5_0_1 = 0x5000100 -CCConstants.OS_VERSION_5_1_0 = 0x5010000 -CCConstants.OS_VERSION_6_0_0 = 0x6000000 -CCConstants.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification' -CCConstants.CHIPMUNK_IMPORT = 'chipmunk.h' -CCConstants.ATTRIBUTE_NAME_COLOR = 'a_color' -CCConstants.ATTRIBUTE_NAME_POSITION = 'a_position' -CCConstants.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord' -CCConstants.SHADER_POSITION_COLOR = 'ShaderPositionColor' -CCConstants.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor' -CCConstants.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture' -CCConstants.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color' -CCConstants.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor' -CCConstants.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest' -CCConstants.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor' -CCConstants.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor' -CCConstants.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue' -CCConstants.UNIFORM_COS_TIME_S = 'CC_CosTime' -CCConstants.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix' -CCConstants.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix' -CCConstants.UNIFORM_P_MATRIX_S = 'CC_PMatrix' -CCConstants.UNIFORM_RANDOM01_S = 'CC_Random01' -CCConstants.UNIFORM_SAMPLER_S = 'CC_Texture0' -CCConstants.UNIFORM_SIN_TIME_S = 'CC_SinTime' -CCConstants.UNIFORM_TIME_S = 'CC_Time' - - -local modename = "CCConstants" -local CCConstantsproxy = {} -local CCConstantsMt = { - __index = CCConstants, - __newindex = function (t ,k ,v) - print("attemp to update a read-only table") - end -} -setmetatable(CCConstantsproxy,CCConstantsMt) -_G[modename] = CCConstantsproxy -package.loaded[modename] = CCConstantsproxy +cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff +cc.TMX_ORIENTATION_HEX = 0x1 +cc.TMX_ORIENTATION_ISO = 0x2 +cc.TMX_ORIENTATION_ORTHO = 0x0 +cc.Z_COMPRESSION_BZIP2 = 0x1 +cc.Z_COMPRESSION_GZIP = 0x2 +cc.Z_COMPRESSION_NONE = 0x3 +cc.Z_COMPRESSION_ZLIB = 0x0 +cc.BLEND_DST = 0x303 +cc.BLEND_SRC = 0x1 +cc.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0 +cc.DIRECTOR_MAC_THREAD = 0x0 +cc.DIRECTOR_STATS_INTERVAL = 0.1 +cc.ENABLE_BOX2_D_INTEGRATION = 0x0 +cc.ENABLE_DEPRECATED = 0x1 +cc.ENABLE_GL_STATE_CACHE = 0x1 +cc.ENABLE_PROFILERS = 0x0 +cc.ENABLE_STACKABLE_ACTIONS = 0x1 +cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0 +cc.GL_ALL = 0x0 +cc.LABELATLAS_DEBUG_DRAW = 0x0 +cc.LABELBMFONT_DEBUG_DRAW = 0x0 +cc.MAC_USE_DISPLAY_LINK_THREAD = 0x0 +cc.MAC_USE_MAIN_THREAD = 0x2 +cc.MAC_USE_OWN_THREAD = 0x1 +cc.NODE_RENDER_SUBPIXEL = 0x1 +cc.PVRMIPMAP_MAX = 0x10 +cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1 +cc.SPRITE_DEBUG_DRAW = 0x0 +cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0 +cc.TEXTURE_ATLAS_USE_VAO = 0x1 +cc.USE_L_A88_LABELS = 0x1 +cc.ACTION_TAG_INVALID = -1 +cc.DEVICE_MAC = 0x6 +cc.DEVICE_MAC_RETINA_DISPLAY = 0x7 +cc.DEVICEI_PAD = 0x4 +cc.DEVICEI_PAD_RETINA_DISPLAY = 0x5 +cc.DEVICEI_PHONE = 0x0 +cc.DEVICEI_PHONE5 = 0x2 +cc.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3 +cc.DEVICEI_PHONE_RETINA_DISPLAY = 0x1 +cc.DIRECTOR_PROJECTION2_D = 0x0 +cc.DIRECTOR_PROJECTION3_D = 0x1 +cc.DIRECTOR_PROJECTION_CUSTOM = 0x2 +cc.DIRECTOR_PROJECTION_DEFAULT = 0x1 +cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1 +cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0 +cc.FLIPED_ALL = 0xe0000000 +cc.FLIPPED_MASK = 0x1fffffff +cc.IMAGE_FORMAT_JPEG = 0x0 +cc.IMAGE_FORMAT_PNG = 0x1 +cc.ITEM_SIZE = 0x20 +cc.LABEL_AUTOMATIC_WIDTH = -1 +cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1 +cc.LINE_BREAK_MODE_CLIP = 0x2 +cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3 +cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5 +cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4 +cc.LINE_BREAK_MODE_WORD_WRAP = 0x0 +cc.MAC_VERSION_10_6 = 0xa060000 +cc.MAC_VERSION_10_7 = 0xa070000 +cc.MAC_VERSION_10_8 = 0xa080000 +cc.MENU_HANDLER_PRIORITY = -128 +cc.MENU_STATE_TRACKING_TOUCH = 0x1 +cc.MENU_STATE_WAITING = 0x0 +cc.NODE_TAG_INVALID = -1 +cc.PARTICLE_DURATION_INFINITY = -1 +cc.PARTICLE_MODE_GRAVITY = 0x0 +cc.PARTICLE_MODE_RADIUS = 0x1 +cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1 +cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1 +cc.POSITION_TYPE_FREE = 0x0 +cc.POSITION_TYPE_GROUPED = 0x2 +cc.POSITION_TYPE_RELATIVE = 0x1 +cc.PRIORITY_NON_SYSTEM_MIN = -2147483647 +cc.PRIORITY_SYSTEM = -2147483648 +cc.PROGRESS_TIMER_TYPE_BAR = 0x1 +cc.PROGRESS_TIMER_TYPE_RADIAL = 0x0 +cc.REPEAT_FOREVER = 0xfffffffe +cc.RESOLUTION_MAC = 0x1 +cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2 +cc.RESOLUTION_UNKNOWN = 0x0 +cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000 +cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000 +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.TOUCHES_ALL_AT_ONCE = 0x0 +cc.TOUCHES_ONE_BY_ONE = 0x1 +cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1 +cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0 +cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1 +cc.TRANSITION_ORIENTATION_UP_OVER = 0x0 +cc.UNIFORM_COS_TIME = 0x5 +cc.UNIFORM_MV_MATRIX = 0x1 +cc.UNIFORM_MVP_MATRIX = 0x2 +cc.UNIFORM_P_MATRIX = 0x0 +cc.UNIFORM_RANDOM01 = 0x6 +cc.UNIFORM_SAMPLER = 0x7 +cc.UNIFORM_SIN_TIME = 0x4 +cc.UNIFORM_TIME = 0x3 +cc.UNIFORM_MAX = 0x8 +cc.VERTEX_ATTRIB_FLAG_COLOR = 0x2 +cc.VERTEX_ATTRIB_FLAG_NONE = 0x0 +cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7 +cc.VERTEX_ATTRIB_FLAG_POSITION = 0x1 +cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4 +cc.VERTEX_ATTRIB_COLOR = 0x1 +cc.VERTEX_ATTRIB_MAX = 0x3 +cc.VERTEX_ATTRIB_POSITION = 0x0 +cc.VERTEX_ATTRIB_TEX_COORDS = 0x2 +cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2 +cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1 +cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0 +cc.OS_VERSION_4_0 = 0x4000000 +cc.OS_VERSION_4_0_1 = 0x4000100 +cc.OS_VERSION_4_1 = 0x4010000 +cc.OS_VERSION_4_2 = 0x4020000 +cc.OS_VERSION_4_2_1 = 0x4020100 +cc.OS_VERSION_4_3 = 0x4030000 +cc.OS_VERSION_4_3_1 = 0x4030100 +cc.OS_VERSION_4_3_2 = 0x4030200 +cc.OS_VERSION_4_3_3 = 0x4030300 +cc.OS_VERSION_4_3_4 = 0x4030400 +cc.OS_VERSION_4_3_5 = 0x4030500 +cc.OS_VERSION_5_0 = 0x5000000 +cc.OS_VERSION_5_0_1 = 0x5000100 +cc.OS_VERSION_5_1_0 = 0x5010000 +cc.OS_VERSION_6_0_0 = 0x6000000 +cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification' +cc.CHIPMUNK_IMPORT = 'chipmunk.h' +cc.ATTRIBUTE_NAME_COLOR = 'a_color' +cc.ATTRIBUTE_NAME_POSITION = 'a_position' +cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord' +cc.SHADER_POSITION_COLOR = 'ShaderPositionColor' +cc.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor' +cc.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture' +cc.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color' +cc.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor' +cc.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest' +cc.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor' +cc.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor' +cc.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue' +cc.UNIFORM_COS_TIME_S = 'CC_CosTime' +cc.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix' +cc.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix' +cc.UNIFORM_P_MATRIX_S = 'CC_PMatrix' +cc.UNIFORM_RANDOM01_S = 'CC_Random01' +cc.UNIFORM_SAMPLER_S = 'CC_Texture0' +cc.UNIFORM_SIN_TIME_S = 'CC_SinTime' +cc.UNIFORM_TIME_S = 'CC_Time' diff --git a/scripting/lua/script/Opengl.lua b/scripting/lua/script/Opengl.lua index e71bfb54fc..4f70703093 100644 --- a/scripting/lua/script/Opengl.lua +++ b/scripting/lua/script/Opengl.lua @@ -294,6 +294,6 @@ function gl.getAttachedShaders(program) end function gl.glNodeCreate() - return GLNode:create() + return cc.GLNode:create() end diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 4c2e13a97e..9c45b05008 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 +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$ # 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 @@ -97,12 +97,13 @@ skip = Node::[getGrid setGLServerState description getUserObject .*UserData getG Scheduler::[pause resume unschedule schedule update isTargetPaused], TextureCache::[addPVRTCImage], Timer::[getSelector createWithScriptHandler], - *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType], + *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate], FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getClassTypeInfo], SimpleAudioEngine::[getClassTypeInfo], Application::[^application.* ^run$], Camera::[getEyeXYZ getCenterXYZ getUpXYZ], - ccFontDefinition::[*] + ccFontDefinition::[*], + Object::[autorelease isEqual acceptVisitor update] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY], MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], @@ -134,7 +135,7 @@ remove_prefix = classes_have_no_parents = Node Director SimpleAudioEngine FileUtils TMXMapInfo Application # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object Clonable +base_classes_to_skip = Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 6a31b61f3c..5b499f8cc1 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -40,7 +40,7 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC ScrollView::[(g|s)etDelegate$], .*Delegate::[*], .*Loader.*::[*], - *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate], EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], TableView::[create (g|s)etDataSource$ (g|s)etDelegate], Control::[removeHandleOfControlEvent addHandleOfControlEvent]