mirror of https://github.com/axmolengine/axmol.git
issue #2433:Modify Testlua sample and add some manual binding functions
This commit is contained in:
parent
13fd369beb
commit
f29525bbc6
|
@ -2,7 +2,7 @@ local MAX_COUNT = 9;
|
|||
local LINE_SPACE = 40;
|
||||
local kItemTagBasic = 5432;
|
||||
|
||||
local Winsize = CCDirector:getInstance():getWinSize();
|
||||
local Winsize = cc.Director:getInstance():getWinSize();
|
||||
|
||||
local testNames = {
|
||||
"Bug-350",
|
||||
|
@ -17,28 +17,28 @@ local testNames = {
|
|||
}
|
||||
|
||||
local function CreateBugsTestBackMenuItem(pLayer)
|
||||
CCMenuItemFont:setFontName("Arial")
|
||||
CCMenuItemFont:setFontSize(24);
|
||||
local pMenuItemFont = CCMenuItemFont:create("Back");
|
||||
pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25))
|
||||
cc.MenuItemFont:setFontName("Arial")
|
||||
cc.MenuItemFont:setFontSize(24);
|
||||
local pMenuItemFont = cc.MenuItemFont:create("Back");
|
||||
pMenuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25))
|
||||
local function menuCallback()
|
||||
local pScene = BugsTestMain()
|
||||
if pScene ~= nil then
|
||||
CCDirector:getInstance():replaceScene(pScene)
|
||||
cc.Director:getInstance():replaceScene(pScene)
|
||||
end
|
||||
end
|
||||
pMenuItemFont:registerScriptTapHandler(menuCallback)
|
||||
local pMenu = CCMenu:create()
|
||||
local pMenu = cc.Menu:create()
|
||||
pMenu:addChild(pMenuItemFont)
|
||||
pMenu:setPosition(CCPoint(0, 0))
|
||||
pMenu:setPosition(cc.p(0, 0))
|
||||
pLayer:addChild(pMenu)
|
||||
end
|
||||
|
||||
--BugTest350
|
||||
local function BugTest350()
|
||||
local pLayer = CCLayer:create()
|
||||
local pBackground = CCSprite:create("Hello.png");
|
||||
pBackground:setPosition(CCPoint(Winsize.width/2, Winsize.height/2));
|
||||
local pLayer = cc.Layer:create()
|
||||
local pBackground = cc.Sprite:create("Hello.png");
|
||||
pBackground:setPosition(cc.p(Winsize.width/2, Winsize.height/2));
|
||||
pLayer:addChild(pBackground);
|
||||
return pLayer
|
||||
end
|
||||
|
@ -50,7 +50,7 @@ local function BugTest422()
|
|||
nLocalTag = nLocalTag + 1
|
||||
local pNode = pResetLayer:getChildByTag(nLocalTag - 1)
|
||||
if nil ~= pNode then
|
||||
--userdata pointer
|
||||
--userdata per
|
||||
local strLog = "Menu:"..nLocalTag
|
||||
print(strLog)
|
||||
end
|
||||
|
@ -63,24 +63,27 @@ local function BugTest422()
|
|||
reset(pCallbackLayer)
|
||||
end
|
||||
end
|
||||
CCMenuItemFont:setFontName("Arial")
|
||||
CCMenuItemFont:setFontSize(24);
|
||||
local pMenuItem1 = CCMenuItemFont:create("One")
|
||||
cc.MenuItemFont:setFontName("Arial")
|
||||
cc.MenuItemFont:setFontSize(24);
|
||||
local pMenuItem1 = cc.MenuItemFont:create("One")
|
||||
pMenuItem1:registerScriptTapHandler(menuCallback)
|
||||
local pMenuItem2 = CCMenuItemFont:create("Two")
|
||||
local pMenuItem2 = cc.MenuItemFont:create("Two")
|
||||
pMenuItem2:registerScriptTapHandler(menuCallback)
|
||||
local arr = CCArray:create()
|
||||
--[[
|
||||
local arr = cc.Array:create()
|
||||
arr:addObject(pMenuItem1)
|
||||
arr:addObject(pMenuItem2)
|
||||
local pMenu = CCMenu:createWithArray(arr)
|
||||
]]--
|
||||
local pMenu = cc.Menu:create(pMenuItem1, pMenuItem2)
|
||||
pMenu:alignItemsVertically()
|
||||
local fX = math.random() * 50
|
||||
local fY = math.random() * 50
|
||||
pMenu:setPosition(CCPoint.__add(CCPoint(pMenu:getPosition()),CCPoint(fX,fY)))
|
||||
local menuPos = pMenu:getPosition()
|
||||
pMenu:setPosition(cc.p(menuPos.x + fX,menuPos.y + fY))
|
||||
pResetLayer:addChild(pMenu,0,nLocalTag)
|
||||
end
|
||||
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
reset(pLayer)
|
||||
return pLayer
|
||||
end
|
||||
|
@ -88,99 +91,101 @@ end
|
|||
--BugTest458
|
||||
local nColorFlag = 0
|
||||
local function BugTest458()
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
|
||||
local function InitQuestionContainerSprite(pSprite)
|
||||
--Add label
|
||||
local pLabel = CCLabelTTF:create("Answer 1", "Arial", 12);
|
||||
local pLabel = cc.LabelTTF:create("Answer 1", "Arial", 12);
|
||||
pLabel:setTag(100);
|
||||
|
||||
--Add the background
|
||||
local pCorner = CCSprite:create("Images/bugs/corner.png");
|
||||
local pCorner = cc.Sprite:create("Images/bugs/corner.png");
|
||||
local nWidth = Winsize.width * 0.9 - (pCorner:getContentSize().width * 2);
|
||||
local nHeight = Winsize.height * 0.15 - (pCorner:getContentSize().height * 2);
|
||||
local pColorLayer = CCLayerColor:create(Color4B(255, 255, 255, 255 * .75), nWidth, nHeight);
|
||||
pColorLayer:setPosition(CCPoint(-nWidth / 2, -nHeight / 2));
|
||||
local pColorLayer = cc.LayerColor:create(cc.c4b(255, 255, 255, 255 * .75), nWidth, nHeight);
|
||||
pColorLayer:setPosition(cc.p(-nWidth / 2, -nHeight / 2));
|
||||
--First button is blue,Second is red,Used for testing - change later
|
||||
if (0 == nColorFlag) then
|
||||
pLabel:setColor(Color3B(0,0,255))
|
||||
pLabel:setColor(cc.c3b(0,0,255))
|
||||
else
|
||||
print("Color changed")
|
||||
pLabel:setColor(Color3B(255,0,0))
|
||||
pLabel:setColor(cc.c3b(255,0,0))
|
||||
end
|
||||
nColorFlag = nColorFlag + 1;
|
||||
pSprite:addChild(pColorLayer);
|
||||
|
||||
pCorner:setPosition(CCPoint(-(nWidth / 2 + pCorner:getContentSize().width / 2), -(nHeight / 2 + pCorner:getContentSize().height / 2)));
|
||||
pCorner:setPosition(cc.p(-(nWidth / 2 + pCorner:getContentSize().width / 2), -(nHeight / 2 + pCorner:getContentSize().height / 2)));
|
||||
pSprite:addChild(pCorner);
|
||||
|
||||
local nX,nY = pCorner:getPosition()
|
||||
local pCorner2 = CCSprite:create("Images/bugs/corner.png");
|
||||
pCorner2:setPosition(CCPoint(-nX, nY));
|
||||
local posCorner = pCorner:getPosition()
|
||||
local nX,nY = posCorner.x,posCorner.y
|
||||
local pCorner2 = cc.Sprite:create("Images/bugs/corner.png");
|
||||
pCorner2:setPosition(cc.p(-nX, nY));
|
||||
pCorner2:setFlipX(true);
|
||||
pSprite:addChild(pCorner2);
|
||||
|
||||
local pCorner3 = CCSprite:create("Images/bugs/corner.png");
|
||||
pCorner3:setPosition(CCPoint(nX, -nY));
|
||||
local pCorner3 = cc.Sprite:create("Images/bugs/corner.png");
|
||||
pCorner3:setPosition(cc.p(nX, -nY));
|
||||
pCorner3:setFlipY(true);
|
||||
pSprite:addChild(pCorner3);
|
||||
|
||||
local pCorner4 = CCSprite:create("Images/bugs/corner.png");
|
||||
pCorner4:setPosition(CCPoint(-nX, -nY));
|
||||
local pCorner4 = cc.Sprite:create("Images/bugs/corner.png");
|
||||
pCorner4:setPosition(cc.p(-nX, -nY));
|
||||
pCorner4:setFlipX(true);
|
||||
pCorner4:setFlipY(true);
|
||||
pSprite:addChild(pCorner4);
|
||||
|
||||
local pEdge = CCSprite:create("Images/bugs/edge.png");
|
||||
local pEdge = cc.Sprite:create("Images/bugs/edge.png");
|
||||
pEdge:setScaleX(nWidth);
|
||||
pEdge:setPosition(CCPoint(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), nY));
|
||||
pEdge:setPosition(cc.p(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), nY));
|
||||
pSprite:addChild(pEdge);
|
||||
|
||||
local pEdge2 = CCSprite:create("Images/bugs/edge.png");
|
||||
local pEdge2 = cc.Sprite:create("Images/bugs/edge.png");
|
||||
pEdge2:setScaleX(nWidth);
|
||||
pEdge2:setPosition(CCPoint(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), -nY));
|
||||
pEdge2:setPosition(cc.p(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), -nY));
|
||||
pEdge2:setFlipY(true);
|
||||
pSprite:addChild(pEdge2);
|
||||
|
||||
local pEdge3 = CCSprite:create("Images/bugs/edge.png");
|
||||
local pEdge3 = cc.Sprite:create("Images/bugs/edge.png");
|
||||
pEdge3:setRotation(90);
|
||||
pEdge3:setScaleX(nHeight);
|
||||
pEdge3:setPosition(CCPoint(nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2)));
|
||||
pEdge3:setPosition(cc.p(nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2)));
|
||||
pSprite:addChild(pEdge3);
|
||||
|
||||
local pEdge4 = CCSprite:create("Images/bugs/edge.png");
|
||||
local pEdge4 = cc.Sprite:create("Images/bugs/edge.png");
|
||||
pEdge4:setRotation(270);
|
||||
pEdge4:setScaleX(nHeight);
|
||||
pEdge4:setPosition(CCPoint(-nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2)));
|
||||
pEdge4:setPosition(cc.p(-nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2)));
|
||||
pSprite:addChild(pEdge4);
|
||||
|
||||
pSprite:addChild(pLabel);
|
||||
end
|
||||
|
||||
local pQuestion1 = CCSprite:create()
|
||||
local pQuestion1 = cc.Sprite:create()
|
||||
InitQuestionContainerSprite(pQuestion1)
|
||||
local pQuestion2 = CCSprite:create()
|
||||
local pQuestion2 = cc.Sprite:create()
|
||||
InitQuestionContainerSprite(pQuestion2)
|
||||
|
||||
local function menuCallback()
|
||||
print("Selected")
|
||||
end
|
||||
local pMenuItemSprite = CCMenuItemSprite:create(pQuestion1,pQuestion2)
|
||||
local pMenuItemSprite = cc.MenuItemSprite:create(pQuestion1,pQuestion2)
|
||||
pMenuItemSprite:registerScriptTapHandler(menuCallback)
|
||||
local pLayerColor1 = CCLayerColor:create(Color4B(0,0,255,255), 100, 100);
|
||||
local pLayerColor1 = cc.LayerColor:create(cc.c4b(0,0,255,255), 100, 100);
|
||||
-- question->release();
|
||||
-- question2->release();
|
||||
|
||||
local pLayerColor2 = CCLayerColor:create(Color4B(255,0,0,255), 100, 100);
|
||||
local pMenuItemSprite2 = CCMenuItemSprite:create(pLayerColor1, pLayerColor2);
|
||||
local pLayerColor2 = cc.LayerColor:create(cc.c4b(255,0,0,255), 100, 100);
|
||||
local pMenuItemSprite2 = cc.MenuItemSprite:create(pLayerColor1, pLayerColor2);
|
||||
pMenuItemSprite2:registerScriptTapHandler(menuCallback)
|
||||
|
||||
local arr = CCArray:create()
|
||||
--[[
|
||||
local arr = cc.Array:create()
|
||||
arr:addObject(pMenuItemSprite)
|
||||
arr:addObject(pMenuItemSprite2)
|
||||
local pMenu = CCMenu:createWithArray(arr)
|
||||
]]--
|
||||
local pMenu = cc.Menu:create(pMenuItemSprite, pMenuItemSprite2)
|
||||
pMenu:alignItemsVerticallyWithPadding(100);
|
||||
pMenu:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2));
|
||||
pMenu:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2));
|
||||
|
||||
-- add the label as a child to this Layer
|
||||
pLayer:addChild(pMenu);
|
||||
|
@ -193,28 +198,28 @@ local BugTest624_entry = nil
|
|||
local BugTest624_2_entry = nil
|
||||
|
||||
local function BugTest624()
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
|
||||
local pLabel = CCLabelTTF:create("Layer1", "Marker Felt", 36);
|
||||
pLabel:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2));
|
||||
local pLabel = cc.LabelTTF:create("Layer1", "Marker Felt", 36);
|
||||
pLabel:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2));
|
||||
pLayer:addChild(pLabel);
|
||||
pLayer:setAccelerometerEnabled(true);
|
||||
-- schedule(schedule_selector(Bug624Layer::switchLayer), 5.0f);
|
||||
|
||||
local function BugTest624_SwitchLayer()
|
||||
local scheduler = CCDirector:getInstance():getScheduler()
|
||||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
scheduler:unscheduleScriptEntry(BugTest624_entry)
|
||||
|
||||
local pScene = CCScene:create();
|
||||
local pScene = cc.Scene:create();
|
||||
local pNewPlayer = BugTest624_2()
|
||||
CreateBugsTestBackMenuItem(pNewPlayer)
|
||||
pScene:addChild(pNewPlayer);
|
||||
CCDirector:getInstance():replaceScene(CCTransitionFade:create(2.0, pScene, Color3B(255,255,255)));
|
||||
cc.Director:getInstance():replaceScene(cc.TransitionFade:create(2.0, pScene, cc.c3b(255,255,255)));
|
||||
end
|
||||
|
||||
|
||||
local function BugTest624_OnEnterOrExit(tag)
|
||||
local scheduler = CCDirector:getInstance():getScheduler()
|
||||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
if tag == "enter" then
|
||||
BugTest624_entry = scheduler:scheduleScriptFunc(BugTest624_SwitchLayer, 5.0, false)
|
||||
elseif tag == "exit" then
|
||||
|
@ -232,26 +237,26 @@ local function BugTest624()
|
|||
end
|
||||
|
||||
function BugTest624_2()
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
|
||||
local pLabel = CCLabelTTF:create("Layer2", "Marker Felt", 36);
|
||||
pLabel:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2));
|
||||
local pLabel = cc.LabelTTF:create("Layer2", "Marker Felt", 36);
|
||||
pLabel:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2));
|
||||
pLayer:addChild(pLabel);
|
||||
pLayer:setAccelerometerEnabled(true);
|
||||
|
||||
local function BugTest624_2_SwitchLayer()
|
||||
local scheduler = CCDirector:getInstance():getScheduler()
|
||||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
scheduler:unscheduleScriptEntry(BugTest624_2_entry)
|
||||
|
||||
local pScene = CCScene:create();
|
||||
local pScene = cc.Scene:create();
|
||||
local pNewPlayer = BugTest624()
|
||||
CreateBugsTestBackMenuItem(pNewPlayer)
|
||||
pScene:addChild(pNewPlayer);
|
||||
CCDirector:getInstance():replaceScene(CCTransitionFade:create(2.0, pScene, Color3B(255,0,0)));
|
||||
cc.Director:getInstance():replaceScene(cc.TransitionFade:create(2.0, pScene, cc.c3b(255,0,0)));
|
||||
end
|
||||
|
||||
local function BugTest624_2_OnEnterOrExit(tag)
|
||||
local scheduler = CCDirector:getInstance():getScheduler()
|
||||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
if tag == "enter" then
|
||||
BugTest624_2_entry = scheduler:scheduleScriptFunc(BugTest624_2_SwitchLayer, 5.0, false)
|
||||
elseif tag == "exit" then
|
||||
|
@ -270,18 +275,18 @@ end
|
|||
|
||||
--BugTest886
|
||||
local function BugTest886()
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
|
||||
local pSprite1 = CCSprite:create("Images/bugs/bug886.jpg")
|
||||
pSprite1:setAnchorPoint(CCPoint(0, 0))
|
||||
pSprite1:setPosition(CCPoint(0, 0))
|
||||
local pSprite1 = cc.Sprite:create("Images/bugs/bug886.jpg")
|
||||
pSprite1:setAnchorPoint(cc.p(0, 0))
|
||||
pSprite1:setPosition(cc.p(0, 0))
|
||||
pSprite1:setScaleX(0.6)
|
||||
pLayer:addChild(pSprite1)
|
||||
|
||||
local pSprite2 = CCSprite:create("Images/bugs/bug886.jpg")
|
||||
pSprite2:setAnchorPoint(CCPoint(0, 0))
|
||||
local pSprite2 = cc.Sprite:create("Images/bugs/bug886.jpg")
|
||||
pSprite2:setAnchorPoint(cc.p(0, 0))
|
||||
pSprite2:setScaleX(0.6)
|
||||
pSprite2:setPosition(CCPoint(pSprite1:getContentSize().width * 0.6 + 10, 0))
|
||||
pSprite2:setPosition(cc.p(pSprite1:getContentSize().width * 0.6 + 10, 0))
|
||||
pLayer:addChild(pSprite2)
|
||||
|
||||
return pLayer
|
||||
|
@ -289,54 +294,54 @@ end
|
|||
|
||||
--BugTest899
|
||||
local function BugTest899()
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
|
||||
local pBg = CCSprite:create("Images/bugs/RetinaDisplay.jpg")
|
||||
local pBg = cc.Sprite:create("Images/bugs/RetinaDisplay.jpg")
|
||||
pLayer:addChild(pBg,0)
|
||||
pBg:setAnchorPoint(CCPoint(0, 0))
|
||||
pBg:setAnchorPoint(cc.p(0, 0))
|
||||
|
||||
return pLayer
|
||||
end
|
||||
|
||||
--BugTest914
|
||||
local function BugTest914()
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
|
||||
pLayer:setTouchEnabled(true);
|
||||
|
||||
local pLayerColor = nil
|
||||
|
||||
for i = 0, 4 do
|
||||
pLayerColor = CCLayerColor:create(Color4B(i*20, i*20, i*20,255))
|
||||
pLayerColor:setContentSize(CCSize(i*100, i*100));
|
||||
pLayerColor:setPosition(CCPoint(Winsize.width/2, Winsize.height/2))
|
||||
pLayerColor:setAnchorPoint(CCPoint(0.5, 0.5));
|
||||
pLayerColor = cc.LayerColor:create(cc.c4b(i*20, i*20, i*20,255))
|
||||
pLayerColor:setContentSize(cc.size(i*100, i*100));
|
||||
pLayerColor:setPosition(cc.p(Winsize.width/2, Winsize.height/2))
|
||||
pLayerColor:setAnchorPoint(cc.p(0.5, 0.5));
|
||||
pLayerColor:ignoreAnchorPointForPosition(false);
|
||||
pLayer:addChild(pLayerColor, -1-i);
|
||||
end
|
||||
|
||||
--create and initialize a Label
|
||||
local function restart()
|
||||
local pScene = CCScene:create()
|
||||
local pScene = cc.Scene:create()
|
||||
local pLayer = BugTest914()
|
||||
CreateBugsTestBackMenuItem(pLayer)
|
||||
pScene:addChild(pLayer);
|
||||
CCDirector:getInstance():replaceScene(pScene)
|
||||
cc.Director:getInstance():replaceScene(pScene)
|
||||
end
|
||||
|
||||
local label = CCLabelTTF:create("Hello World", "Marker Felt", 64)
|
||||
local label = cc.LabelTTF:create("Hello World", "Marker Felt", 64)
|
||||
--position the label on the center of the screen
|
||||
label:setPosition(CCPoint( Winsize.width /2 , Winsize.height/2 ));
|
||||
label:setPosition(cc.p( Winsize.width /2 , Winsize.height/2 ));
|
||||
pLayer:addChild(label);
|
||||
|
||||
local item1 = CCMenuItemFont:create("restart")
|
||||
local item1 = cc.MenuItemFont:create("restart")
|
||||
item1:registerScriptTapHandler(restart)
|
||||
--Bug914Layer::restart));
|
||||
|
||||
local menu = CCMenu:create()
|
||||
local menu = cc.Menu:create()
|
||||
menu:addChild(item1)
|
||||
menu:alignItemsVertically()
|
||||
menu:setPosition(CCPoint(Winsize.width/2, 100))
|
||||
menu:setPosition(cc.p(Winsize.width/2, 100))
|
||||
pLayer:addChild(menu)
|
||||
|
||||
-- handling touch events
|
||||
|
@ -363,44 +368,45 @@ end
|
|||
|
||||
--BugTest1159
|
||||
local function BugTest1159()
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
|
||||
CCDirector:getInstance():setDepthTest(true)
|
||||
cc.Director:getInstance():setDepthTest(true)
|
||||
|
||||
local background = CCLayerColor:create(Color4B(255, 0, 255, 255))
|
||||
local background = cc.LayerColor:create(cc.c4b(255, 0, 255, 255))
|
||||
pLayer:addChild(background)
|
||||
|
||||
local sprite_a = CCLayerColor:create(Color4B(255, 0, 0, 255), 700, 700)
|
||||
sprite_a:setAnchorPoint(CCPoint(0.5, 0.5))
|
||||
local sprite_a = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 700, 700)
|
||||
sprite_a:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
sprite_a:ignoreAnchorPointForPosition(false)
|
||||
sprite_a:setPosition(CCPoint(0.0, Winsize.height/2))
|
||||
sprite_a:setPosition(cc.p(0.0, Winsize.height/2))
|
||||
pLayer:addChild(sprite_a)
|
||||
|
||||
--[[
|
||||
local arr = cc.Array:create()
|
||||
arr:addObject(cc.MoveTo:create(1.0, cc.p(1024.0, 384.0)))
|
||||
arr:addObject(cc.MoveTo:create(1.0, cc.p(0.0, 384.0)))
|
||||
]]--
|
||||
local seq = cc.Sequence:create(cc.MoveTo:create(1.0, cc.p(1024.0, 384.0)), cc.MoveTo:create(1.0, cc.p(0.0, 384.0)))
|
||||
sprite_a:runAction(cc.RepeatForever:create(seq))
|
||||
|
||||
local arr = CCArray:create()
|
||||
arr:addObject(CCMoveTo:create(1.0, CCPoint(1024.0, 384.0)))
|
||||
arr:addObject(CCMoveTo:create(1.0, CCPoint(0.0, 384.0)))
|
||||
local seq = CCSequence:create(arr)
|
||||
sprite_a:runAction(CCRepeatForever:create(seq))
|
||||
|
||||
local sprite_b = CCLayerColor:create(Color4B(0, 0, 255, 255), 400, 400);
|
||||
sprite_b:setAnchorPoint(CCPoint(0.5, 0.5))
|
||||
local sprite_b = cc.LayerColor:create(cc.c4b(0, 0, 255, 255), 400, 400);
|
||||
sprite_b:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
sprite_b:ignoreAnchorPointForPosition(false);
|
||||
sprite_b:setPosition(CCPoint(Winsize.width/2, Winsize.height/2));
|
||||
sprite_b:setPosition(cc.p(Winsize.width/2, Winsize.height/2));
|
||||
pLayer:addChild(sprite_b);
|
||||
|
||||
local function menuCallback()
|
||||
local pScene = CCScene:create()
|
||||
local pScene = cc.Scene:create()
|
||||
local pLayer = BugTest1159()
|
||||
CreateBugsTestBackMenuItem(pLayer)
|
||||
pScene:addChild(pLayer);
|
||||
CCDirector:getInstance():replaceScene(CCTransitionPageTurn:create(1.0, pScene, false))
|
||||
cc.Director:getInstance():replaceScene(cc.TransitionPageTurn:create(1.0, pScene, false))
|
||||
end
|
||||
local label = CCMenuItemLabel:create(CCLabelTTF:create("Flip Me", "Helvetica", 24));
|
||||
local label = cc.MenuItemLabel:create(cc.LabelTTF:create("Flip Me", "Helvetica", 24));
|
||||
label:registerScriptTapHandler(menuCallback)
|
||||
local menu = CCMenu:create();
|
||||
local menu = cc.Menu:create();
|
||||
menu:addChild(label)
|
||||
menu:setPosition(CCPoint(Winsize.width - 200.0, 50.0));
|
||||
menu:setPosition(cc.p(Winsize.width - 200.0, 50.0));
|
||||
pLayer:addChild(menu);
|
||||
|
||||
local function onNodeEvent(event)
|
||||
|
@ -410,7 +416,7 @@ local function BugTest1159()
|
|||
scheduler:unscheduleScriptEntry(schedulerEntry)
|
||||
end
|
||||
]]--
|
||||
CCDirector:getInstance():setDepthTest(false)
|
||||
cc.Director:getInstance():setDepthTest(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -421,19 +427,19 @@ end
|
|||
|
||||
--BugTest1174
|
||||
local function BugTest1174()
|
||||
local pLayer = CCLayer:create()
|
||||
local pLayer = cc.Layer:create()
|
||||
|
||||
local function check_for_error(p1,p2,p3,p4,s,t)
|
||||
local p4_p3 = CCPoint.__sub(p4,p3)
|
||||
local p4_p3_t = CCPoint.__mul(p4_p3,t)
|
||||
local hitPoint1 = CCPoint.__add(p3,p4_p3_t)
|
||||
local p4_p3 = cc.p.__sub(p4,p3)
|
||||
local p4_p3_t = cc.p.__mul(p4_p3,t)
|
||||
local hitp1 = cc.p.__add(p3,p4_p3_t)
|
||||
|
||||
local p2_p1 = CCPoint.__sub(p2,p1)
|
||||
local p2_p1_s = CCPoint.__mul(p2_p1,s)
|
||||
local hitPoint2 = CCPoint.__add(p1,p2_p1_s)
|
||||
local p2_p1 = cc.p.__sub(p2,p1)
|
||||
local p2_p1_s = cc.p.__mul(p2_p1,s)
|
||||
local hitp2 = cc.p.__add(p1,p2_p1_s)
|
||||
|
||||
if math.abs(hitPoint1.x - hitPoint2.x ) > 0.1 or math.abs(hitPoint1.y - hitPoint2.y) > 0.1 then
|
||||
local strErr = "ERROR: ("..hitPoint1.x..","..hitPoint1.y..") != ("..hitPoint2.x..","..hitPoint2.y..")"
|
||||
if math.abs(hitp1.x - hitp2.x ) > 0.1 or math.abs(hitp1.y - hitp2.y) > 0.1 then
|
||||
local strErr = "ERROR: ("..hitp1.x..","..hitp1.y..") != ("..hitp2.x..","..hitp2.y..")"
|
||||
print(strErr)
|
||||
return 1
|
||||
end
|
||||
|
@ -480,12 +486,12 @@ local function BugTest1174()
|
|||
local cx = math.random() * -5000
|
||||
local cy = math.random() * -5000
|
||||
|
||||
A = CCPoint(ax,ay)
|
||||
B = CCPoint(bx,by)
|
||||
C = CCPoint(cx,cy)
|
||||
D = CCPoint(dx,dy)
|
||||
A = cc.p(ax,ay)
|
||||
B = cc.p(bx,by)
|
||||
C = cc.p(cx,cy)
|
||||
D = cc.p(dx,dy)
|
||||
|
||||
bRet,s,t = CCPoint:isLineIntersect( A, D, B, C, s, t)
|
||||
bRet,s,t = cc.p:isLineIntersect( A, D, B, C, s, t)
|
||||
if true == bRet then
|
||||
if 1 == check_for_error(A,D,B,C,s,t) then
|
||||
err = err + 1
|
||||
|
@ -501,13 +507,13 @@ local function BugTest1174()
|
|||
--------
|
||||
print("Test2 - Start")
|
||||
|
||||
p1 = CCPoint(220,480);
|
||||
p2 = CCPoint(304,325);
|
||||
p3 = CCPoint(264,416);
|
||||
p4 = CCPoint(186,416);
|
||||
p1 = cc.p(220,480);
|
||||
p2 = cc.p(304,325);
|
||||
p3 = cc.p(264,416);
|
||||
p4 = cc.p(186,416);
|
||||
s = 0.0;
|
||||
t = 0.0;
|
||||
bRet,s,t = CCPoint:isLineIntersect( p1, p2, p3, p4, s, t)
|
||||
bRet,s,t = cc.p:isLineIntersect( p1, p2, p3, p4, s, t)
|
||||
if true == bRet then
|
||||
check_for_error(p1, p2, p3, p4, s, t)
|
||||
end
|
||||
|
@ -526,13 +532,13 @@ local function BugTest1174()
|
|||
-- c | d
|
||||
local ax = math.random() * -500
|
||||
local ay = math.random() * 500
|
||||
p1 = CCPoint(ax,ay);
|
||||
p1 = cc.p(ax,ay);
|
||||
-- a | b
|
||||
-- -----
|
||||
-- c | D
|
||||
local dx = math.random() * 500
|
||||
local dy = math.random() * -500
|
||||
p2 = CCPoint(dx,dy)
|
||||
p2 = cc.p(dx,dy)
|
||||
|
||||
-------
|
||||
|
||||
|
@ -542,17 +548,17 @@ local function BugTest1174()
|
|||
-- -----
|
||||
-- C | d
|
||||
local cx = math.random() * -500
|
||||
p3 = CCPoint(cx,y)
|
||||
p3 = cc.p(cx,y)
|
||||
|
||||
-- a | B
|
||||
-- -----
|
||||
-- c | d
|
||||
local bx = math.random() * 500
|
||||
p4 = CCPoint(bx,y)
|
||||
p4 = cc.p(bx,y)
|
||||
|
||||
s = 0.0
|
||||
t = 0.0
|
||||
bRet,s,t = CCPoint:isLineIntersect(p1, p2, p3, p4, s, t)
|
||||
bRet,s,t = cc.p:isLineIntersect(p1, p2, p3, p4, s, t)
|
||||
if true == bRet then
|
||||
if 1 == check_for_error(p1, p2, p3, p4, s,t ) then
|
||||
err = err + 1
|
||||
|
@ -580,41 +586,41 @@ local CreateBugsTestTable = {
|
|||
}
|
||||
|
||||
local function CreateBugsTestScene(nBugNo)
|
||||
local pNewscene = CCScene:create()
|
||||
local pNewscene = cc.Scene:create()
|
||||
local pLayer = CreateBugsTestTable[nBugNo]()
|
||||
CreateBugsTestBackMenuItem(pLayer)
|
||||
pNewscene:addChild(pLayer)
|
||||
CCDirector:getInstance():replaceScene(pNewscene)
|
||||
cc.Director:getInstance():replaceScene(pNewscene)
|
||||
--pLayer:autorelease()
|
||||
end
|
||||
|
||||
|
||||
local function BugsTestMainLayer()
|
||||
local ret = CCLayer:create();
|
||||
local ret = cc.Layer:create();
|
||||
|
||||
--menu callback
|
||||
local function menuCallback(tag, pMenuItem)
|
||||
local nIdx = pMenuItem:getZOrder() - kItemTagBasic
|
||||
local BugTestScene = CreateBugsTestScene(nIdx)
|
||||
if nil ~= testScene then
|
||||
CCDirector:getInstance():replaceScene(testScene)
|
||||
cc.Director:getInstance():replaceScene(testScene)
|
||||
end
|
||||
end
|
||||
|
||||
-- add menu items for tests
|
||||
local pItemMenu = CCMenu:create();
|
||||
local pItemMenu = cc.Menu:create();
|
||||
local nTestCount = table.getn(testNames);
|
||||
|
||||
local i = 1
|
||||
for i = 1, nTestCount do
|
||||
local label = CCLabelTTF:create(testNames[i], "Arial", 24)
|
||||
local pMenuItem = CCMenuItemLabel:create(label)
|
||||
local label = cc.LabelTTF:create(testNames[i], "Arial", 24)
|
||||
local pMenuItem = cc.MenuItemLabel:create(label)
|
||||
pMenuItem:registerScriptTapHandler(menuCallback)
|
||||
pItemMenu:addChild(pMenuItem, i + kItemTagBasic)
|
||||
pMenuItem:setPosition( CCPoint( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) ))
|
||||
pMenuItem:setPosition( cc.p( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) ))
|
||||
end
|
||||
|
||||
pItemMenu:setPosition(CCPoint(0, 0))
|
||||
pItemMenu:setPosition(cc.p(0, 0))
|
||||
ret:addChild(pItemMenu)
|
||||
ret:setTouchEnabled(true)
|
||||
|
||||
|
@ -623,13 +629,14 @@ local function BugsTestMainLayer()
|
|||
local ptCurPos = {x = 0, y = 0}
|
||||
local function onTouchBegan(x, y)
|
||||
ptBeginPos = {x = x, y = y}
|
||||
-- CCTOUCHBEGAN event must return true
|
||||
-- cc.TOUCHBEGAN event must return true
|
||||
return true
|
||||
end
|
||||
|
||||
local function onTouchMoved(x, y)
|
||||
local nMoveY = y - ptBeginPos.y
|
||||
local curPosx, curPosy = pItemMenu:getPosition()
|
||||
local curPos = pItemMenu:getPosition()
|
||||
local curPosx, curPosy = curPos.x,curPos.y
|
||||
local nextPosy = curPosy + nMoveY
|
||||
if nextPosy < 0 then
|
||||
pItemMenu:setPosition(0, 0)
|
||||
|
@ -660,7 +667,7 @@ local function BugsTestMainLayer()
|
|||
end
|
||||
function BugsTestMain()
|
||||
cclog("BugsTestMain");
|
||||
local scene = CCScene:create();
|
||||
local scene = cc.Scene:create();
|
||||
scene:addChild(BugsTestMainLayer());
|
||||
scene:addChild(CreateBackMenuItem());
|
||||
return scene;
|
||||
|
|
|
@ -1,27 +1,28 @@
|
|||
local size = CCDirector:getInstance():getWinSize()
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
local layer = nil
|
||||
local kTagSprite = 1
|
||||
|
||||
local function initWithLayer()
|
||||
local sprite = CCSprite:create(s_pPathGrossini)
|
||||
local sprite = cc.Sprite:create(s_pPathGrossini)
|
||||
|
||||
local bgLayer = CCLayerColor:create(Color4B(255,255,0,255))
|
||||
local bgLayer = cc.LayerColor:create(cc.c4b(255,255,0,255))
|
||||
layer:addChild(bgLayer, -1)
|
||||
|
||||
layer:addChild(sprite, 0, kTagSprite)
|
||||
sprite:setPosition(CCPoint(20,150))
|
||||
sprite:setPosition(cc.p(20,150))
|
||||
|
||||
sprite:runAction(CCJumpTo:create(4, CCPoint(300,48), 100, 4))
|
||||
sprite:runAction(cc.JumpTo:create(4, cc.p(300,48), 100, 4))
|
||||
|
||||
bgLayer:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(
|
||||
CCFadeIn:create(1),
|
||||
CCFadeOut:create(1))))
|
||||
bgLayer:runAction(cc.RepeatForever:create(cc.Sequence:create(
|
||||
cc.FadeIn:create(1),
|
||||
cc.FadeOut:create(1))))
|
||||
|
||||
local function onTouchEnded(x, y)
|
||||
local s = layer:getChildByTag(kTagSprite)
|
||||
s:stopAllActions()
|
||||
s:runAction(CCMoveTo:create(1, CCPoint(x, y)))
|
||||
local posX, posY = s:getPosition()
|
||||
s:runAction(cc.MoveTo:create(1, cc.p(x, y)))
|
||||
local pos = s:getPosition()
|
||||
local posX, posY = pos.x,pos.y
|
||||
local o = x - posX
|
||||
local a = y - posY
|
||||
local at = math.atan(o / a) / math.pi * 180.0
|
||||
|
@ -33,7 +34,7 @@ local function initWithLayer()
|
|||
at = 180 - math.abs(at)
|
||||
end
|
||||
end
|
||||
s:runAction(CCRotateTo:create(1, at))
|
||||
s:runAction(cc.RotateTo:create(1, at))
|
||||
end
|
||||
|
||||
local function onTouch(eventType, x, y)
|
||||
|
@ -55,8 +56,8 @@ end
|
|||
--------------------------------
|
||||
function ClickAndMoveTest()
|
||||
cclog("ClickAndMoveTest")
|
||||
local scene = CCScene:create()
|
||||
layer = CCLayer:create()
|
||||
local scene = cc.Scene:create()
|
||||
layer = cc.Layer:create()
|
||||
|
||||
initWithLayer()
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ local MUSIC_FILE = "background.mp3"
|
|||
local LINE_SPACE = 40
|
||||
|
||||
local function CocosDenshionTest()
|
||||
local ret = CCLayer:create()
|
||||
local ret = cc.Layer:create()
|
||||
local m_pItmeMenu = nil
|
||||
local m_tBeginPos = CCPoint(0, 0)
|
||||
local m_tBeginPos = cc.p(0, 0)
|
||||
local m_nSoundId = 0
|
||||
|
||||
local testItems = {
|
||||
|
@ -93,20 +93,20 @@ local function CocosDenshionTest()
|
|||
end
|
||||
end
|
||||
-- add menu items for tests
|
||||
m_pItmeMenu = CCMenu:create()
|
||||
m_pItmeMenu = cc.Menu:create()
|
||||
|
||||
m_nTestCount = table.getn(testItems)
|
||||
local i = 1
|
||||
for i = 1, m_nTestCount do
|
||||
local label = CCLabelTTF:create(testItems[i], "Arial", 24)
|
||||
local pMenuItem = CCMenuItemLabel:create(label)
|
||||
local label = cc.LabelTTF:create(testItems[i], "Arial", 24)
|
||||
local pMenuItem = cc.MenuItemLabel:create(label)
|
||||
pMenuItem:registerScriptTapHandler(menuCallback)
|
||||
m_pItmeMenu:addChild(pMenuItem, i + 10000 -1)
|
||||
pMenuItem:setPosition( CCPoint( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) ))
|
||||
pMenuItem:setPosition( cc.p( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) ))
|
||||
end
|
||||
|
||||
m_pItmeMenu:setContentSize(CCSize(VisibleRect:getVisibleRect().size.width, (m_nTestCount + 1) * LINE_SPACE))
|
||||
m_pItmeMenu:setPosition(CCPoint(0, 0))
|
||||
m_pItmeMenu:setContentSize(cc.size(VisibleRect:getVisibleRect().width, (m_nTestCount + 1) * LINE_SPACE))
|
||||
m_pItmeMenu:setPosition(cc.p(0, 0))
|
||||
ret:addChild(m_pItmeMenu)
|
||||
ret:setTouchEnabled(true)
|
||||
|
||||
|
@ -133,21 +133,22 @@ local function CocosDenshionTest()
|
|||
if eventType == "began" then
|
||||
prev.x = x
|
||||
prev.y = y
|
||||
m_tBeginPos = CCPoint(x, y)
|
||||
m_tBeginPos = cc.p(x, y)
|
||||
return true
|
||||
elseif eventType == "moved" then
|
||||
local touchLocation = CCPoint(x, y)
|
||||
local touchLocation = cc.p(x, y)
|
||||
local nMoveY = touchLocation.y - m_tBeginPos.y
|
||||
local curPosX, curPosY = m_pItmeMenu:getPosition()
|
||||
local curPos = CCPoint(curPosX, curPosY)
|
||||
local nextPos = CCPoint(curPos.x, curPos.y + nMoveY)
|
||||
local curPos = m_pItmeMenu:getPosition()
|
||||
local curPosX, curPosY = curPos.x,curPos.y
|
||||
local curPos = cc.p(curPosX, curPosY)
|
||||
local nextPos = cc.p(curPos.x, curPos.y + nMoveY)
|
||||
|
||||
if nextPos.y < 0.0 then
|
||||
m_pItmeMenu:setPosition(CCPoint(0, 0))
|
||||
m_pItmeMenu:setPosition(cc.p(0, 0))
|
||||
end
|
||||
|
||||
if nextPos.y > ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().size.height) then
|
||||
m_pItmeMenu:setPosition(CCPoint(0, ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().size.height)))
|
||||
if nextPos.y > ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().height) then
|
||||
m_pItmeMenu:setPosition(cc.p(0, ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().height)))
|
||||
end
|
||||
|
||||
m_pItmeMenu:setPosition(nextPos)
|
||||
|
@ -165,7 +166,7 @@ end
|
|||
|
||||
function CocosDenshionTestMain()
|
||||
cclog("CocosDenshionTestMain")
|
||||
local scene = CCScene:create()
|
||||
local scene = cc.Scene:create()
|
||||
scene:addChild(CocosDenshionTest())
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
return scene
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
local function CurrentLanguageTest()
|
||||
local ret = CCLayer:create()
|
||||
local label = CCLabelTTF:create("Current language Test", "Arial", 28)
|
||||
local ret = cc.Layer:create()
|
||||
local label = cc.LabelTTF:create("Current language Test", "Arial", 28)
|
||||
ret:addChild(label, 0)
|
||||
label:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y-50) )
|
||||
label:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y-50) )
|
||||
|
||||
local labelLanguage = CCLabelTTF:create("", "Arial", 20)
|
||||
local labelLanguage = cc.LabelTTF:create("", "Arial", 20)
|
||||
labelLanguage:setPosition(VisibleRect:center())
|
||||
|
||||
local currentLanguageType = CCApplication:getInstance():getCurrentLanguage()
|
||||
local currentLanguageType = cc.Application:getInstance():getCurrentLanguage()
|
||||
|
||||
if currentLanguageType == kLanguageEnglish then
|
||||
labelLanguage:setString("current language is English")
|
||||
|
@ -39,7 +39,7 @@ local function CurrentLanguageTest()
|
|||
end
|
||||
|
||||
function CurrentLanguageTestMain()
|
||||
local scene = CCScene:create()
|
||||
local scene = cc.Scene:create()
|
||||
local pLayer = CurrentLanguageTest()
|
||||
scene:addChild(pLayer)
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
|
|
|
@ -5,7 +5,7 @@ local function drawPrimitivesMainLayer()
|
|||
local testCount = 2
|
||||
local maxCases = testCount
|
||||
local curCase = 0
|
||||
local size = CCDirector:getInstance():getWinSize()
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
local curLayer = nil
|
||||
|
||||
local function orderCallbackMenu()
|
||||
|
@ -27,23 +27,23 @@ local function drawPrimitivesMainLayer()
|
|||
showCurrentTest()
|
||||
end
|
||||
|
||||
local ordercallbackmenu = CCMenu:create()
|
||||
local size = CCDirector:getInstance():getWinSize()
|
||||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local ordercallbackmenu = cc.Menu:create()
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
ordercallbackmenu:addChild(item1,kItemTagBasic)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
ordercallbackmenu:addChild(item2,kItemTagBasic)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
ordercallbackmenu:addChild(item3,kItemTagBasic)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
||||
item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2))
|
||||
item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
||||
item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
||||
item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2))
|
||||
item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
||||
|
||||
ordercallbackmenu:setPosition(CCPoint(0, 0))
|
||||
ordercallbackmenu:setPosition(cc.p(0, 0))
|
||||
|
||||
return ordercallbackmenu
|
||||
end
|
||||
|
@ -66,89 +66,90 @@ local function drawPrimitivesMainLayer()
|
|||
|
||||
local function InitTitle(layer)
|
||||
--Title
|
||||
local lableTitle = CCLabelTTF:create(GetTitle(), "Arial", 40)
|
||||
local lableTitle = cc.LabelTTF:create(GetTitle(), "Arial", 40)
|
||||
layer:addChild(lableTitle, 15)
|
||||
lableTitle:setPosition(CCPoint(size.width / 2, size.height - 32))
|
||||
lableTitle:setColor(Color3B(255, 255, 40))
|
||||
lableTitle:setPosition(cc.p(size.width / 2, size.height - 32))
|
||||
lableTitle:setColor(cc.c3b(255, 255, 40))
|
||||
--SubTitle
|
||||
local subLabelTitle = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16)
|
||||
local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16)
|
||||
layer:addChild(subLabelTitle, 15)
|
||||
subLabelTitle:setPosition(CCPoint(size.width / 2, size.height - 80))
|
||||
subLabelTitle:setPosition(cc.p(size.width / 2, size.height - 80))
|
||||
end
|
||||
|
||||
local function createDrawPrimitivesEffect()
|
||||
local layer = CCLayer:create()
|
||||
local layer = cc.Layer:create()
|
||||
|
||||
InitTitle(layer)
|
||||
|
||||
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))
|
||||
|
||||
local function primitivesDraw()
|
||||
CCDrawPrimitives.ccDrawLine(VisibleRect:leftBottom(), VisibleRect:rightTop() )
|
||||
gl.DrawPrimitives.ccDrawLine(VisibleRect:leftBottom(), VisibleRect:rightTop() )
|
||||
|
||||
gl.lineWidth( 5.0 )
|
||||
CCDrawPrimitives.ccDrawColor4B(255,0,0,255)
|
||||
CCDrawPrimitives.ccDrawLine( VisibleRect:leftTop(), VisibleRect:rightBottom() )
|
||||
gl.DrawPrimitives.ccDrawColor4B(255,0,0,255)
|
||||
gl.DrawPrimitives.ccDrawLine( VisibleRect:leftTop(), VisibleRect:rightBottom() )
|
||||
|
||||
|
||||
|
||||
CCDrawPrimitives.ccPointSize(64)
|
||||
CCDrawPrimitives.ccDrawColor4B(0, 0, 255, 128)
|
||||
CCDrawPrimitives.ccDrawPoint(VisibleRect:center())
|
||||
gl.DrawPrimitives.ccPointSize(64)
|
||||
gl.DrawPrimitives.ccDrawColor4B(0, 0, 255, 128)
|
||||
gl.DrawPrimitives.ccDrawPoint(VisibleRect:center())
|
||||
|
||||
local points = {CCPoint(60,60), CCPoint(70,70), CCPoint(60,70), CCPoint(70,60) }
|
||||
CCDrawPrimitives.ccPointSize(4)
|
||||
CCDrawPrimitives.ccDrawColor4B(0,255,255,255)
|
||||
CCDrawPrimitives.ccDrawPoints(points,4)
|
||||
local points = {cc.p(60,60), cc.p(70,70), cc.p(60,70), cc.p(70,60) }
|
||||
gl.DrawPrimitives.ccPointSize(4)
|
||||
gl.DrawPrimitives.ccDrawColor4B(0,255,255,255)
|
||||
gl.DrawPrimitives.ccDrawPoints(points,4)
|
||||
|
||||
gl.lineWidth(16)
|
||||
CCDrawPrimitives.ccDrawColor4B(0, 255, 0, 255)
|
||||
CCDrawPrimitives.ccDrawCircle( VisibleRect:center(), 100, 0, 10, false)
|
||||
gl.DrawPrimitives.ccDrawColor4B(0, 255, 0, 255)
|
||||
gl.DrawPrimitives.ccDrawCircle( VisibleRect:center(), 100, 0, 10, false)
|
||||
|
||||
gl.lineWidth(2)
|
||||
CCDrawPrimitives.ccDrawColor4B(0, 255, 255, 255)
|
||||
CCDrawPrimitives.ccDrawCircle( VisibleRect:center(), 50, math.pi / 2, 50, true)
|
||||
gl.DrawPrimitives.ccDrawColor4B(0, 255, 255, 255)
|
||||
gl.DrawPrimitives.ccDrawCircle( VisibleRect:center(), 50, math.pi / 2, 50, true)
|
||||
|
||||
gl.lineWidth(2)
|
||||
CCDrawPrimitives.ccDrawColor4B(255, 0, 255, 255)
|
||||
CCDrawPrimitives.ccDrawSolidCircle( VisibleRect:center() + CCPoint(140,0), 40, math.rad(90), 50, 1.0, 1.0)
|
||||
gl.DrawPrimitives.ccDrawColor4B(255, 0, 255, 255)
|
||||
gl.DrawPrimitives.ccDrawSolidCircle( cc.p(VisibleRect:center().x + 140 ,VisibleRect:center().y), 40, math.rad(90), 50, 1.0, 1.0)
|
||||
|
||||
gl.lineWidth(10)
|
||||
CCDrawPrimitives.ccDrawColor4B(255, 255, 0, 255)
|
||||
local yellowPoints = { CCPoint(0,0), CCPoint(50,50), CCPoint(100,50), CCPoint(100,100), CCPoint(50,100)}
|
||||
CCDrawPrimitives.ccDrawPoly( yellowPoints, 5, false)
|
||||
gl.DrawPrimitives.ccDrawColor4B(255, 255, 0, 255)
|
||||
local yellowPoints = { cc.p(0,0), cc.p(50,50), cc.p(100,50), cc.p(100,100), cc.p(50,100)}
|
||||
gl.DrawPrimitives.ccDrawPoly( yellowPoints, 5, false)
|
||||
|
||||
gl.lineWidth(1)
|
||||
local filledVertices = { CCPoint(0,120), CCPoint(50,120), CCPoint(50,170), CCPoint(25,200), CCPoint(0,170) }
|
||||
CCDrawPrimitives.ccDrawSolidPoly(filledVertices, 5, Color4F(0.5, 0.5, 1, 1))
|
||||
local filledVertices = { cc.p(0,120), cc.p(50,120), cc.p(50,170), cc.p(25,200), cc.p(0,170) }
|
||||
gl.DrawPrimitives.ccDrawSolidPoly(filledVertices, 5, cc.c4f(0.5, 0.5, 1, 1))
|
||||
|
||||
gl.lineWidth(2)
|
||||
CCDrawPrimitives.ccDrawColor4B(255, 0, 255, 255)
|
||||
local closePoints= { CCPoint(30,130), CCPoint(30,230), CCPoint(50,200) }
|
||||
CCDrawPrimitives.ccDrawPoly( closePoints, 3, true)
|
||||
gl.DrawPrimitives.ccDrawColor4B(255, 0, 255, 255)
|
||||
local closePoints= { cc.p(30,130), cc.p(30,230), cc.p(50,200) }
|
||||
gl.DrawPrimitives.ccDrawPoly( closePoints, 3, true)
|
||||
|
||||
CCDrawPrimitives.ccDrawQuadBezier(VisibleRect:leftTop(), VisibleRect:center(), VisibleRect:rightTop(), 50)
|
||||
gl.DrawPrimitives.ccDrawQuadBezier(VisibleRect:leftTop(), VisibleRect:center(), VisibleRect:rightTop(), 50)
|
||||
|
||||
CCDrawPrimitives.ccDrawCubicBezier(VisibleRect:center(), CCPoint(VisibleRect:center().x + 30, VisibleRect:center().y + 50), CCPoint(VisibleRect:center().x + 60,VisibleRect:center().y - 50), VisibleRect:right(), 100)
|
||||
gl.DrawPrimitives.ccDrawCubicBezier(VisibleRect:center(), cc.p(VisibleRect:center().x + 30, VisibleRect:center().y + 50), cc.p(VisibleRect:center().x + 60,VisibleRect:center().y - 50), VisibleRect:right(), 100)
|
||||
|
||||
local solidvertices = {CCPoint(60,160), CCPoint(70,190), CCPoint(100,190), CCPoint(90,160)}
|
||||
CCDrawPrimitives.ccDrawSolidPoly( solidvertices, 4, Color4F(1, 1, 0, 1) )
|
||||
local solidvertices = {cc.p(60,160), cc.p(70,190), cc.p(100,190), cc.p(90,160)}
|
||||
gl.DrawPrimitives.ccDrawSolidPoly( solidvertices, 4, cc.c4f(1, 1, 0, 1) )
|
||||
|
||||
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))
|
||||
CCDrawPrimitives.ccDrawCatmullRom( array, 5)
|
||||
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),
|
||||
}
|
||||
gl.DrawPrimitives.ccDrawCatmullRom( array, 5)
|
||||
|
||||
CCDrawPrimitives.ccDrawCardinalSpline( array, 0,100)
|
||||
gl.DrawPrimitives.ccDrawCardinalSpline( array, 0,100)
|
||||
|
||||
gl.lineWidth(1)
|
||||
CCDrawPrimitives.ccDrawColor4B(255,255,255,255)
|
||||
CCDrawPrimitives.ccPointSize(1)
|
||||
gl.DrawPrimitives.ccDrawColor4B(255,255,255,255)
|
||||
gl.DrawPrimitives.ccPointSize(1)
|
||||
end
|
||||
|
||||
glNode:registerScriptDrawHandler(primitivesDraw)
|
||||
|
@ -159,44 +160,44 @@ local function drawPrimitivesMainLayer()
|
|||
end
|
||||
|
||||
local function createDrawNodeTest()
|
||||
local layer = CCLayer:create()
|
||||
local layer = cc.Layer:create()
|
||||
|
||||
InitTitle(layer)
|
||||
|
||||
local draw = CCDrawNode:create()
|
||||
local draw = cc.DrawNode:create()
|
||||
layer:addChild(draw, 10)
|
||||
|
||||
--Draw 10 circles
|
||||
for i=1, 10 do
|
||||
draw:drawDot(CCPoint(size.width/2, size.height/2), 10*(10-i), Color4F(math.random(0,1), math.random(0,1), math.random(0,1), 1))
|
||||
draw:drawDot(cc.p(size.width/2, size.height/2), 10*(10-i), cc.c4f(math.random(0,1), math.random(0,1), math.random(0,1), 1))
|
||||
end
|
||||
|
||||
--Draw polygons
|
||||
points = { CCPoint(size.height/4, 0), CCPoint(size.width, size.height / 5), CCPoint(size.width / 3 * 2, size.height) }
|
||||
draw:drawPolygon(points, table.getn(points), Color4F(1,0,0,0.5), 4, Color4F(0,0,1,1))
|
||||
points = { cc.p(size.height/4, 0), cc.p(size.width, size.height / 5), cc.p(size.width / 3 * 2, size.height) }
|
||||
draw:drawPolygon(points, table.getn(points), cc.c4f(1,0,0,0.5), 4, cc.c4f(0,0,1,1))
|
||||
|
||||
local o = 80
|
||||
local w = 20
|
||||
local h = 50
|
||||
local star1 = { CCPoint( o + w, o - h), CCPoint(o + w * 2, o), CCPoint(o + w * 2 + h, o + w), CCPoint(o + w * 2, o + w * 2) }
|
||||
local star1 = { cc.p( o + w, o - h), cc.p(o + w * 2, o), cc.p(o + w * 2 + h, o + w), cc.p(o + w * 2, o + w * 2) }
|
||||
|
||||
draw:drawPolygon(star1, table.getn(star1), Color4F(1,0,0,0.5), 1, Color4F(0,0,1,1))
|
||||
draw:drawPolygon(star1, table.getn(star1), cc.c4f(1,0,0,0.5), 1, cc.c4f(0,0,1,1))
|
||||
|
||||
o = 180
|
||||
w = 20
|
||||
h = 50
|
||||
local star2 = {
|
||||
CCPoint(o, o), CCPoint(o + w, o - h), CCPoint(o + w * 2, o), --lower spike
|
||||
CCPoint(o + w * 2 + h, o + w ), CCPoint(o + w * 2, o + w * 2), --right spike
|
||||
CCPoint(o + w, o + w * 2 + h), CCPoint(o, o + w * 2), --top spike
|
||||
CCPoint(o - h, o + w), --left spike
|
||||
cc.p(o, o), cc.p(o + w, o - h), cc.p(o + w * 2, o), --lower spike
|
||||
cc.p(o + w * 2 + h, o + w ), cc.p(o + w * 2, o + w * 2), --right spike
|
||||
cc.p(o + w, o + w * 2 + h), cc.p(o, o + w * 2), --top spike
|
||||
cc.p(o - h, o + w), --left spike
|
||||
};
|
||||
|
||||
draw:drawPolygon(star2, table.getn(star2), Color4F(1,0,0,0.5), 1, Color4F(0,0,1,1))
|
||||
draw:drawPolygon(star2, table.getn(star2), cc.c4f(1,0,0,0.5), 1, cc.c4f(0,0,1,1))
|
||||
|
||||
draw:drawSegment(CCPoint(20,size.height), CCPoint(20,size.height/2), 10, Color4F(0, 1, 0, 1))
|
||||
draw:drawSegment(cc.p(20,size.height), cc.p(20,size.height/2), 10, cc.c4f(0, 1, 0, 1))
|
||||
|
||||
draw:drawSegment(CCPoint(10,size.height/2), CCPoint(size.width/2, size.height/2), 40, Color4F(1, 0, 1, 0.5))
|
||||
draw:drawSegment(cc.p(10,size.height/2), cc.p(size.width/2, size.height/2), 40, cc.c4f(1, 0, 1, 0.5))
|
||||
|
||||
return layer
|
||||
end
|
||||
|
@ -210,14 +211,14 @@ local function drawPrimitivesMainLayer()
|
|||
end
|
||||
|
||||
function showCurrentTest()
|
||||
local curScene = CCScene:create()
|
||||
local curScene = cc.Scene:create()
|
||||
if nil ~= curScene then
|
||||
curLayer = createLayerByCurCase(curCase)
|
||||
if nil ~= curLayer then
|
||||
curScene:addChild(curLayer)
|
||||
curLayer:addChild(orderCallbackMenu(),15)
|
||||
curScene:addChild(CreateBackMenuItem())
|
||||
CCDirector:getInstance():replaceScene(curScene)
|
||||
cc.Director:getInstance():replaceScene(curScene)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -228,7 +229,7 @@ local function drawPrimitivesMainLayer()
|
|||
end
|
||||
|
||||
function DrawPrimitivesTest()
|
||||
local scene = CCScene:create()
|
||||
local scene = cc.Scene:create()
|
||||
scene:addChild(drawPrimitivesMainLayer())
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
return scene
|
||||
|
|
|
@ -8,29 +8,23 @@ local originCreateLayer = createTestLayer
|
|||
|
||||
local function createTestLayer(title, subtitle)
|
||||
local ret = originCreateLayer(title, subtitle)
|
||||
local bg = CCSprite:create("Images/background3.png")
|
||||
local bg = cc.Sprite:create("Images/background3.png")
|
||||
ret:addChild(bg, 0, kTagBackground)
|
||||
bg:setPosition( VisibleRect:center() )
|
||||
|
||||
local grossini = CCSprite:create("Images/grossinis_sister2.png")
|
||||
local grossini = cc.Sprite:create("Images/grossinis_sister2.png")
|
||||
bg:addChild(grossini, 1, kTagSprite1)
|
||||
grossini:setPosition( CCPoint(VisibleRect:left().x+VisibleRect:getVisibleRect().size.width/3.0, VisibleRect:bottom().y+ 200) )
|
||||
local sc = CCScaleBy:create(2, 5)
|
||||
grossini:setPosition( cc.p(VisibleRect:left().x+VisibleRect:getVisibleRect().width/3.0, VisibleRect:bottom().y+ 200) )
|
||||
local sc = cc.ScaleBy:create(2, 5)
|
||||
local sc_back = sc:reverse()
|
||||
local arr = CCArray:create()
|
||||
arr:addObject(sc)
|
||||
arr:addObject(sc_back)
|
||||
grossini:runAction( CCRepeatForever:create(CCSequence:create(arr)))
|
||||
grossini:runAction( cc.RepeatForever:create(cc.Sequence:create(sc, sc_back)))
|
||||
|
||||
local tamara = CCSprite:create("Images/grossinis_sister1.png")
|
||||
local tamara = cc.Sprite:create("Images/grossinis_sister1.png")
|
||||
bg:addChild(tamara, 1, kTagSprite2)
|
||||
tamara:setPosition( CCPoint(VisibleRect:left().x+2*VisibleRect:getVisibleRect().size.width/3.0,VisibleRect:bottom().y+200) )
|
||||
local sc2 = CCScaleBy:create(2, 5)
|
||||
tamara:setPosition( cc.p(VisibleRect:left().x+2*VisibleRect:getVisibleRect().width/3.0,VisibleRect:bottom().y+200) )
|
||||
local sc2 = cc.ScaleBy:create(2, 5)
|
||||
local sc2_back = sc2:reverse()
|
||||
arr = CCArray:create()
|
||||
arr:addObject(sc2)
|
||||
arr:addObject(sc2_back)
|
||||
tamara:runAction( CCRepeatForever:create(CCSequence:create(arr)))
|
||||
tamara:runAction( cc.RepeatForever:create(cc.Sequence:create(sc2, sc2_back)))
|
||||
|
||||
return ret
|
||||
end
|
||||
|
@ -50,25 +44,17 @@ local function Effect1()
|
|||
-- Lens3D is Grid3D and it's size is (15,10)
|
||||
-- Waves3D is Grid3D and it's size is (15,10)
|
||||
|
||||
local size = CCDirector:getInstance():getWinSize()
|
||||
local lens = CCLens3D:create(0.0, CCSize(15,10), CCPoint(size.width/2,size.height/2), 240)
|
||||
local waves = CCWaves3D:create(10, CCSize(15,10), 18, 15)
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
local lens = cc.Lens3D:create(0.0, cc.size(15,10), cc.p(size.width/2,size.height/2), 240)
|
||||
local waves = cc.Waves3D:create(10, cc.size(15,10), 18, 15)
|
||||
|
||||
local reuse = CCReuseGrid:create(1)
|
||||
local delay = CCDelayTime:create(8)
|
||||
local reuse = cc.ReuseGrid:create(1)
|
||||
local delay = cc.DelayTime:create(8)
|
||||
|
||||
local orbit = CCOrbitCamera:create(5, 1, 2, 0, 180, 0, -90)
|
||||
local orbit = cc.OrbitCamera:create(5, 1, 2, 0, 180, 0, -90)
|
||||
local orbit_back = orbit:reverse()
|
||||
local arr = CCArray:create()
|
||||
arr:addObject(orbit)
|
||||
arr:addObject(orbit_back)
|
||||
target:runAction( CCRepeatForever:create( CCSequence:create(arr)))
|
||||
arr = CCArray:create()
|
||||
arr:addObject(lens)
|
||||
arr:addObject(delay)
|
||||
arr:addObject(reuse)
|
||||
arr:addObject(waves)
|
||||
target:runAction( CCSequence:create(arr))
|
||||
target:runAction( cc.RepeatForever:create( cc.Sequence:create(orbit, orbit_back)))
|
||||
target:runAction( cc.Sequence:create(lens, delay, reuse, waves))
|
||||
return ret
|
||||
end
|
||||
|
||||
|
@ -86,28 +72,20 @@ local function Effect2()
|
|||
-- ShakyTiles is TiledGrid3D and it's size is (15,10)
|
||||
-- Shuffletiles is TiledGrid3D and it's size is (15,10)
|
||||
-- TurnOfftiles is TiledGrid3D and it's size is (15,10)
|
||||
local shaky = CCShakyTiles3D:create(5, CCSize(15,10), 4, false)
|
||||
local shuffle = CCShuffleTiles:create(0, CCSize(15,10), 3)
|
||||
local turnoff = CCTurnOffTiles:create(0, CCSize(15,10), 3)
|
||||
local shaky = cc.ShakyTiles3D:create(5, cc.size(15,10), 4, false)
|
||||
local shuffle = cc.ShuffleTiles:create(0, cc.size(15,10), 3)
|
||||
local turnoff = cc.TurnOffTiles:create(0, cc.size(15,10), 3)
|
||||
local turnon = turnoff:reverse()
|
||||
|
||||
-- reuse 2 times:
|
||||
-- 1 for shuffle
|
||||
-- 2 for turn off
|
||||
-- turnon tiles will use a new grid
|
||||
local reuse = CCReuseGrid:create(2)
|
||||
local reuse = cc.ReuseGrid:create(2)
|
||||
|
||||
local delay = CCDelayTime:create(1)
|
||||
local delay = cc.DelayTime:create(1)
|
||||
|
||||
local arr = CCArray:create()
|
||||
arr:addObject(shaky)
|
||||
arr:addObject(delay)
|
||||
arr:addObject(reuse)
|
||||
arr:addObject(shuffle)
|
||||
arr:addObject(tolua.cast(delay:clone(), "CCAction"))
|
||||
arr:addObject(turnoff)
|
||||
arr:addObject(turnon)
|
||||
target:runAction(CCSequence:create(arr))
|
||||
target:runAction(cc.Sequence:create(shaky, delay ,reuse, shuffle, tolua.cast(delay:clone(), "Action"), turnoff, turnon))
|
||||
return ret
|
||||
end
|
||||
|
||||
|
@ -122,18 +100,15 @@ local function Effect3()
|
|||
local target1 = bg:getChildByTag(kTagSprite1)
|
||||
local target2 = bg:getChildByTag(kTagSprite2)
|
||||
|
||||
local waves = CCWaves:create(5, CCSize(15,10), 5, 20, true, false)
|
||||
local shaky = CCShaky3D:create(5, CCSize(15,10), 4, false)
|
||||
local waves = cc.Waves:create(5, cc.size(15,10), 5, 20, true, false)
|
||||
local shaky = cc.Shaky3D:create(5, cc.size(15,10), 4, false)
|
||||
|
||||
target1:runAction( CCRepeatForever:create( waves ) )
|
||||
target2:runAction( CCRepeatForever:create( shaky ) )
|
||||
target1:runAction( cc.RepeatForever:create( waves ) )
|
||||
target2:runAction( cc.RepeatForever:create( shaky ) )
|
||||
|
||||
-- moving background. Testing issue #244
|
||||
local move = CCMoveBy:create(3, CCPoint(200,0) )
|
||||
local arr = CCArray:create()
|
||||
arr:addObject(move)
|
||||
arr:addObject(move:reverse())
|
||||
bg:runAction(CCRepeatForever:create( CCSequence:create(arr)))
|
||||
local move = cc.MoveBy:create(3, cc.p(200,0) )
|
||||
bg:runAction(cc.RepeatForever:create( cc.Sequence:create(move, move:reverse())))
|
||||
return ret
|
||||
end
|
||||
|
||||
|
@ -143,20 +118,20 @@ end
|
|||
--
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- class Lens3DTarget : public CCNode
|
||||
-- class Lens3DTarget : public cc.Node
|
||||
|
||||
-- public:
|
||||
-- virtual void setPosition(const CCPoint& var)
|
||||
-- virtual void setPosition(const cc.p& var)
|
||||
|
||||
-- m_pLens3D:setPosition(var)
|
||||
-- end
|
||||
|
||||
-- virtual const CCPoint& getPosition()
|
||||
-- virtual const cc.p& getPosition()
|
||||
|
||||
-- return m_pLens3D:getPosition()
|
||||
-- end
|
||||
|
||||
-- static Lens3DTarget* create(CCLens3D* pAction)
|
||||
-- static Lens3DTarget* create(cc.Lens3D* pAction)
|
||||
|
||||
-- Lens3DTarget* pRet = new Lens3DTarget()
|
||||
-- pRet:m_pLens3D = pAction
|
||||
|
@ -169,25 +144,22 @@ end
|
|||
-- : m_pLens3D(NULL)
|
||||
-- {}
|
||||
|
||||
-- CCLens3D* m_pLens3D
|
||||
-- cc.Lens3D* m_pLens3D
|
||||
-- end
|
||||
|
||||
local function Effect4()
|
||||
local ret = createTestLayer("Jumpy Lens3D")
|
||||
local lens = CCLens3D:create(10, CCSize(32,24), CCPoint(100,180), 150)
|
||||
local move = CCJumpBy:create(5, CCPoint(380,0), 100, 4)
|
||||
local lens = cc.Lens3D:create(10, cc.size(32,24), cc.p(100,180), 150)
|
||||
local move = cc.JumpBy:create(5, cc.p(380,0), 100, 4)
|
||||
local move_back = move:reverse()
|
||||
local arr = CCArray:create()
|
||||
arr:addObject(move)
|
||||
arr:addObject(move_back)
|
||||
local seq = CCSequence:create( arr)
|
||||
local seq = cc.Sequence:create( move, move_back)
|
||||
|
||||
-- /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'CCLens3D' as its target.
|
||||
-- While in cocos2d-x, the target of action only supports CCNode or its subclass,
|
||||
-- so we make an encapsulation for CCLens3D to achieve that.
|
||||
-- /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'cc.Lens3D' as its target.
|
||||
-- While in cocos2d-x, the target of action only supports cc.Node or its subclass,
|
||||
-- so we make an encapsulation for cc.Lens3D to achieve that.
|
||||
-- */
|
||||
|
||||
local director = CCDirector:getInstance()
|
||||
local director = cc.Director:getInstance()
|
||||
-- local pTarget = Lens3DTarget:create(lens)
|
||||
-- -- Please make sure the target been added to its parent.
|
||||
-- ret:addChild(pTarget)
|
||||
|
@ -205,18 +177,14 @@ end
|
|||
local function Effect5()
|
||||
local ret = createTestLayer("Test Stop-Copy-Restar")
|
||||
|
||||
local effect = CCLiquid:create(2, CCSize(32,24), 1, 20)
|
||||
local arr = CCArray:create()
|
||||
arr:addObject(effect)
|
||||
arr:addObject(CCDelayTime:create(2))
|
||||
arr:addObject(CCStopGrid:create())
|
||||
local effect = cc.Liquid:create(2, cc.size(32,24), 1, 20)
|
||||
|
||||
local stopEffect = CCSequence:create(arr)
|
||||
local stopEffect = cc.Sequence:create(effect, cc.DelayTime:create(2), cc.StopGrid:create())
|
||||
local bg = ret:getChildByTag(kTagBackground)
|
||||
bg:runAction(stopEffect)
|
||||
local function onNodeEvent(event)
|
||||
if event == "exit" then
|
||||
CCDirector:getInstance():setProjection(kCCDirectorProjection3D)
|
||||
cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION_3D)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -233,35 +201,33 @@ end
|
|||
local function Issue631()
|
||||
local ret = createTestLayer("Testing Opacity",
|
||||
"Effect image should be 100% opaque. Testing issue #631")
|
||||
local arr = CCArray:create()
|
||||
arr:addObject(CCDelayTime:create(2.0))
|
||||
arr:addObject(CCShaky3D:create(5.0, CCSize(5, 5), 16, false))
|
||||
local effect = CCSequence:create(arr)
|
||||
|
||||
local effect = cc.Sequence:create(cc.DelayTime:create(2.0),cc.Shaky3D:create(5.0, cc.size(5, 5), 16, false))
|
||||
|
||||
-- cleanup
|
||||
local bg = ret:getChildByTag(kTagBackground)
|
||||
ret:removeChild(bg, true)
|
||||
|
||||
-- background
|
||||
local layer = CCLayerColor:create( Color4B(255,0,0,255) )
|
||||
local layer = cc.LayerColor:create( cc.c4b(255,0,0,255) )
|
||||
ret:addChild(layer, -10)
|
||||
local sprite = CCSprite:create("Images/grossini.png")
|
||||
sprite:setPosition( CCPoint(50,80) )
|
||||
local sprite = cc.Sprite:create("Images/grossini.png")
|
||||
sprite:setPosition( cc.p(50,80) )
|
||||
layer:addChild(sprite, 10)
|
||||
|
||||
-- foreground
|
||||
local layer2 = CCLayerColor:create(Color4B( 0, 255,0,255 ) )
|
||||
local fog = CCSprite:create("Images/Fog.png")
|
||||
local layer2 = cc.LayerColor:create(cc.c4b( 0, 255,0,255 ) )
|
||||
local fog = cc.Sprite:create("Images/Fog.png")
|
||||
|
||||
local bf = BlendFunc()
|
||||
bf.src = GL_SRC_ALPHA
|
||||
bf.dst = GL_ONE_MINUS_SRC_ALPHA
|
||||
--local bf = BlendFunc()
|
||||
--bf.src = GL_SRC_ALPHA
|
||||
--bf.dst = GL_ONE_MINUS_SRC_ALPHA
|
||||
|
||||
fog:setBlendFunc(bf)
|
||||
fog:setBlendFunc(gl.SRC_ALPHA , gl.ONE_MINUS_SRC_ALPHA )
|
||||
layer2:addChild(fog, 1)
|
||||
ret:addChild(layer2, 1)
|
||||
|
||||
layer2:runAction( CCRepeatForever:create(effect) )
|
||||
layer2:runAction( cc.RepeatForever:create(effect) )
|
||||
return ret
|
||||
end
|
||||
|
||||
|
@ -269,7 +235,7 @@ function EffectAdvancedTestMain()
|
|||
cclog("EffectAdvancedTestMain")
|
||||
Helper.index = 1
|
||||
|
||||
local scene = CCScene:create()
|
||||
local scene = cc.Scene:create()
|
||||
Helper.createFunctionTable = {
|
||||
Effect3,
|
||||
Effect2,
|
||||
|
|
|
@ -2,7 +2,7 @@ require "luaScript/EffectsTest/EffectsName"
|
|||
|
||||
|
||||
local ActionIdx = -1
|
||||
local size = CCDirector:getInstance():getWinSize()
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
local kTagTextLayer = 1
|
||||
local kTagBackground = 1
|
||||
local kTagLabel = 2
|
||||
|
@ -26,7 +26,7 @@ local function checkAnim(dt)
|
|||
end
|
||||
|
||||
local function onEnterOrExit(tag)
|
||||
local scheduler = CCDirector:getInstance():getScheduler()
|
||||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
if tag == "enter" then
|
||||
entry = scheduler:scheduleScriptFunc(checkAnim, 0, false)
|
||||
elseif tag == "exit" then
|
||||
|
@ -55,256 +55,224 @@ local function nextAction()
|
|||
end
|
||||
|
||||
local function backCallback(sender)
|
||||
local scene = CCScene:create()
|
||||
local scene = cc.Scene:create()
|
||||
|
||||
scene:addChild(backAction())
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
|
||||
CCDirector:getInstance():replaceScene(scene)
|
||||
cc.Director:getInstance():replaceScene(scene)
|
||||
end
|
||||
|
||||
local function restartCallback(sender)
|
||||
local scene = CCScene:create()
|
||||
local scene = cc.Scene:create()
|
||||
|
||||
scene:addChild(restartAction())
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
|
||||
CCDirector:getInstance():replaceScene(scene)
|
||||
cc.Director:getInstance():replaceScene(scene)
|
||||
end
|
||||
|
||||
local function nextCallback(sender)
|
||||
local scene = CCScene:create()
|
||||
local scene = cc.Scene:create()
|
||||
|
||||
scene:addChild(nextAction())
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
|
||||
CCDirector:getInstance():replaceScene(scene)
|
||||
cc.Director:getInstance():replaceScene(scene)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- Shaky3DDemo
|
||||
--------------------------------------
|
||||
local function Shaky3DDemo(t)
|
||||
return CCShaky3D:create(t, CCSize(15,10), 5, false);
|
||||
return cc.Shaky3D:create(t, cc.size(15,10), 5, false);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- Waves3DDemo
|
||||
--------------------------------------
|
||||
local function Waves3DDemo(t)
|
||||
return CCWaves3D:create(t, CCSize(15,10), 5, 40);
|
||||
return cc.Waves3D:create(t, cc.size(15,10), 5, 40);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- FlipX3DDemo
|
||||
--------------------------------------
|
||||
local function FlipX3DDemo(t)
|
||||
local flipx = CCFlipX3D:create(t)
|
||||
local flipx = cc.FlipX3D:create(t)
|
||||
local flipx_back = flipx:reverse()
|
||||
local delay = CCDelayTime:create(2)
|
||||
local delay = cc.DelayTime:create(2)
|
||||
|
||||
local array = CCArray:create()
|
||||
array:addObject(flipx)
|
||||
array:addObject(flipx_back)
|
||||
array:addObject(delay)
|
||||
return CCSequence:create(array)
|
||||
return cc.Sequence:create(flipx, flipx_back, delay)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- FlipY3DDemo
|
||||
--------------------------------------
|
||||
local function FlipY3DDemo(t)
|
||||
local flipy = CCFlipY3D:create(t)
|
||||
local flipy = cc.FlipY3D:create(t)
|
||||
local flipy_back = flipy:reverse()
|
||||
local delay = CCDelayTime:create(2)
|
||||
local delay = cc.DelayTime:create(2)
|
||||
|
||||
local array = CCArray:create()
|
||||
array:addObject(flipy)
|
||||
array:addObject(flipy_back)
|
||||
array:addObject(delay)
|
||||
return CCSequence:create(array)
|
||||
return cc.Sequence:create(flipy, flipy_back, delay)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- Lens3DDemo
|
||||
--------------------------------------
|
||||
local function Lens3DDemo(t)
|
||||
return CCLens3D:create(t, CCSize(15,10), CCPoint(size.width/2,size.height/2), 240);
|
||||
return cc.Lens3D:create(t, cc.size(15,10), cc.p(size.width/2,size.height/2), 240);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- Ripple3DDemo
|
||||
--------------------------------------
|
||||
local function Ripple3DDemo(t)
|
||||
return CCRipple3D:create(t, CCSize(32,24), CCPoint(size.width/2,size.height/2), 240, 4, 160);
|
||||
return cc.Ripple3D:create(t, cc.size(32,24), cc.p(size.width/2,size.height/2), 240, 4, 160);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- LiquidDemo
|
||||
--------------------------------------
|
||||
local function LiquidDemo(t)
|
||||
return CCLiquid:create(t, CCSize(16,12), 4, 20);
|
||||
return cc.Liquid:create(t, cc.size(16,12), 4, 20);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- WavesDemo
|
||||
--------------------------------------
|
||||
local function WavesDemo(t)
|
||||
return CCWaves:create(t, CCSize(16,12), 4, 20, true, true);
|
||||
return cc.Waves:create(t, cc.size(16,12), 4, 20, true, true);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- TwirlDemo
|
||||
--------------------------------------
|
||||
local function TwirlDemo(t)
|
||||
return CCTwirl:create(t, CCSize(12,8), CCPoint(size.width/2, size.height/2), 1, 2.5);
|
||||
return cc.Twirl:create(t, cc.size(12,8), cc.p(size.width/2, size.height/2), 1, 2.5);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- ShakyTiles3DDemo
|
||||
--------------------------------------
|
||||
local function ShakyTiles3DDemo(t)
|
||||
return CCShakyTiles3D:create(t, CCSize(16,12), 5, false);
|
||||
return cc.ShakyTiles3D:create(t, cc.size(16,12), 5, false);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- ShatteredTiles3DDemo
|
||||
--------------------------------------
|
||||
local function ShatteredTiles3DDemo(t)
|
||||
return CCShatteredTiles3D:create(t, CCSize(16,12), 5, false);
|
||||
return cc.ShatteredTiles3D:create(t, cc.size(16,12), 5, false);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- ShuffleTilesDemo
|
||||
--------------------------------------
|
||||
local function ShuffleTilesDemo(t)
|
||||
local shuffle = CCShuffleTiles:create(t, CCSize(16,12), 25);
|
||||
local shuffle = cc.ShuffleTiles:create(t, cc.size(16,12), 25);
|
||||
local shuffle_back = shuffle:reverse()
|
||||
local delay = CCDelayTime:create(2)
|
||||
local delay = cc.DelayTime:create(2)
|
||||
|
||||
local array = CCArray:create()
|
||||
array:addObject(shuffle)
|
||||
array:addObject(shuffle_back)
|
||||
array:addObject(delay)
|
||||
return CCSequence:create(array)
|
||||
return cc.Sequence:create(shuffle, shuffle_back, delay)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- FadeOutTRTilesDemo
|
||||
--------------------------------------
|
||||
local function FadeOutTRTilesDemo(t)
|
||||
local fadeout = CCFadeOutTRTiles:create(t, CCSize(16,12));
|
||||
local fadeout = cc.FadeOutTRTiles:create(t, cc.size(16,12));
|
||||
local back = fadeout:reverse()
|
||||
local delay = CCDelayTime:create(0.5)
|
||||
local delay = cc.DelayTime:create(0.5)
|
||||
|
||||
local array = CCArray:create()
|
||||
array:addObject(fadeout)
|
||||
array:addObject(back)
|
||||
array:addObject(delay)
|
||||
return CCSequence:create(array)
|
||||
return cc.Sequence:create(fadeout, back, delay)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- FadeOutBLTilesDemo
|
||||
--------------------------------------
|
||||
local function FadeOutBLTilesDemo(t)
|
||||
local fadeout = CCFadeOutBLTiles:create(t, CCSize(16,12));
|
||||
local fadeout = cc.FadeOutBLTiles:create(t, cc.size(16,12));
|
||||
local back = fadeout:reverse()
|
||||
local delay = CCDelayTime:create(0.5)
|
||||
local delay = cc.DelayTime:create(0.5)
|
||||
|
||||
local array = CCArray:create()
|
||||
array:addObject(fadeout)
|
||||
array:addObject(back)
|
||||
array:addObject(delay)
|
||||
return CCSequence:create(array)
|
||||
return cc.Sequence:create(fadeout, back, delay)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- FadeOutUpTilesDemo
|
||||
--------------------------------------
|
||||
local function FadeOutUpTilesDemo(t)
|
||||
local fadeout = CCFadeOutUpTiles:create(t, CCSize(16,12));
|
||||
local fadeout = cc.FadeOutUpTiles:create(t, cc.size(16,12));
|
||||
local back = fadeout:reverse()
|
||||
local delay = CCDelayTime:create(0.5)
|
||||
local delay = cc.DelayTime:create(0.5)
|
||||
|
||||
local array = CCArray:create()
|
||||
array:addObject(fadeout)
|
||||
array:addObject(back)
|
||||
array:addObject(delay)
|
||||
return CCSequence:create(array)
|
||||
return cc.Sequence:create(fadeout, back, delay)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- FadeOutDownTilesDemo
|
||||
--------------------------------------
|
||||
local function FadeOutDownTilesDemo(t)
|
||||
local fadeout = CCFadeOutDownTiles:create(t, CCSize(16,12));
|
||||
local fadeout = cc.FadeOutDownTiles:create(t, cc.size(16,12));
|
||||
local back = fadeout:reverse()
|
||||
local delay = CCDelayTime:create(0.5)
|
||||
local delay = cc.DelayTime:create(0.5)
|
||||
|
||||
local array = CCArray:create()
|
||||
array:addObject(fadeout)
|
||||
array:addObject(back)
|
||||
array:addObject(delay)
|
||||
return CCSequence:create(array)
|
||||
return cc.Sequence:create(fadeout, back, delay)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- TurnOffTilesDemo
|
||||
--------------------------------------
|
||||
local function TurnOffTilesDemo(t)
|
||||
local fadeout = CCTurnOffTiles:create(t, CCSize(48,32), 25);
|
||||
local fadeout = cc.TurnOffTiles:create(t, cc.size(48,32), 25);
|
||||
local back = fadeout:reverse()
|
||||
local delay = CCDelayTime:create(0.5)
|
||||
local delay = cc.DelayTime:create(0.5)
|
||||
|
||||
local array = CCArray:create()
|
||||
array:addObject(fadeout)
|
||||
array:addObject(back)
|
||||
array:addObject(delay)
|
||||
return CCSequence:create(array)
|
||||
return cc.Sequence:create(fadeout, back, delay)
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- WavesTiles3DDemo
|
||||
--------------------------------------
|
||||
local function WavesTiles3DDemo(t)
|
||||
return CCWavesTiles3D:create(t, CCSize(15,10), 4, 120);
|
||||
return cc.WavesTiles3D:create(t, cc.size(15,10), 4, 120);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- JumpTiles3DDemo
|
||||
--------------------------------------
|
||||
local function JumpTiles3DDemo(t)
|
||||
return CCJumpTiles3D:create(t, CCSize(15,10), 2, 30);
|
||||
return cc.JumpTiles3D:create(t, cc.size(15,10), 2, 30);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- SplitRowsDemo
|
||||
--------------------------------------
|
||||
local function SplitRowsDemo(t)
|
||||
return CCSplitRows:create(t, 9);
|
||||
return cc.SplitRows:create(t, 9);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- SplitColsDemo
|
||||
--------------------------------------
|
||||
local function SplitColsDemo(t)
|
||||
return CCSplitCols:create(t, 9);
|
||||
return cc.SplitCols:create(t, 9);
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- PageTurn3DDemo
|
||||
--------------------------------------
|
||||
local function PageTurn3DDemo(t)
|
||||
CCDirector:getInstance():setDepthTest(true)
|
||||
return CCPageTurn3D:create(t, CCSize(15,10));
|
||||
cc.Director:getInstance():setDepthTest(true)
|
||||
return cc.PageTurn3D:create(t, cc.size(15,10));
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
-- Effects Test
|
||||
--------------------------------------
|
||||
local function createEffect(idx, t)
|
||||
CCDirector:getInstance():setDepthTest(false)
|
||||
cc.Director:getInstance():setDepthTest(false)
|
||||
local action = nil
|
||||
|
||||
if idx == 0 then
|
||||
|
@ -357,54 +325,54 @@ local function createEffect(idx, t)
|
|||
end
|
||||
|
||||
function CreateEffectsTestLayer()
|
||||
testLayer = CCLayerColor:create(Color4B(32,128,32,255))
|
||||
testLayer = cc.LayerColor:create(cc.c4b(32,128,32,255))
|
||||
|
||||
local x, y = size.width, size.height
|
||||
|
||||
local node = CCNode:create()
|
||||
local node = cc.Node:create()
|
||||
local effect = createEffect(ActionIdx, 3)
|
||||
node:runAction(effect)
|
||||
testLayer:addChild(node, 0, kTagBackground)
|
||||
|
||||
local bg = CCSprite:create(s_back3)
|
||||
local bg = cc.Sprite:create(s_back3)
|
||||
node:addChild(bg, 0)
|
||||
bg:setPosition(CCPoint(size.width / 2, size.height / 2))
|
||||
bg:setPosition(cc.p(size.width / 2, size.height / 2))
|
||||
|
||||
local grossini = CCSprite:create(s_pPathSister2)
|
||||
local grossini = cc.Sprite:create(s_pPathSister2)
|
||||
node:addChild(grossini, 1)
|
||||
grossini:setPosition( CCPoint(x / 3, y / 2) )
|
||||
local sc = CCScaleBy:create(2, 5)
|
||||
grossini:setPosition( cc.p(x / 3, y / 2) )
|
||||
local sc = cc.ScaleBy:create(2, 5)
|
||||
local sc_back = sc:reverse()
|
||||
grossini:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc, sc_back)))
|
||||
grossini:runAction(cc.RepeatForever:create(cc.Sequence:create(sc, sc_back)))
|
||||
|
||||
local tamara = CCSprite:create(s_pPathSister1)
|
||||
local tamara = cc.Sprite:create(s_pPathSister1)
|
||||
node:addChild(tamara, 1)
|
||||
tamara:setPosition(CCPoint(2 * x / 3, y / 2))
|
||||
local sc2 = CCScaleBy:create(2, 5)
|
||||
tamara:setPosition(cc.p(2 * x / 3, y / 2))
|
||||
local sc2 = cc.ScaleBy:create(2, 5)
|
||||
local sc2_back = sc2:reverse()
|
||||
tamara:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc2, sc2_back)))
|
||||
tamara:runAction(cc.RepeatForever:create(cc.Sequence:create(sc2, sc2_back)))
|
||||
|
||||
titleLabel = CCLabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32)
|
||||
titleLabel = cc.LabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32)
|
||||
titleLabel:setPosition(x / 2, y - 80)
|
||||
testLayer:addChild(titleLabel)
|
||||
titleLabel:setTag(kTagLabel)
|
||||
|
||||
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||
local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||
local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||
item1:registerScriptTapHandler(backCallback)
|
||||
item2:registerScriptTapHandler(restartCallback)
|
||||
item3:registerScriptTapHandler(nextCallback)
|
||||
|
||||
local menu = CCMenu:create()
|
||||
local menu = cc.Menu:create()
|
||||
menu:addChild(item1)
|
||||
menu:addChild(item2)
|
||||
menu:addChild(item3)
|
||||
|
||||
menu:setPosition(CCPoint(0, 0))
|
||||
item1:setPosition(CCPoint(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))
|
||||
|
||||
testLayer:addChild(menu, 1)
|
||||
|
||||
|
@ -414,7 +382,7 @@ function CreateEffectsTestLayer()
|
|||
end
|
||||
|
||||
function EffectsTest()
|
||||
local scene = CCScene:create()
|
||||
local scene = cc.Scene:create()
|
||||
|
||||
ActionIdx = -1
|
||||
scene:addChild(nextAction())
|
||||
|
|
|
@ -23,7 +23,7 @@ end
|
|||
|
||||
function VisibleRect:getVisibleRect()
|
||||
self:lazyInit()
|
||||
return cc.Rect(self.s_visibleRect.x, self.s_visibleRect.y, self.s_visibleRect.width, self.s_visibleRect.height)
|
||||
return cc.rect(self.s_visibleRect.x, self.s_visibleRect.y, self.s_visibleRect.width, self.s_visibleRect.height)
|
||||
end
|
||||
|
||||
function VisibleRect:left()
|
||||
|
|
|
@ -6,20 +6,25 @@ require "Opengl"
|
|||
require "OpenglConstants"
|
||||
require "luaScript/helper"
|
||||
require "luaScript/testResource"
|
||||
require "luaScript/VisibleRect"
|
||||
|
||||
require "luaScript/ActionManagerTest/ActionManagerTest"
|
||||
require "luaScript/ActionsEaseTest/ActionsEaseTest"
|
||||
require "luaScript/ActionsProgressTest/ActionsProgressTest"
|
||||
require "luaScript/ActionsTest/ActionsTest"
|
||||
require "luaScript/BugsTest/BugsTest"
|
||||
require "luaScript/ClickAndMoveTest/ClickAndMoveTest"
|
||||
require "luaScript/CocosDenshionTest/CocosDenshionTest"
|
||||
require "luaScript/CurrentLanguageTest/CurrentLanguageTest"
|
||||
require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest"
|
||||
require "luaScript/EffectsTest/EffectsTest"
|
||||
require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest"
|
||||
|
||||
--[[
|
||||
require "luaScript/TransitionsTest/TransitionsTest"
|
||||
require "luaScript/EffectsTest/EffectsTest"
|
||||
require "luaScript/ClickAndMoveTest/ClickAndMoveTest"
|
||||
require "luaScript/RotateWorldTest/RotateWorldTest"
|
||||
require "luaScript/ParticleTest/ParticleTest"
|
||||
require "luaScript/MotionStreakTest/MotionStreakTest"
|
||||
require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest"
|
||||
require "luaScript/NodeTest/NodeTest"
|
||||
require "luaScript/TouchesTest/TouchesTest"
|
||||
require "luaScript/SpriteTest/SpriteTest"
|
||||
|
@ -36,11 +41,7 @@ require "luaScript/Texture2dTest/Texture2dTest"
|
|||
require "luaScript/RenderTextureTest/RenderTextureTest"
|
||||
require "luaScript/ZwoptexTest/ZwoptexTest"
|
||||
require "luaScript/FontTest/FontTest"
|
||||
require "luaScript/CocosDenshionTest/CocosDenshionTest"
|
||||
require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest"
|
||||
require "luaScript/UserDefaultTest/UserDefaultTest"
|
||||
require "luaScript/CurrentLanguageTest/CurrentLanguageTest"
|
||||
require "luaScript/BugsTest/BugsTest"
|
||||
require "luaScript/ExtensionTest/ExtensionTest"
|
||||
require "luaScript/AccelerometerTest/AccelerometerTest"
|
||||
require "luaScript/KeypadTest/KeypadTest"
|
||||
|
|
|
@ -1 +1 @@
|
|||
b3460818609e566b063e1c9b7404650048c81121
|
||||
faeffa101e0d6ba77fa19f3bd83b12a267209994
|
|
@ -1 +1 @@
|
|||
aa5612e5aef2fe92c3fed272d4de8a072dc1682f
|
||||
fe22a58a97c6532a0d8b5c326cd683e108407b1e
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __cocos2dx_lua_cocos2dx_support_auto_h__
|
||||
#define __cocos2dx_lua_cocos2dx_support_auto_h__
|
||||
#ifndef __cocos2dx_h__
|
||||
#define __cocos2dx_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -1790,4 +1790,216 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
#endif // #ifndef __cocos2dx_lua_cocos2dx_support_auto_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __cocos2dx_h__
|
||||
|
|
|
@ -1 +1 @@
|
|||
63d07a801569560e761eb49303c77fdb54e6d57e
|
||||
1df451e47e5e21c6430adcd93e76253dac5dcb14
|
|
@ -1 +1 @@
|
|||
19d626318d010f941ff497bb509888c194056b85
|
||||
55f9aed3fc28a46be61e0ddaa629a9503b54a1ac
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __cocos2dx_extension_lua_cocos2dx_support_auto_h__
|
||||
#define __cocos2dx_extension_lua_cocos2dx_support_auto_h__
|
||||
#ifndef __cocos2dx_extension_h__
|
||||
#define __cocos2dx_extension_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -257,4 +257,12 @@ int register_all_cocos2dx_extension(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
#endif // #ifndef __cocos2dx_extension_lua_cocos2dx_support_auto_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __cocos2dx_extension_h__
|
||||
|
|
|
@ -431,7 +431,7 @@ setTitleLabelForState : function () {},
|
|||
* @method ccTouchBegan
|
||||
* @return A value converted from C/C++ "bool"
|
||||
* @param {cocos2d::Touch*}
|
||||
* @param {Event*}
|
||||
* @param {cocos2d::Event*}
|
||||
*/
|
||||
ccTouchBegan : function () {},
|
||||
|
||||
|
@ -444,7 +444,7 @@ setAdjustBackgroundImage : function () {},
|
|||
/**
|
||||
* @method ccTouchEnded
|
||||
* @param {cocos2d::Touch*}
|
||||
* @param {Event*}
|
||||
* @param {cocos2d::Event*}
|
||||
*/
|
||||
ccTouchEnded : function () {},
|
||||
|
||||
|
@ -552,7 +552,7 @@ setTitleLabel : function () {},
|
|||
/**
|
||||
* @method ccTouchMoved
|
||||
* @param {cocos2d::Touch*}
|
||||
* @param {Event*}
|
||||
* @param {cocos2d::Event*}
|
||||
*/
|
||||
ccTouchMoved : function () {},
|
||||
|
||||
|
@ -720,7 +720,7 @@ getTitleLabel : function () {},
|
|||
/**
|
||||
* @method ccTouchCancelled
|
||||
* @param {cocos2d::Touch*}
|
||||
* @param {Event*}
|
||||
* @param {cocos2d::Event*}
|
||||
*/
|
||||
ccTouchCancelled : function () {},
|
||||
|
||||
|
@ -1168,12 +1168,6 @@ getRootNode : function () {},
|
|||
*/
|
||||
addDocumentOutletNode : function () {},
|
||||
|
||||
/**
|
||||
* @method setDelegate
|
||||
* @param {cocos2d::extension::CCBAnimationManagerDelegate*}
|
||||
*/
|
||||
setDelegate : function () {},
|
||||
|
||||
/**
|
||||
* @method addDocumentCallbackNode
|
||||
* @param {cocos2d::Node*}
|
||||
|
@ -1187,12 +1181,6 @@ addDocumentCallbackNode : function () {},
|
|||
*/
|
||||
setCallFunc : function () {},
|
||||
|
||||
/**
|
||||
* @method getDelegate
|
||||
* @return A value converted from C/C++ "cocos2d::extension::CCBAnimationManagerDelegate*"
|
||||
*/
|
||||
getDelegate : function () {},
|
||||
|
||||
/**
|
||||
* @method runAnimationsForSequenceNamed
|
||||
* @param {const char*}
|
||||
|
|
|
@ -87,7 +87,7 @@ static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_initWithTarget'.\n",&tolua_err);
|
||||
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_MenuItemImage_create'.\n",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
|
@ -123,6 +123,103 @@ static int tolua_cocos2d_MenuItemLabel_create(lua_State* tolua_S)
|
|||
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_MenuItemFont_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,"MenuItemFont",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
if(1 == argc)
|
||||
{
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
const char* value = ((const char*) tolua_tostring(tolua_S,2,0));
|
||||
MenuItemFont* tolua_ret = (MenuItemFont*) MenuItemFont::create(value);
|
||||
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,"MenuItemFont");
|
||||
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_MenuItemSprite_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,"MenuItemSprite",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
||||
if(argc >= 2 && argc <= 3)
|
||||
{
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) ||
|
||||
!tolua_isusertype(tolua_S,3,"Node",0,&tolua_err) )
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
|
||||
if (3 == argc && !tolua_isusertype(tolua_S,4,"Node",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
|
||||
Node* normalSprite = ((Node*) tolua_tousertype(tolua_S,2,0));
|
||||
Node* selectedSprite = ((Node*) tolua_tousertype(tolua_S,3,0));
|
||||
Node* disabledSprite = NULL;
|
||||
if (3 == argc)
|
||||
{
|
||||
disabledSprite = (Node*) tolua_tousertype(tolua_S,4,0);
|
||||
}
|
||||
MenuItemSprite* tolua_ret = (MenuItemSprite*) MenuItemSprite::create(normalSprite,selectedSprite,disabledSprite);
|
||||
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,"MenuItemSprite");
|
||||
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);
|
||||
|
@ -154,7 +251,7 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S)
|
|||
uint32_t i = 1;
|
||||
while (i <= argc)
|
||||
{
|
||||
if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err))
|
||||
if (!tolua_isusertype(tolua_S, 1 + i, "MenuItem", 0, &tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
return 0;
|
||||
|
@ -180,7 +277,7 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S)
|
|||
cocos2d::Menu* tolua_ret = cocos2d::Menu::create();
|
||||
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,"MenuItemImage");
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -189,7 +286,7 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_initWithTarget'.\n",&tolua_err);
|
||||
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Menu_create'.\n",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -208,7 +305,7 @@ static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S)
|
|||
cobj = static_cast<cocos2d::MenuItemImage*>(tolua_tousertype(tolua_S,1,0));
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == cobj) {
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler00'\n", NULL);
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -252,7 +349,7 @@ static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S)
|
|||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == cobj) {
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler00'\n", NULL);
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -397,6 +494,91 @@ tolua_lerror:
|
|||
#endif
|
||||
}
|
||||
|
||||
int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
Layer* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<cocos2d::Layer*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptAccelerateHandler'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
||||
if (1 == argc)
|
||||
{
|
||||
#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*)self, handler, ScriptHandlerMgr::kAccelerometerHandler);
|
||||
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 'registerScriptAccelerateHandler'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
Layer* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<cocos2d::Layer*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptAccelerateHandler'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
||||
if (0 == argc)
|
||||
{
|
||||
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::kAccelerometerHandler);
|
||||
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 'unregisterScriptAccelerateHandler'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S)
|
||||
{
|
||||
|
@ -1036,10 +1218,148 @@ tolua_lerror:
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
//void lua_extend_cocos2dx_MenuItem
|
||||
//{
|
||||
//
|
||||
//}
|
||||
|
||||
static int tolua_cocos2d_DrawNode_drawPolygon(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
DrawNode* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S,1,"DrawNode",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<cocos2d::DrawNode*>(tolua_tousertype(tolua_S,1,0));
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_DrawNode_drawPolygon'\n", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
if (5 == argc)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if(
|
||||
!tolua_istable(tolua_S, 2, 0, &tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
|
||||
!tolua_istable(tolua_S, 4, 0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 5, 0, &tolua_err) ||
|
||||
!tolua_istable(tolua_S,6, 0,&tolua_err) )
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
size_t size = lua_tonumber(tolua_S, 3);
|
||||
if ( size > 0 )
|
||||
{
|
||||
Point* points = new Point[size];
|
||||
if (NULL == points)
|
||||
return 0;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
lua_pushnumber(tolua_S,i + 1);
|
||||
lua_gettable(tolua_S,2);
|
||||
if (!tolua_istable(tolua_S,-1, 0, &tolua_err))
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(points);
|
||||
goto tolua_lerror;
|
||||
}
|
||||
|
||||
if(!luaval_to_point(tolua_S, lua_gettop(tolua_S), &points[i]))
|
||||
{
|
||||
lua_pop(tolua_S, 1);
|
||||
CC_SAFE_DELETE_ARRAY(points);
|
||||
return 0;
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
||||
Color4F fillColor;
|
||||
if (!luaval_to_color4f(tolua_S, 4, &fillColor))
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(points);
|
||||
return 0;
|
||||
}
|
||||
|
||||
float borderWidth = (float)tolua_tonumber(tolua_S, 5, 0);
|
||||
|
||||
Color4F borderColor;
|
||||
if (!luaval_to_color4f(tolua_S, 6, &borderColor))
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(points);
|
||||
return 0;
|
||||
}
|
||||
|
||||
self->drawPolygon(points, size, fillColor, borderWidth, borderColor);
|
||||
CC_SAFE_DELETE_ARRAY(points);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 5);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'drawPolygon'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// setBlendFunc
|
||||
template<class T>
|
||||
static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
T* self = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
// if (!tolua_isusertype(tolua_S,1,typeid(T).name(),0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<T*>(tolua_tousertype(tolua_S,1,0));
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
if (2 == argc)
|
||||
{
|
||||
GLenum src, dst;
|
||||
if (!luaval_to_int32(tolua_S, 2, (int32_t*)&src))
|
||||
return 0;
|
||||
|
||||
if (!luaval_to_int32(tolua_S, 3, (int32_t*)&dst))
|
||||
return 0;
|
||||
|
||||
BlendFunc blendFunc = {src, dst};
|
||||
self->setBlendFunc(blendFunc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
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 'setBlendFunc'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int tolua_cocos2dx_Sprite_setBlendFunc(lua_State* tolua_S)
|
||||
{
|
||||
return tolua_cocos2dx_setBlendFunc<Sprite>(tolua_S);
|
||||
}
|
||||
|
||||
|
||||
int register_all_cocos2dx_manual(lua_State* tolua_S)
|
||||
{
|
||||
|
@ -1076,6 +1396,24 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
|
|||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
|
||||
lua_pushstring(tolua_S, "MenuItemFont");
|
||||
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
lua_pushstring(tolua_S,"create");
|
||||
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemFont_create);
|
||||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
|
||||
lua_pushstring(tolua_S, "MenuItemSprite");
|
||||
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
lua_pushstring(tolua_S,"create");
|
||||
lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemSprite_create);
|
||||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
|
||||
lua_pushstring(tolua_S, "Menu");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S, -1))
|
||||
|
@ -1105,7 +1443,7 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
|
|||
lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_registerScriptTouchHandler);
|
||||
lua_rawset(tolua_S,-3);
|
||||
lua_pushstring(tolua_S, "unregisterScriptTouchHandler");
|
||||
lua_pushcfunction(tolua_S,tolua_Cocos2d_unregisterScriptTouchHandler00);
|
||||
lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_unregisterScriptTouchHandler);
|
||||
lua_rawset(tolua_S, -3);
|
||||
// lua_pushstring(lua_S, "registerScriptKeypadHandler");
|
||||
// lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptKeypadHandler00);
|
||||
|
@ -1113,12 +1451,12 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
|
|||
// lua_pushstring(lua_S, "unregisterScriptKeypadHandler");
|
||||
// lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptKeypadHandler00);
|
||||
// lua_rawset(lua_S, -3);
|
||||
// lua_pushstring(lua_S, "registerScriptAccelerateHandler");
|
||||
// lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptAccelerateHandler00);
|
||||
// lua_rawset(lua_S, -3);
|
||||
// lua_pushstring(lua_S, "unregisterScriptAccelerateHandler");
|
||||
// lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptAccelerateHandler00);
|
||||
// lua_rawset(lua_S, -3);
|
||||
lua_pushstring(tolua_S, "registerScriptAccelerateHandler");
|
||||
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptAccelerateHandler);
|
||||
lua_rawset(tolua_S, -3);
|
||||
lua_pushstring(tolua_S, "unregisterScriptAccelerateHandler");
|
||||
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptAccelerateHandler);
|
||||
lua_rawset(tolua_S, -3);
|
||||
}
|
||||
|
||||
lua_pushstring(tolua_S,"Scheduler");
|
||||
|
@ -1205,7 +1543,23 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
|
|||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
|
||||
lua_pushstring(tolua_S,"DrawNode");
|
||||
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
lua_pushstring(tolua_S,"drawPolygon");
|
||||
lua_pushcfunction(tolua_S,tolua_cocos2d_DrawNode_drawPolygon);
|
||||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
|
||||
lua_pushstring(tolua_S,"Sprite");
|
||||
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
lua_pushstring(tolua_S,"setBlendFunc");
|
||||
lua_pushcfunction(tolua_S,tolua_cocos2dx_Sprite_setBlendFunc);
|
||||
lua_rawset(tolua_S,-3);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
--Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects.
|
||||
local M = {}
|
||||
local audioEngineInstance = SimpleAudioEngine:getInstance()
|
||||
local audioEngineInstance = cc.SimpleAudioEngine:getInstance()
|
||||
|
||||
function M.stopAllEffects()
|
||||
audioEngineInstance:stopAllEffects()
|
||||
end
|
||||
|
||||
function M.getMusicVolume()
|
||||
return audioEngineInstance:getBackgroundMusicVolume()
|
||||
return audioEngineInstance:getMusicVolume()
|
||||
end
|
||||
|
||||
function M.isMusicPlaying()
|
||||
return audioEngineInstance:isBackgroundMusicPlaying()
|
||||
return audioEngineInstance:isMusicPlaying()
|
||||
end
|
||||
|
||||
function M.getEffectsVolume()
|
||||
|
@ -19,7 +19,7 @@ function M.getEffectsVolume()
|
|||
end
|
||||
|
||||
function M.setMusicVolume(volume)
|
||||
audioEngineInstance:setBackgroundMusicVolume(volume)
|
||||
audioEngineInstance:setMusicVolume(volume)
|
||||
end
|
||||
|
||||
function M.stopEffect(handle)
|
||||
|
@ -31,7 +31,7 @@ function M.stopMusic(isReleaseData)
|
|||
if nil ~= isReleaseData then
|
||||
releaseDataValue = isReleaseData
|
||||
end
|
||||
audioEngineInstance:stopBackgroundMusic(releaseDataValue)
|
||||
audioEngineInstance:stopMusic(releaseDataValue)
|
||||
end
|
||||
|
||||
function M.playMusic(filename, isLoop)
|
||||
|
@ -39,7 +39,7 @@ function M.playMusic(filename, isLoop)
|
|||
if nil ~= isLoop then
|
||||
loopValue = isLoop
|
||||
end
|
||||
audioEngineInstance:playBackgroundMusic(filename, loopValue)
|
||||
audioEngineInstance:playMusic(filename, loopValue)
|
||||
end
|
||||
|
||||
function M.pauseAllEffects()
|
||||
|
@ -47,11 +47,11 @@ function M.pauseAllEffects()
|
|||
end
|
||||
|
||||
function M.preloadMusic(filename)
|
||||
audioEngineInstance:preloadBackgroundMusic(filename)
|
||||
audioEngineInstance:preloadMusic(filename)
|
||||
end
|
||||
|
||||
function M.resumeMusic()
|
||||
audioEngineInstance:resumeBackgroundMusic()
|
||||
audioEngineInstance:resumeMusic()
|
||||
end
|
||||
|
||||
function M.playEffect(filename, isLoop)
|
||||
|
@ -63,11 +63,11 @@ function M.playEffect(filename, isLoop)
|
|||
end
|
||||
|
||||
function M.rewindMusic()
|
||||
audioEngineInstance:rewindBackgroundMusic()
|
||||
audioEngineInstance:rewindMusic()
|
||||
end
|
||||
|
||||
function M.willPlayMusic()
|
||||
return audioEngineInstance:willPlayBackgroundMusic()
|
||||
return audioEngineInstance:willPlayMusic()
|
||||
end
|
||||
|
||||
function M.unloadEffect(filename)
|
||||
|
@ -91,7 +91,7 @@ function M.resumeAllEffects(handle)
|
|||
end
|
||||
|
||||
function M.pauseMusic()
|
||||
audioEngineInstance:pauseBackgroundMusic()
|
||||
audioEngineInstance:pauseMusic()
|
||||
end
|
||||
|
||||
function M.resumeEffect(handle)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
cc = cc or {}
|
||||
|
||||
cc.DIRECTOR_PROJECTION_2D = 0
|
||||
cc.DIRECTOR_PROJECTION_3D = 1
|
||||
|
||||
--Point
|
||||
function cc.p(_x,_y)
|
||||
return { x = _x, y = _y }
|
||||
|
@ -25,4 +28,9 @@ function cc.c4b( _r,_g,_b,_a )
|
|||
return { r = _r, g = _g, b = _b, a = _a }
|
||||
end
|
||||
|
||||
--Color4F
|
||||
function cc.c4f( _r,_g,_b,_a )
|
||||
return { r = _r, g = _g, b = _b, a = _a }
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 93cd250dd0cc9b3c0c20df12b7e76330895c9db3
|
||||
Subproject commit cb7f610eae8f638d1c2929c3e2fdecd29e506dad
|
|
@ -35,7 +35,7 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.*
|
|||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = Node::[getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
|
||||
skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
|
||||
Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode],
|
||||
SpriteBatchNode::[getBlendFunc setBlendFunc],
|
||||
MotionStreak::[getBlendFunc setBlendFunc draw update],
|
||||
|
|
Loading…
Reference in New Issue