issue #2433:Modify TestLua samples and some .ini files

This commit is contained in:
samuele3hu 2013-08-20 13:44:37 +08:00
parent c8b75a1080
commit 7a9f1d6804
40 changed files with 4834 additions and 3113 deletions

View File

@ -3,37 +3,37 @@ local function AccelerometerMainLayer()
local function title()
return "AccelerometerTest"
end
local pLayer = CCLayer:create()
local pLayer = cc.Layer:create()
pLayer:setAccelerometerEnabled(true)
local pLabel = CCLabelTTF:create(title(), "Arial", 32)
local pLabel = cc.LabelTTF:create(title(), "Arial", 32)
pLayer:addChild(pLabel, 1)
pLabel:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 50) )
pLabel:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 50) )
local pBall = CCSprite:create("Images/ball.png")
pBall:setPosition(CCPoint(VisibleRect:center().x, VisibleRect:center().y))
local pBall = cc.Sprite:create("Images/ball.png")
pBall:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y))
pLayer:addChild(pBall)
pBall:retain()
local function didAccelerate(x,y,z,timestamp)
local pDir = CCDirector:getInstance()
local pDir = cc.Director:getInstance()
if nil == pBall then
return
end
local szBall = pBall:getContentSize()
local ptNowX,ptNowY = pBall:getPosition()
local ptNow = pBall:getPosition()
local ptNowX,ptNowY = ptNow.x, ptNow.y
local ptTmp = pDir:convertToUI(CCPoint(ptNowX,ptNowY))
local ptTmp = pDir:convertToUI(cc.p(ptNowX,ptNowY))
ptTmp.x = ptTmp.x + x * 9.81
ptTmp.y = ptTmp.y - y * 9.81
local ptNext = pDir:convertToGL(CCPoint(ptTmp.x,ptTmp.y))
local ptNext = pDir:convertToGL(cc.p(ptTmp.x,ptTmp.y))
local nMinX = math.floor(VisibleRect:left().x + szBall.width / 2.0)
local nMaxX = math.floor(VisibleRect:right().x - szBall.width / 2.0)
if ptNext.x < nMinX then
@ -50,7 +50,7 @@ local function AccelerometerMainLayer()
ptNext.y = nMaxY
end
pBall:setPosition(CCPoint(ptNext.x,ptNext.y))
pBall:setPosition(cc.p(ptNext.x,ptNext.y))
end
@ -63,7 +63,7 @@ end
function AccelerometerMain()
cclog("AccelerometerMain")
local scene = CCScene:create()
local scene = cc.Scene:create()
scene:addChild(AccelerometerMainLayer())
scene:addChild(CreateBackMenuItem())
return scene

View File

@ -49,12 +49,14 @@ local function setEnableRecursiveCascading(node, enable)
local children = node:getChildren()
if children == nil then
-- cclog("children is nil")
print("children is nil")
return
end
local i = 0
local len = table.getn(children)
for i = 0, len-1, 1 do
print("come in")
local child = tolua.cast(children[i + 1], "Node")
setEnableRecursiveCascading(child, enable)
end

View File

@ -21,38 +21,38 @@ local MID_BACKCALLBACK = 1009
local function MenuLayerMainMenu()
local m_disabledItem = nil
local ret = CCLayer:create()
local ret = cc.Layer:create()
ret:setTouchEnabled(true)
ret:setTouchPriority(kCCMenuHandlerPriority + 1)
ret:setTouchMode(kCCTouchesOneByOne)
ret:setTouchPriority(cc.MENU_HANDLER_PRIORITY + 1)
ret:setTouchMode(cc.TOUCHES_ONE_BY_ONE )
-- Font Item
local spriteNormal = CCSprite:create(s_MenuItem, CCRect(0,23*2,115,23))
local spriteSelected = CCSprite:create(s_MenuItem, CCRect(0,23*1,115,23))
local spriteDisabled = CCSprite:create(s_MenuItem, CCRect(0,23*0,115,23))
local spriteNormal = cc.Sprite:create(s_MenuItem, cc.rect(0,23*2,115,23))
local spriteSelected = cc.Sprite:create(s_MenuItem, cc.rect(0,23*1,115,23))
local spriteDisabled = cc.Sprite:create(s_MenuItem, cc.rect(0,23*0,115,23))
local item1 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled)
local item1 = cc.MenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled)
local function menuCallback(sender)
cclog("menuCallback...")
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(1)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(1)
end
item1:registerScriptTapHandler(menuCallback)
-- Image Item
local function menuCallback2(sender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(2)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(2)
end
local item2 = CCMenuItemImage:create(s_SendScore, s_PressSendScore)
local item2 = cc.MenuItemImage:create(s_SendScore, s_PressSendScore)
item2:registerScriptTapHandler(menuCallback2)
local schedulerEntry = nil
local scheduler = CCDirector:getInstance():getScheduler()
local scheduler = cc.Director:getInstance():getScheduler()
local function allowTouches(dt)
local pDirector = CCDirector:getInstance()
--pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority+1, ret)
local pDirector = cc.Director:getInstance()
--pDirector:getTouchDispatcher():setPriority(cc.MENU_HANDLER_PRIORITY +1, ret)
if nil ~= schedulerEntry then
scheduler:unscheduleScriptEntry(schedulerEntry)
schedulerEntry = nil
@ -63,57 +63,57 @@ local function MenuLayerMainMenu()
local function menuCallbackDisabled(sender)
-- hijack all touch events for 5 seconds
local pDirector = CCDirector:getInstance()
--pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority-1, ret)
local pDirector = cc.Director:getInstance()
--pDirector:getTouchDispatcher():setPriority(cc.MENU_HANDLER_PRIORITY -1, ret)
schedulerEntry = scheduler:scheduleScriptFunc(allowTouches, 5, false)
cclog("TOUCHES DISABLED FOR 5 SECONDS")
end
-- Label Item (LabelAtlas)
local labelAtlas = CCLabelAtlas:create("0123456789", "fonts/labelatlas.png", 16, 24, string.byte('.'))
local item3 = CCMenuItemLabel:create(labelAtlas)
local labelAtlas = cc.LabelAtlas:_create("0123456789", "fonts/labelatlas.png", 16, 24, string.byte('.'))
local item3 = cc.MenuItemLabel:create(labelAtlas)
item3:registerScriptTapHandler(menuCallbackDisabled)
item3:setDisabledColor( Color3B(32,32,64) )
item3:setColor( Color3B(200,200,255) )
item3:setDisabledColor( cc.c3b(32,32,64) )
item3:setColor( cc.c3b(200,200,255) )
local function menuCallbackEnable(sender)
m_disabledItem:setEnabled(not m_disabledItem:isEnabled() )
end
-- Font Item
local item4 = CCMenuItemFont:create("I toggle enable items")
local item4 = cc.MenuItemFont:create("I toggle enable items")
item4:registerScriptTapHandler(menuCallbackEnable)
item4:setFontSizeObj(20)
CCMenuItemFont:setFontName("Marker Felt")
cc.MenuItemFont:setFontName("Marker Felt")
local function menuCallbackConfig(sender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(3)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(3)
end
-- Label Item (CCLabelBMFont)
local label = CCLabelBMFont:create("configuration", "fonts/bitmapFontTest3.fnt")
local item5 = CCMenuItemLabel:create(label)
-- Label Item (cc.LabelBMFont)
local label = cc.LabelBMFont:create("configuration", "fonts/bitmapFontTest3.fnt")
local item5 = cc.MenuItemLabel:create(label)
item5:registerScriptTapHandler(menuCallbackConfig)
-- Testing issue #500
item5:setScale( 0.8 )
local function menuCallbackPriorityTest(pSender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(4)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(4)
end
-- Events
CCMenuItemFont:setFontName("Marker Felt")
local item6 = CCMenuItemFont:create("Priority Test")
cc.MenuItemFont:setFontName("Marker Felt")
local item6 = cc.MenuItemFont:create("Priority Test")
item6:registerScriptTapHandler(menuCallbackPriorityTest)
local function menuCallbackBugsTest(pSender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(5)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5)
end
-- Bugs Item
local item7 = CCMenuItemFont:create("Bugs")
local item7 = cc.MenuItemFont:create("Bugs")
item7:registerScriptTapHandler(menuCallbackBugsTest)
local function onQuit(sender)
@ -121,25 +121,22 @@ local function MenuLayerMainMenu()
end
-- Font Item
local item8 = CCMenuItemFont:create("Quit")
local item8 = cc.MenuItemFont:create("Quit")
item8:registerScriptTapHandler(onQuit)
local function menuMovingCallback(pSender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(6)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(6)
end
local item9 = CCMenuItemFont:create("Remove menu item when moving")
local item9 = cc.MenuItemFont:create("Remove menu item when moving")
item9:registerScriptTapHandler(menuMovingCallback)
local color_action = CCTintBy:create(0.5, 0, -255, -255)
local color_action = cc.TintBy:create(0.5, 0, -255, -255)
local color_back = color_action:reverse()
local arr = CCArray:create()
arr:addObject(color_action)
arr:addObject(color_back)
local seq = CCSequence:create(arr)
item8:runAction(CCRepeatForever:create(seq))
local seq = cc.Sequence:create(color_action, color_back)
item8:runAction(cc.RepeatForever:create(seq))
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(item1)
menu:addChild(item2)
@ -154,27 +151,27 @@ local function MenuLayerMainMenu()
menu:alignItemsVertically()
-- elastic effect
local s = CCDirector:getInstance():getWinSize()
local s = cc.Director:getInstance():getWinSize()
local i = 0
local child = nil
local pArray = menu:getChildren()
local len = pArray:count()
local len = table.getn(pArray)
local pObject = nil
for i = 0, len-1 do
pObject = pArray:objectAtIndex(i)
pObject = pArray[i + 1]
if pObject == nil then
break
end
child = tolua.cast(pObject, "CCNode")
local dstPointX, dstPointY = child:getPosition()
child = tolua.cast(pObject, "Node")
local dstPoint = child:getPosition()
local dstPointX, dstPointY = dstPoint.x,dstPoint.y
local offset = s.width/2 + 50
if i % 2 == 0 then
offset = 0-offset
end
child:setPosition( CCPoint( dstPointX + offset, dstPointY) )
child:runAction( CCEaseElasticOut:create(CCMoveBy:create(2, CCPoint(dstPointX - offset,0)), 0.35) )
child:setPosition( cc.p( dstPointX + offset, dstPointY) )
child:runAction( cc.EaseElasticOut:create(cc.MoveBy:create(2, cc.p(dstPointX - offset,0)), 0.35) )
end
m_disabledItem = item3
@ -183,7 +180,7 @@ local function MenuLayerMainMenu()
m_disabledItem:setEnabled( false )
ret:addChild(menu)
menu:setPosition(CCPoint(s.width/2, s.height/2))
menu:setPosition(cc.p(s.width/2, s.height/2))
-- local schedulerEntry = nil
local function onNodeEvent(event)
@ -208,25 +205,27 @@ end
--
--------------------------------------------------------------------
local function MenuLayer2()
local ret = CCLayer:create()
local ret = cc.Layer:create()
local m_centeredMenu = nil
local m_alignedH = false
local function alignMenusH()
local i = 0
for i=0, 1 do
local menu = tolua.cast(ret:getChildByTag(100+i), "CCMenu")
local menu = tolua.cast(ret:getChildByTag(100+i), "Menu")
menu:setPosition( m_centeredMenu )
if i==0 then
-- TIP: if no padding, padding = 5
menu:alignItemsHorizontally()
local x, y = menu:getPosition()
menu:setPosition( CCPoint.__add(CCPoint(x, y), CCPoint(0,30)) )
local menuPos = menu:getPosition()
local x, y = menuPos.x,menuPos.y
menu:setPosition( cc.pAdd(cc.p(x, y), cc.p(0,30)) )
else
-- TIP: but padding is configurable
menu:alignItemsHorizontallyWithPadding(40)
local x, y = menu:getPosition()
menu:setPosition( CCPoint.__sub(CCPoint(x, y), CCPoint(0,30)) )
local menuPos = menu:getPosition()
local x, y = menuPos.x,menuPos.y
menu:setPosition( cc.pSub(cc.p(x, y), cc.p(0,30)) )
end
end
end
@ -234,28 +233,30 @@ local function MenuLayer2()
local function alignMenusV()
local i = 0
for i=0, 1 do
local menu = tolua.cast(ret:getChildByTag(100+i), "CCMenu")
local menu = tolua.cast(ret:getChildByTag(100+i), "Menu")
menu:setPosition( m_centeredMenu )
if i==0 then
-- TIP: if no padding, padding = 5
menu:alignItemsVertically()
local x, y = menu:getPosition()
menu:setPosition( CCPoint.__add(CCPoint(x, y), CCPoint(100,0)) )
local menuPos = menu:getPosition()
local x, y = menuPos.x,menuPos.y
menu:setPosition( cc.pAdd(cc.p(x, y), cc.p(100,0)) )
else
-- TIP: but padding is configurable
menu:alignItemsVerticallyWithPadding(40)
local x, y = menu:getPosition()
menu:setPosition( CCPoint.__sub(CCPoint(x, y), CCPoint(100,0)) )
local menuPos = menu:getPosition()
local x, y = menuPos.x,menuPos.y
menu:setPosition( cc.pSub(cc.p(x, y), cc.p(100,0)) )
end
end
end
local function menuCallback(sender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0)
end
local function menuCallbackOpacity(tag, sender)
local menu = tolua.cast(sender:getParent(), "CCMenu")
local menu = tolua.cast(sender:getParent(), "Menu")
local opacity = menu:getOpacity()
if opacity == 128 then
menu:setOpacity(255)
@ -276,34 +277,34 @@ local function MenuLayer2()
local i = 0
for i=0, 1 do
local item1 = CCMenuItemImage:create(s_PlayNormal, s_PlaySelect)
local item1 = cc.MenuItemImage:create(s_PlayNormal, s_PlaySelect)
item1:registerScriptTapHandler(menuCallback)
local item2 = CCMenuItemImage:create(s_HighNormal, s_HighSelect)
local item2 = cc.MenuItemImage:create(s_HighNormal, s_HighSelect)
item2:registerScriptTapHandler(menuCallbackOpacity)
local item3 = CCMenuItemImage:create(s_AboutNormal, s_AboutSelect)
local item3 = cc.MenuItemImage:create(s_AboutNormal, s_AboutSelect)
item3:registerScriptTapHandler(menuCallbackAlign)
item1:setScaleX( 1.5 )
item2:setScaleX( 0.5 )
item3:setScaleX( 0.5 )
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
local s = CCDirector:getInstance():getWinSize()
menu:setPosition(CCPoint(s.width/2, s.height/2))
local s = cc.Director:getInstance():getWinSize()
menu:setPosition(cc.p(s.width/2, s.height/2))
menu:setTag( kTagMenu )
ret:addChild(menu, 0, 100+i)
local x, y = menu:getPosition()
m_centeredMenu = CCPoint(x, y)
local menuPos = menu:getPosition()
local x, y = menuPos.x,menuPos.y
m_centeredMenu = cc.p(x, y)
end
m_alignedH = true
@ -319,9 +320,9 @@ end
--------------------------------------------------------------------
local function MenuLayer3()
local m_disabledItem = nil
local ret = CCLayer:create()
local ret = cc.Layer:create()
local function menuCallback(sender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0)
end
local function menuCallback2(sender)
@ -334,58 +335,55 @@ local function MenuLayer3()
cclog("MenuItemSprite clicked")
end
CCMenuItemFont:setFontName("Marker Felt")
CCMenuItemFont:setFontSize(28)
cc.MenuItemFont:setFontName("Marker Felt")
cc.MenuItemFont:setFontSize(28)
local label = CCLabelBMFont:create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt")
local item1 = CCMenuItemLabel:create(label)
local label = cc.LabelBMFont:create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt")
local item1 = cc.MenuItemLabel:create(label)
item1:registerScriptTapHandler(menuCallback2)
local item2 = CCMenuItemFont:create("--- Go Back ---")
local item2 = cc.MenuItemFont:create("--- Go Back ---")
item2:registerScriptTapHandler(menuCallback)
local spriteNormal = CCSprite:create(s_MenuItem, CCRect(0,23*2,115,23))
local spriteSelected = CCSprite:create(s_MenuItem, CCRect(0,23*1,115,23))
local spriteDisabled = CCSprite:create(s_MenuItem, CCRect(0,23*0,115,23))
local spriteNormal = cc.Sprite:create(s_MenuItem, cc.rect(0,23*2,115,23))
local spriteSelected = cc.Sprite:create(s_MenuItem, cc.rect(0,23*1,115,23))
local spriteDisabled = cc.Sprite:create(s_MenuItem, cc.rect(0,23*0,115,23))
local item3 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled)
local item3 = cc.MenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled)
item3:registerScriptTapHandler(menuCallback3)
m_disabledItem = item3
item3:retain()
m_disabledItem:setEnabled( false )
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:setPosition( CCPoint(0,0) )
menu:setPosition( cc.p(0,0) )
local s = CCDirector:getInstance():getWinSize()
local s = cc.Director:getInstance():getWinSize()
item1:setPosition( CCPoint(s.width/2 - 150, s.height/2) )
item2:setPosition( CCPoint(s.width/2 - 200, s.height/2) )
item3:setPosition( CCPoint(s.width/2, s.height/2 - 100) )
item1:setPosition( cc.p(s.width/2 - 150, s.height/2) )
item2:setPosition( cc.p(s.width/2 - 200, s.height/2) )
item3:setPosition( cc.p(s.width/2, s.height/2 - 100) )
local jump = CCJumpBy:create(3, CCPoint(400,0), 50, 4)
local arr = CCArray:create()
arr:addObject(jump)
arr:addObject(jump:reverse())
item2:runAction( CCRepeatForever:create(CCSequence:create( arr)))
local jump = cc.JumpBy:create(3, cc.p(400,0), 50, 4)
item2:runAction( cc.RepeatForever:create(cc.Sequence:create( jump, jump:reverse())))
local spin1 = CCRotateBy:create(3, 360)
local spin2 = tolua.cast(spin1:clone(), "CCActionInterval")
local spin3 = tolua.cast(spin1:clone(), "CCActionInterval")
local spin1 = cc.RotateBy:create(3, 360)
local spin2 = tolua.cast(spin1:clone(), "ActionInterval")
local spin3 = tolua.cast(spin1:clone(), "ActionInterval")
item1:runAction( CCRepeatForever:create(spin1) )
item2:runAction( CCRepeatForever:create(spin2) )
item3:runAction( CCRepeatForever:create(spin3) )
item1:runAction( cc.RepeatForever:create(spin1) )
item2:runAction( cc.RepeatForever:create(spin2) )
item3:runAction( cc.RepeatForever:create(spin3) )
ret:addChild( menu )
menu:setPosition(CCPoint(0,0))
menu:setPosition(cc.p(0,0))
local function onNodeEvent(event)
if event == "exit" then
@ -407,70 +405,69 @@ end
--
--------------------------------------------------------------------
local function MenuLayer4()
local ret = CCLayer:create()
CCMenuItemFont:setFontName("American Typewriter")
CCMenuItemFont:setFontSize(18)
local title1 = CCMenuItemFont:create("Sound")
local ret = cc.Layer:create()
cc.MenuItemFont:setFontName("American Typewriter")
cc.MenuItemFont:setFontSize(18)
local title1 = cc.MenuItemFont:create("Sound")
title1:setEnabled(false)
CCMenuItemFont:setFontName( "Marker Felt" )
CCMenuItemFont:setFontSize(34)
local item1 = CCMenuItemToggle:create(CCMenuItemFont:create( "On" ))
cc.MenuItemFont:setFontName( "Marker Felt" )
cc.MenuItemFont:setFontSize(34)
local item1 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" ))
local function menuCallback(tag, sender)
cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "CCMenuItemToggle"):getSelectedIndex() )
cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "MenuItemToggle"):getSelectedIndex() )
end
local function backCallback(tag, sender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0)
end
item1:registerScriptTapHandler(menuCallback)
item1:addSubItem(CCMenuItemFont:create( "Off"))
item1:addSubItem(cc.MenuItemFont:create( "Off"))
CCMenuItemFont:setFontName( "American Typewriter" )
CCMenuItemFont:setFontSize(18)
local title2 = CCMenuItemFont:create( "Music" )
cc.MenuItemFont:setFontName( "American Typewriter" )
cc.MenuItemFont:setFontSize(18)
local title2 = cc.MenuItemFont:create( "Music" )
title2:setEnabled(false)
CCMenuItemFont:setFontName( "Marker Felt" )
CCMenuItemFont:setFontSize(34)
local item2 = CCMenuItemToggle:create(CCMenuItemFont:create( "On" ))
cc.MenuItemFont:setFontName( "Marker Felt" )
cc.MenuItemFont:setFontSize(34)
local item2 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" ))
item2:registerScriptTapHandler(menuCallback)
item2:addSubItem(CCMenuItemFont:create( "Off"))
item2:addSubItem(cc.MenuItemFont:create( "Off"))
CCMenuItemFont:setFontName( "American Typewriter" )
CCMenuItemFont:setFontSize(18)
local title3 = CCMenuItemFont:create( "Quality" )
cc.MenuItemFont:setFontName( "American Typewriter" )
cc.MenuItemFont:setFontSize(18)
local title3 = cc.MenuItemFont:create( "Quality" )
title3:setEnabled( false )
CCMenuItemFont:setFontName( "Marker Felt" )
CCMenuItemFont:setFontSize(34)
local item3 = CCMenuItemToggle:create(CCMenuItemFont:create( "High" ))
cc.MenuItemFont:setFontName( "Marker Felt" )
cc.MenuItemFont:setFontSize(34)
local item3 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "High" ))
item3:registerScriptTapHandler(menuCallback)
item3:addSubItem(CCMenuItemFont:create( "Low" ))
item3:addSubItem(cc.MenuItemFont:create( "Low" ))
CCMenuItemFont:setFontName( "American Typewriter" )
CCMenuItemFont:setFontSize(18)
local title4 = CCMenuItemFont:create( "Orientation" )
cc.MenuItemFont:setFontName( "American Typewriter" )
cc.MenuItemFont:setFontSize(18)
local title4 = cc.MenuItemFont:create( "Orientation" )
title4:setEnabled(false)
CCMenuItemFont:setFontName( "Marker Felt" )
CCMenuItemFont:setFontSize(34)
local item4 = CCMenuItemToggle:create(CCMenuItemFont:create( "Off" ))
cc.MenuItemFont:setFontName( "Marker Felt" )
cc.MenuItemFont:setFontSize(34)
local item4 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "Off"),
cc.MenuItemFont:create( "33%" ),
cc.MenuItemFont:create( "66%" ),
cc.MenuItemFont:create( "100%"))
item4:registerScriptTapHandler(menuCallback)
item4:getSubItems():addObject( CCMenuItemFont:create( "33%" ) )
item4:getSubItems():addObject( CCMenuItemFont:create( "66%" ) )
item4:getSubItems():addObject( CCMenuItemFont:create( "100%" ) )
-- you can change the one of the items by doing this
item4:setSelectedIndex( 2 )
CCMenuItemFont:setFontName( "Marker Felt" )
CCMenuItemFont:setFontSize( 34 )
cc.MenuItemFont:setFontName( "Marker Felt" )
cc.MenuItemFont:setFontSize( 34 )
local label = CCLabelBMFont:create( "go back", "fonts/bitmapFontTest3.fnt" )
local back = CCMenuItemLabel:create(label)
local label = cc.LabelBMFont:create( "go back", "fonts/bitmapFontTest3.fnt" )
local back = cc.MenuItemLabel:create(label)
back:registerScriptTapHandler(backCallback)
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(title1)
menu:addChild(title2)
@ -482,30 +479,24 @@ local function MenuLayer4()
menu:addChild(item4 )
menu:addChild(back )
local arr = CCArray:create()
arr:addObject(CCInteger:create(2))
arr:addObject(CCInteger:create(2))
arr:addObject(CCInteger:create(2))
arr:addObject(CCInteger:create(2))
arr:addObject(CCInteger:create(1))
menu:alignItemsInColumnsWithArray(arr)
menu:alignItemsInColumns(2, 2, 2, 2, 1)
ret:addChild(menu)
local s = CCDirector:getInstance():getWinSize()
menu:setPosition(CCPoint(s.width/2, s.height/2))
local s = cc.Director:getInstance():getWinSize()
menu:setPosition(cc.p(s.width/2, s.height/2))
return ret
end
local function MenuLayerPriorityTest()
local ret = CCLayer:create()
local ret = cc.Layer:create()
local m_bPriority = false
-- Testing empty menu
local m_pMenu1 = CCMenu:create()
local m_pMenu2 = CCMenu:create()
local m_pMenu1 = cc.Menu:create()
local m_pMenu2 = cc.Menu:create()
local function menuCallback(tag, pSender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0)
end
local function enableMenuCallback()
@ -514,31 +505,28 @@ local function MenuLayerPriorityTest()
local function disableMenuCallback(tag, pSender)
m_pMenu1:setEnabled(false)
local wait = CCDelayTime:create(5)
local enable = CCCallFunc:create(enableMenuCallback)
local arr = CCArray:create()
arr:addObject(wait)
arr:addObject(enable)
local seq = CCSequence:create(arr)
local wait = cc.DelayTime:create(5)
local enable = cc.CallFunc:create(enableMenuCallback)
local seq = cc.Sequence:create(wait, enable)
m_pMenu1:runAction(seq)
end
local function togglePriorityCallback(tag, pSender)
if m_bPriority then
m_pMenu2:setHandlerPriority(kCCMenuHandlerPriority + 20)
m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY + 20)
m_bPriority = false
else
m_pMenu2:setHandlerPriority(kCCMenuHandlerPriority - 20)
m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY - 20)
m_bPriority = true
end
end
-- Menu 1
CCMenuItemFont:setFontName("Marker Felt")
CCMenuItemFont:setFontSize(18)
local item1 = CCMenuItemFont:create("Return to Main Menu")
cc.MenuItemFont:setFontName("Marker Felt")
cc.MenuItemFont:setFontSize(18)
local item1 = cc.MenuItemFont:create("Return to Main Menu")
item1:registerScriptTapHandler(menuCallback)
local item2 = CCMenuItemFont:create("Disable menu for 5 seconds")
local item2 = cc.MenuItemFont:create("Disable menu for 5 seconds")
item2:registerScriptTapHandler(disableMenuCallback)
m_pMenu1:addChild(item1)
@ -550,10 +538,10 @@ local function MenuLayerPriorityTest()
-- Menu 2
m_bPriority = true
CCMenuItemFont:setFontSize(48)
item1 = CCMenuItemFont:create("Toggle priority")
cc.MenuItemFont:setFontSize(48)
item1 = cc.MenuItemFont:create("Toggle priority")
item2:registerScriptTapHandler(togglePriorityCallback)
item1:setColor(Color3B(0,0,255))
item1:setColor(cc.c3b(0,0,255))
m_pMenu2:addChild(item1)
ret:addChild(m_pMenu2)
return ret
@ -562,78 +550,78 @@ end
-- BugsTest
local function BugsTest()
local ret = CCLayer:create()
local ret = cc.Layer:create()
local function issue1410MenuCallback(tag, pSender)
local menu = tolua.cast(pSender:getParent(), "CCMenu")
local menu = tolua.cast(pSender:getParent(), "Menu")
menu:setTouchEnabled(false)
menu:setTouchEnabled(true)
cclog("NO CRASHES")
end
local function issue1410v2MenuCallback(tag, pSender)
local menu = tolua.cast(pSender:getParent(), "CCMenu")
local menu = tolua.cast(pSender:getParent(), "Menu")
menu:setTouchEnabled(true)
menu:setTouchEnabled(false)
cclog("NO CRASHES. AND MENU SHOULD STOP WORKING")
end
local function backMenuCallback(tag, pSender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0)
end
local issue1410 = CCMenuItemFont:create("Issue 1410")
local issue1410 = cc.MenuItemFont:create("Issue 1410")
issue1410:registerScriptTapHandler(issue1410MenuCallback)
local issue1410_2 = CCMenuItemFont:create("Issue 1410 #2")
local issue1410_2 = cc.MenuItemFont:create("Issue 1410 #2")
issue1410_2:registerScriptTapHandler(issue1410v2MenuCallback)
local back = CCMenuItemFont:create("Back")
local back = cc.MenuItemFont:create("Back")
back:registerScriptTapHandler(backMenuCallback)
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(issue1410)
menu:addChild(issue1410_2)
menu:addChild(back)
ret:addChild(menu)
menu:alignItemsVertically()
local s = CCDirector:getInstance():getWinSize()
menu:setPosition(CCPoint(s.width/2, s.height/2))
local s = cc.Director:getInstance():getWinSize()
menu:setPosition(cc.p(s.width/2, s.height/2))
return ret
end
local function RemoveMenuItemWhenMove()
local ret = CCLayer:create()
local s = CCDirector:getInstance():getWinSize()
local ret = cc.Layer:create()
local s = cc.Director:getInstance():getWinSize()
local label = CCLabelTTF:create("click item and move, should not crash", "Arial", 20)
label:setPosition(CCPoint(s.width/2, s.height - 30))
local label = cc.LabelTTF:create("click item and move, should not crash", "Arial", 20)
label:setPosition(cc.p(s.width/2, s.height - 30))
ret:addChild(label)
local item = CCMenuItemFont:create("item 1")
local item = cc.MenuItemFont:create("item 1")
item:retain()
local back = CCMenuItemFont:create("go back")
local back = cc.MenuItemFont:create("go back")
local function goBack(tag, pSender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0)
tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0)
end
back:registerScriptTapHandler(goBack)
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(item)
menu:addChild(back)
ret:addChild(menu)
menu:alignItemsVertically()
menu:setPosition(CCPoint(s.width/2, s.height/2))
menu:setPosition(cc.p(s.width/2, s.height/2))
ret:setTouchEnabled(true)
--[[
local function onNodeEvent(event)
if event == "enter" then
CCDirector:getInstance():getTouchDispatcher():addTargetedDelegate(ret, -129, false)
cc.Director:getInstance():getTouchDispatcher():addTargetedDelegate(ret, -129, false)
elseif event == "exit" then
-- item:release()
end
@ -647,7 +635,7 @@ local function RemoveMenuItemWhenMove()
return true
elseif eventType == "moved" then
if item ~= nil then
item:removeFromParentAndCleanup(true)
item:removeFromParent(true)
--item:release()
--item = nil
end
@ -660,7 +648,7 @@ end
function MenuTestMain()
cclog("MenuTestMain")
local scene = CCScene:create()
local scene = cc.Scene:create()
local pLayer1 = MenuLayerMainMenu()
local pLayer2 = MenuLayer2()
@ -671,17 +659,13 @@ function MenuTestMain()
local pLayer6 = BugsTest()
local pLayer7 = RemoveMenuItemWhenMove()
local arr = CCArray:create()
arr:addObject(pLayer1)
arr:addObject(pLayer2)
arr:addObject(pLayer3)
arr:addObject(pLayer4)
arr:addObject(pLayer5)
arr:addObject(pLayer6)
arr:addObject(pLayer7)
local layer = CCLayerMultiplex:createWithArray(arr)
local layer = cc.LayerMultiplex:create(pLayer1,
pLayer2,
pLayer3,
pLayer4,
pLayer5,
pLayer6,
pLayer7)
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())

View File

@ -3,8 +3,8 @@ local streak = nil
local titleLabel = nil
local subtitleLabel = nil
local s = CCDirector:getInstance():getWinSize()
local scheduler = CCDirector:getInstance():getScheduler()
local s = cc.Director:getInstance():getWinSize()
local scheduler = cc.Director:getInstance():getScheduler()
local firstTick = nil
@ -18,14 +18,14 @@ local function modeCallback(sender)
end
local function getBaseLayer()
local layer = CCLayer:create()
local layer = cc.Layer:create()
local itemMode = CCMenuItemToggle:create(CCMenuItemFont:create("Use High Quality Mode"))
itemMode:addSubItem(CCMenuItemFont:create("Use Fast Mode"))
local itemMode = cc.MenuItemToggle:create(cc.MenuItemFont:create("Use High Quality Mode"))
itemMode:addSubItem(cc.MenuItemFont:create("Use Fast Mode"))
itemMode:registerScriptTapHandler(modeCallback)
local menuMode = CCMenu:create()
local menuMode = cc.Menu:create()
menuMode:addChild(itemMode)
menuMode:setPosition(CCPoint(s.width / 2, s.height / 4))
menuMode:setPosition(cc.p(s.width / 2, s.height / 4))
layer:addChild(menuMode)
Helper.initWithLayer(layer)
@ -47,7 +47,7 @@ local function MotionStreakTest1_update(dt)
return
end
streak:setPosition(target:convertToWorldSpace(CCPoint(0, 0)))
streak:setPosition(target:convertToWorldSpace(cc.p(0, 0)))
end
local function MotionStreakTest1_onEnterOrExit(tag)
@ -61,32 +61,30 @@ end
local function MotionStreakTest1()
local layer = getBaseLayer()
root = CCSprite:create(s_pPathR1)
root = cc.Sprite:create(s_pPathR1)
layer:addChild(root, 1)
root:setPosition(CCPoint(s.width / 2, s.height / 2))
root:setPosition(cc.p(s.width / 2, s.height / 2))
target = CCSprite:create(s_pPathR1)
target = cc.Sprite:create(s_pPathR1)
root:addChild(target)
target:setPosition(CCPoint(s.width / 4, 0))
target:setPosition(cc.p(s.width / 4, 0))
streak = CCMotionStreak:create(2, 3, 32, Color3B(0, 255, 0), s_streak)
streak = cc.MotionStreak:create(2, 3, 32, cc.c3b(0, 255, 0), s_streak)
layer:addChild(streak)
local a1 = CCRotateBy:create(2, 360)
local a1 = cc.RotateBy:create(2, 360)
local action1 = CCRepeatForever:create(a1)
local motion = CCMoveBy:create(2, CCPoint(100,0))
root:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(motion, motion:reverse())))
local action1 = cc.RepeatForever:create(a1)
local motion = cc.MoveBy:create(2, cc.p(100,0))
root:runAction(cc.RepeatForever:create(cc.Sequence:create(motion, motion:reverse())))
root:runAction(action1)
local array = CCArray:create()
array:addObject(CCTintTo:create(0.2, 255, 0, 0))
array:addObject(CCTintTo:create(0.2, 0, 255, 0))
array:addObject(CCTintTo:create(0.2, 0, 0, 255))
array:addObject(CCTintTo:create(0.2, 0, 255, 255))
array:addObject(CCTintTo:create(0.2, 255, 255, 0))
array:addObject(CCTintTo:create(0.2, 255, 255, 255))
local colorAction = CCRepeatForever:create(CCSequence:create(array))
local colorAction = cc.RepeatForever:create(cc.Sequence:create(cc.TintTo:create(0.2, 255, 0, 0),
cc.TintTo:create(0.2, 0, 255, 0),
cc.TintTo:create(0.2, 0, 0, 255),
cc.TintTo:create(0.2, 0, 255, 255),
cc.TintTo:create(0.2, 255, 255, 0),
cc.TintTo:create(0.2, 255, 255, 255)))
streak:runAction(colorAction)
@ -103,10 +101,10 @@ end
local function MotionStreakTest2()
local layer = getBaseLayer()
streak = CCMotionStreak:create(3, 3, 64, Color3B(255, 255, 255), s_streak)
streak = cc.MotionStreak:create(3, 3, 64, cc.c3b(255, 255, 255), s_streak)
layer:addChild(streak)
streak:setPosition(CCPoint(s.width / 2, s.height / 2))
streak:setPosition(cc.p(s.width / 2, s.height / 2))
local function onTouchMoved(x, y)
if firstTick == true then
@ -114,7 +112,7 @@ local function MotionStreakTest2()
return
end
streak:setPosition(CCPoint(x, y))
streak:setPosition(cc.p(x, y))
end
local function onTouch(eventType, x, y)
@ -149,7 +147,7 @@ local function Issue1358_update(dt)
end
fAngle = fAngle + 1.0
streak:setPosition(
CCPoint(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius))
cc.p(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius))
end
local function Issue1358_onEnterOrExit(tag)
@ -163,10 +161,10 @@ end
local function Issue1358()
local layer = getBaseLayer()
streak = CCMotionStreak:create(2.0, 1.0, 50.0, Color3B(255, 255, 0), "Images/Icon.png")
streak = cc.MotionStreak:create(2.0, 1.0, 50.0, cc.c3b(255, 255, 0), "Images/Icon.png")
layer:addChild(streak)
center = CCPoint(s.width / 2, s.height / 2)
center = cc.p(s.width / 2, s.height / 2)
fRadius = s.width / 3
fAngle = 0
@ -179,7 +177,7 @@ local function Issue1358()
end
function MotionStreakTest()
local scene = CCScene:create()
local scene = cc.Scene:create()
Helper.createFunctionTable = {
MotionStreakTest1,

View File

@ -3,11 +3,11 @@ local kTagSprite2 = 2
local kTagSprite3 = 3
local kTagSlider = 4
local s = CCDirector:getInstance():getWinSize()
local scheduler = CCDirector:getInstance():getScheduler()
local s = cc.Director:getInstance():getWinSize()
local scheduler = cc.Director:getInstance():getScheduler()
local function getBaseLayer()
local layer = CCLayer:create()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
@ -21,50 +21,50 @@ local function CameraCenterTest()
local layer = getBaseLayer()
-- LEFT-TOP
local sprite = CCSprite:create("Images/white-512x512.png")
local sprite = cc.Sprite:create("Images/white-512x512.png")
layer:addChild(sprite, 0)
sprite:setPosition(CCPoint(s.width / 5 * 1, s.height / 5 * 1))
sprite:setColor(Color3B(255, 0, 0))
sprite:setTextureRect(CCRect(0, 0, 120, 50))
local orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(CCRepeatForever:create(orbit))
-- [sprite setAnchorPoint: CCPoint(0,1))
sprite:setPosition(cc.p(s.width / 5 * 1, s.height / 5 * 1))
sprite:setColor(cc.c3b(255, 0, 0))
sprite:setTextureRect(cc.rect(0, 0, 120, 50))
local orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(cc.RepeatForever:create(orbit))
-- [sprite setAnchorPoint: cc.p(0,1))
-- LEFT-BOTTOM
sprite = CCSprite:create("Images/white-512x512.png")
sprite = cc.Sprite:create("Images/white-512x512.png")
layer:addChild(sprite, 0, 40)
sprite:setPosition(CCPoint(s.width / 5 * 1, s.height / 5 * 4))
sprite:setColor(Color3B(0, 0, 255))
sprite:setTextureRect(CCRect(0, 0, 120, 50))
orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(CCRepeatForever:create(orbit))
sprite:setPosition(cc.p(s.width / 5 * 1, s.height / 5 * 4))
sprite:setColor(cc.c3b(0, 0, 255))
sprite:setTextureRect(cc.rect(0, 0, 120, 50))
orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(cc.RepeatForever:create(orbit))
-- RIGHT-TOP
sprite = CCSprite:create("Images/white-512x512.png")
sprite = cc.Sprite:create("Images/white-512x512.png")
layer:addChild(sprite, 0)
sprite:setPosition(CCPoint(s.width / 5 * 4, s.height / 5 * 1))
sprite:setColor(Color3B(255, 255, 0))
sprite:setTextureRect(CCRect(0, 0, 120, 50))
orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(CCRepeatForever:create(orbit))
sprite:setPosition(cc.p(s.width / 5 * 4, s.height / 5 * 1))
sprite:setColor(cc.c3b(255, 255, 0))
sprite:setTextureRect(cc.rect(0, 0, 120, 50))
orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(cc.RepeatForever:create(orbit))
-- RIGHT-BOTTOM
sprite = CCSprite:create("Images/white-512x512.png")
sprite = cc.Sprite:create("Images/white-512x512.png")
layer:addChild(sprite, 0, 40)
sprite:setPosition(CCPoint(s.width / 5 * 4, s.height / 5 * 4))
sprite:setColor(Color3B(0, 255, 0))
sprite:setTextureRect(CCRect(0, 0, 120, 50))
orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(CCRepeatForever:create(orbit))
sprite:setPosition(cc.p(s.width / 5 * 4, s.height / 5 * 4))
sprite:setColor(cc.c3b(0, 255, 0))
sprite:setTextureRect(cc.rect(0, 0, 120, 50))
orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(cc.RepeatForever:create(orbit))
-- CENTER
sprite = CCSprite:create("Images/white-512x512.png")
sprite = cc.Sprite:create("Images/white-512x512.png")
layer:addChild(sprite, 0, 40)
sprite:setPosition(CCPoint(s.width / 2, s.height / 2))
sprite:setColor(Color3B(255, 255, 255))
sprite:setTextureRect(CCRect(0, 0, 120, 50))
orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(CCRepeatForever:create(orbit))
sprite:setPosition(cc.p(s.width / 2, s.height / 2))
sprite:setColor(cc.c3b(255, 255, 255))
sprite:setTextureRect(cc.rect(0, 0, 120, 50))
orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0)
sprite:runAction(cc.RepeatForever:create(orbit))
Helper.titleLabel:setString("Camera Center test")
Helper.subtitleLabel:setString("Sprites should rotate at the same speed")
@ -77,13 +77,13 @@ end
local function Test2()
local layer = getBaseLayer()
local sp1 = CCSprite:create(s_pPathSister1)
local sp2 = CCSprite:create(s_pPathSister2)
local sp3 = CCSprite:create(s_pPathSister1)
local sp4 = CCSprite:create(s_pPathSister2)
local sp1 = cc.Sprite:create(s_pPathSister1)
local sp2 = cc.Sprite:create(s_pPathSister2)
local sp3 = cc.Sprite:create(s_pPathSister1)
local sp4 = cc.Sprite:create(s_pPathSister2)
sp1:setPosition(CCPoint(100, s.height /2))
sp2:setPosition(CCPoint(380, s.height /2))
sp1:setPosition(cc.p(100, s.height /2))
sp2:setPosition(cc.p(380, s.height /2))
layer:addChild(sp1)
layer:addChild(sp2)
@ -92,22 +92,13 @@ local function Test2()
sp1:addChild(sp3)
sp2:addChild(sp4)
local a1 = CCRotateBy:create(2, 360)
local a2 = CCScaleBy:create(2, 2)
local a1 = cc.RotateBy:create(2, 360)
local a2 = cc.ScaleBy:create(2, 2)
local array1 = CCArray:create()
array1:addObject(a1)
array1:addObject(a2)
array1:addObject(a2:reverse())
local action1 = CCRepeatForever:create(CCSequence:create(array1))
local action1 = cc.RepeatForever:create(cc.Sequence:create(a1, a2, a2:reverse()))
local action2 = cc.RepeatForever:create(cc.Sequence:create(a1:clone(), a2:clone(), a2:reverse()))
local array2 = CCArray:create()
array2:addObject(a1:clone())
array2:addObject(a2:clone())
array2:addObject(a2:reverse())
local action2 = CCRepeatForever:create(CCSequence:create(array2))
sp2:setAnchorPoint(CCPoint(0,0))
sp2:setAnchorPoint(cc.p(0,0))
sp1:runAction(action1)
sp2:runAction(action2)
@ -125,7 +116,7 @@ local Test4_delay4Entry = nil
local function delay2(dt)
node = Test4_layer:getChildByTag(2)
local action1 = CCRotateBy:create(1, 360)
local action1 = cc.RotateBy:create(1, 360)
node:runAction(action1)
end
@ -147,10 +138,10 @@ end
local function Test4()
Test4_layer = getBaseLayer()
local sp1 = CCSprite:create(s_pPathSister1)
local sp2 = CCSprite:create(s_pPathSister2)
sp1:setPosition(CCPoint(100, 160))
sp2:setPosition(CCPoint(380, 160))
local sp1 = cc.Sprite:create(s_pPathSister1)
local sp2 = cc.Sprite:create(s_pPathSister2)
sp1:setPosition(cc.p(100, 160))
sp2:setPosition(cc.p(380, 160))
Test4_layer:addChild(sp1, 0, 2)
Test4_layer:addChild(sp2, 0, 3)
@ -195,19 +186,19 @@ end
local function Test5()
Test5_layer = getBaseLayer()
local sp1 = CCSprite:create(s_pPathSister1)
local sp2 = CCSprite:create(s_pPathSister2)
local sp1 = cc.Sprite:create(s_pPathSister1)
local sp2 = cc.Sprite:create(s_pPathSister2)
sp1:setPosition(CCPoint(100, 160))
sp2:setPosition(CCPoint(380, 160))
sp1:setPosition(cc.p(100, 160))
sp2:setPosition(cc.p(380, 160))
local rot = CCRotateBy:create(2, 360)
local rot = cc.RotateBy:create(2, 360)
local rot_back = rot:reverse()
local forever = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot_back))
local forever = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back))
local rot2 = CCRotateBy:create(2, 360)
local rot2 = cc.RotateBy:create(2, 360)
local rot2_back = rot2:reverse()
local forever2 = CCRepeatForever:create(CCSequence:createWithTwoActions(rot2, rot2_back))
local forever2 = cc.RepeatForever:create(cc.Sequence:create(rot2, rot2_back))
forever:setTag(101)
forever2:setTag(102)
@ -258,22 +249,22 @@ end
local function Test6()
Test6_layer = getBaseLayer()
local sp1 = CCSprite:create(s_pPathSister1)
local sp11 = CCSprite:create(s_pPathSister1)
local sp1 = cc.Sprite:create(s_pPathSister1)
local sp11 = cc.Sprite:create(s_pPathSister1)
local sp2 = CCSprite:create(s_pPathSister2)
local sp21 = CCSprite:create(s_pPathSister2)
local sp2 = cc.Sprite:create(s_pPathSister2)
local sp21 = cc.Sprite:create(s_pPathSister2)
sp1:setPosition(CCPoint(100, 160))
sp2:setPosition(CCPoint(380, 160))
sp1:setPosition(cc.p(100, 160))
sp2:setPosition(cc.p(380, 160))
local rot = CCRotateBy:create(2, 360)
local rot = cc.RotateBy:create(2, 360)
local rot_back = rot:reverse()
local forever1 = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot_back))
local forever11 = tolua.cast(forever1:clone(), "CCRepeatForever")
local forever1 = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back))
local forever11 = tolua.cast(forever1:clone(), "RepeatForever")
local forever2 = tolua.cast(forever1:clone(), "CCRepeatForever")
local forever21 = tolua.cast(forever1:clone(), "CCRepeatForever")
local forever2 = tolua.cast(forever1:clone(), "RepeatForever")
local forever21 = tolua.cast(forever1:clone(), "RepeatForever")
Test6_layer:addChild(sp1, 0, kTagSprite1)
sp1:addChild(sp11)
@ -307,14 +298,14 @@ local function shouldNotCrash(dt)
scheduler:unscheduleScriptEntry(StressTest1_entry)
-- if the node has timers, it crashes
local explosion = CCParticleSun:create()
explosion:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png"))
local explosion = cc.ParticleSun:create()
explosion:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png"))
explosion:setPosition(s.width / 2, s.height / 2)
StressTest1_layer:setAnchorPoint(CCPoint(0, 0))
local callFunc = CCCallFunc:create(removeMe)
StressTest1_layer:runAction(CCSequence:createWithTwoActions(CCRotateBy:create(2, 360), callFunc))
StressTest1_layer:setAnchorPoint(cc.p(0, 0))
local callFunc = cc.CallFunc:create(removeMe)
StressTest1_layer:runAction(cc.Sequence:create(cc.RotateBy:create(2, 360), callFunc))
StressTest1_layer:addChild(explosion)
end
@ -330,10 +321,10 @@ end
local function StressTest1()
StressTest1_layer = getBaseLayer()
sp1 = CCSprite:create(s_pPathSister1)
sp1 = cc.Sprite:create(s_pPathSister1)
StressTest1_layer:addChild(sp1, 0, kTagSprite1)
sp1:setPosition(CCPoint(s.width / 2, s.height / 2))
sp1:setPosition(cc.p(s.width / 2, s.height / 2))
StressTest1_layer:registerScriptHandler(StressTest1_onEnterOrExit)
@ -365,25 +356,25 @@ end
local function StressTest2()
StressTest2_layer = getBaseLayer()
sublayer = CCLayer:create()
sublayer = cc.Layer:create()
local sp1 = CCSprite:create(s_pPathSister1)
sp1:setPosition(CCPoint(80, s.height / 2))
local sp1 = cc.Sprite:create(s_pPathSister1)
sp1:setPosition(cc.p(80, s.height / 2))
local move = CCMoveBy:create(3, CCPoint(350, 0))
local move_ease_inout3 = CCEaseInOut:create(CCMoveBy:create(3, CCPoint(350, 0)), 2.0)
local move = cc.MoveBy:create(3, cc.p(350, 0))
local move_ease_inout3 = cc.EaseInOut:create(cc.MoveBy:create(3, cc.p(350, 0)), 2.0)
local move_ease_inout_back3 = move_ease_inout3:reverse()
local seq3 = CCSequence:createWithTwoActions(move_ease_inout3, move_ease_inout_back3)
sp1:runAction(CCRepeatForever:create(seq3))
local seq3 = cc.Sequence:create(move_ease_inout3, move_ease_inout_back3)
sp1:runAction(cc.RepeatForever:create(seq3))
sublayer:addChild(sp1, 1)
local fire = CCParticleFire:create()
fire:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png"))
fire = tolua.cast(fire, "CCNode")
local fire = cc.ParticleFire:create()
fire:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png"))
fire = tolua.cast(fire, "Node")
fire:setPosition(80, s.height / 2 - 50)
local copy_seq3 = tolua.cast(seq3:clone(), "CCSequence")
fire:runAction(CCRepeatForever:create(copy_seq3))
local copy_seq3 = tolua.cast(seq3:clone(), "Sequence")
fire:runAction(cc.RepeatForever:create(copy_seq3))
sublayer:addChild(fire, 2)
StressTest2_layer:registerScriptHandler(StressTest2_onEnterOrExit)
@ -404,26 +395,26 @@ local function NodeToWorld()
-- - It tests different anchor Points
-- - It tests different children anchor points
local back = CCSprite:create(s_back3)
local back = cc.Sprite:create(s_back3)
layer:addChild(back, -10)
back:setAnchorPoint(CCPoint(0, 0))
back:setAnchorPoint(cc.p(0, 0))
local backSize = back:getContentSize()
local item = CCMenuItemImage:create(s_PlayNormal, s_PlaySelect)
local menu = CCMenu:create()
local item = cc.MenuItemImage:create(s_PlayNormal, s_PlaySelect)
local menu = cc.Menu:create()
menu:addChild(item)
menu:alignItemsVertically()
menu:setPosition(CCPoint(backSize.width / 2, backSize.height / 2))
menu:setPosition(cc.p(backSize.width / 2, backSize.height / 2))
back:addChild(menu)
local rot = CCRotateBy:create(5, 360)
local fe = CCRepeatForever:create(rot)
local rot = cc.RotateBy:create(5, 360)
local fe = cc.RepeatForever:create(rot)
item:runAction(fe)
local move = CCMoveBy:create(3, CCPoint(200, 0))
local move = cc.MoveBy:create(3, cc.p(200, 0))
local move_back = move:reverse()
local seq = CCSequence:createWithTwoActions(move, move_back)
local fe2 = CCRepeatForever:create(seq)
local seq = cc.Sequence:create(move, move_back)
local fe2 = cc.RepeatForever:create(seq)
back:runAction(fe2)
Helper.titleLabel:setString("nodeToParent transform")
@ -435,50 +426,50 @@ end
-----------------------------------
local function CameraOrbitTest_onEnterOrExit(tag)
if tag == "enter" then
CCDirector:getInstance():setProjection(kCCDirectorProjection3D)
cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION3_D)
elseif tag == "exit" then
CCDirector:getInstance():setProjection(kCCDirectorProjection2D)
cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D)
end
end
local function CameraOrbitTest()
local layer = getBaseLayer()
local p = CCSprite:create(s_back3)
local p = cc.Sprite:create(s_back3)
layer:addChild(p, 0)
p:setPosition(CCPoint(s.width / 2, s.height / 2))
p:setPosition(cc.p(s.width / 2, s.height / 2))
p:setOpacity(128)
-- LEFT
local s = p:getContentSize()
local sprite = CCSprite:create(s_pPathGrossini)
local sprite = cc.Sprite:create(s_pPathGrossini)
sprite:setScale(0.5)
p:addChild(sprite, 0)
sprite:setPosition(CCPoint(s.width / 4 * 1, s.height / 2))
sprite:setPosition(cc.p(s.width / 4 * 1, s.height / 2))
local cam = sprite:getCamera()
local orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 0, 0)
sprite:runAction(CCRepeatForever:create(orbit))
local orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 0, 0)
sprite:runAction(cc.RepeatForever:create(orbit))
-- CENTER
sprite = CCSprite:create(s_pPathGrossini)
sprite = cc.Sprite:create(s_pPathGrossini)
sprite:setScale(1.0)
p:addChild(sprite, 0)
sprite:setPosition(CCPoint(s.width / 4 * 2, s.height / 2))
orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 45, 0)
sprite:runAction(CCRepeatForever:create(orbit))
sprite:setPosition(cc.p(s.width / 4 * 2, s.height / 2))
orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 45, 0)
sprite:runAction(cc.RepeatForever:create(orbit))
-- RIGHT
sprite = CCSprite:create(s_pPathGrossini)
sprite = cc.Sprite:create(s_pPathGrossini)
sprite:setScale(2.0)
p:addChild(sprite, 0)
sprite:setPosition(CCPoint(s.width / 4 * 3, s.height / 2))
sprite:setPosition(cc.p(s.width / 4 * 3, s.height / 2))
local ss = sprite:getContentSize()
orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 90, -45)
sprite:runAction(CCRepeatForever:create(orbit))
orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 90, -45)
sprite:runAction(cc.RepeatForever:create(orbit))
-- PARENT
orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 90)
p:runAction(CCRepeatForever:create(orbit))
orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 90)
p:runAction(cc.RepeatForever:create(orbit))
layer:setScale(1)
@ -498,19 +489,19 @@ local function CameraZoomTest_update(dt)
local sprite = CameraZoomTest_layer:getChildByTag(20)
local cam = sprite:getCamera()
cam:setEyeXYZ(0, 0, z)
cam:setEye(0, 0, z)
sprite = CameraZoomTest_layer:getChildByTag(40)
cam = sprite:getCamera()
cam:setEyeXYZ(0, 0, -z)
cam:setEye(0, 0, -z)
end
local function CameraZoomTest_onEnterOrExit(tag)
if tag == "enter" then
CCDirector:getInstance():setProjection(kCCDirectorProjection3D)
cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION3_D)
CameraZoomTest_entry = scheduler:scheduleScriptFunc(CameraZoomTest_update, 0.0, false)
elseif tag == "exit" then
CCDirector:getInstance():setProjection(kCCDirectorProjection2D)
cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D)
scheduler:unscheduleScriptEntry(CameraZoomTest_entry)
end
end
@ -521,22 +512,22 @@ local function CameraZoomTest()
z = 0
-- LEFT
local sprite = CCSprite:create(s_pPathGrossini)
local sprite = cc.Sprite:create(s_pPathGrossini)
CameraZoomTest_layer:addChild(sprite, 0)
sprite:setPosition(CCPoint(s.width / 4 * 1, s.height / 2))
sprite:setPosition(cc.p(s.width / 4 * 1, s.height / 2))
local cam = sprite:getCamera()
cam:setEyeXYZ(0, 0, 415 / 2)
cam:setCenterXYZ(0, 0, 0)
cam:setEye(0, 0, 415 / 2)
cam:setCenter(0, 0, 0)
-- CENTER
sprite = CCSprite:create(s_pPathGrossini)
sprite = cc.Sprite:create(s_pPathGrossini)
CameraZoomTest_layer:addChild(sprite, 0, 40)
sprite:setPosition(CCPoint(s.width / 4 * 2, s.height / 2))
sprite:setPosition(cc.p(s.width / 4 * 2, s.height / 2))
-- RIGHT
sprite = CCSprite:create(s_pPathGrossini)
sprite = cc.Sprite:create(s_pPathGrossini)
CameraZoomTest_layer:addChild(sprite, 0, 20)
sprite:setPosition(CCPoint(s.width / 4 * 3, s.height / 2))
sprite:setPosition(cc.p(s.width / 4 * 3, s.height / 2))
CameraZoomTest_layer:scheduleUpdateWithPriorityLua(CameraZoomTest_update, 0)
CameraZoomTest_layer:registerScriptHandler(CameraZoomTest_onEnterOrExit)
@ -553,28 +544,28 @@ local ConvertToNode_layer = nil
local function ConvertToNode()
ConvertToNode_layer = getBaseLayer()
local rotate = CCRotateBy:create(10, 360)
local action = CCRepeatForever:create(rotate)
local rotate = cc.RotateBy:create(10, 360)
local action = cc.RepeatForever:create(rotate)
for i = 0, 2 do
local sprite = CCSprite:create("Images/grossini.png")
sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2))
local sprite = cc.Sprite:create("Images/grossini.png")
sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2))
local point = CCSprite:create("Images/r1.png")
local point = cc.Sprite:create("Images/r1.png")
point:setScale(0.25)
point:setPosition(sprite:getPosition())
ConvertToNode_layer:addChild(point, 10, 100 + i)
if i == 0 then
sprite:setAnchorPoint(CCPoint(0, 0))
sprite:setAnchorPoint(cc.p(0, 0))
elseif i == 1 then
sprite:setAnchorPoint(CCPoint(0.5, 0.5))
sprite:setAnchorPoint(cc.p(0.5, 0.5))
elseif i == 2 then
sprite:setAnchorPoint(CCPoint(1,1))
sprite:setAnchorPoint(cc.p(1,1))
end
point:setPosition(sprite:getPosition())
local copy = tolua.cast(action:clone(), "CCRepeatForever")
local copy = tolua.cast(action:clone(), "RepeatForever")
sprite:runAction(copy)
ConvertToNode_layer:addChild(sprite, i)
end
@ -583,8 +574,8 @@ local function ConvertToNode()
for i = 0, 2 do
local node = ConvertToNode_layer:getChildByTag(100 + i)
local p1, p2
p1 = node:convertToNodeSpaceAR(CCPoint(x, y))
p2 = node:convertToNodeSpace(CCPoint(x, y))
p1 = node:convertToNodeSpaceAR(cc.p(x, y))
p2 = node:convertToNodeSpace(cc.p(x, y))
cclog("AR: x=" .. p1.x .. ", y=" .. p1.y .. " -- Not AR: x=" .. p2.x .. ", y=" .. p2.y)
end
@ -613,12 +604,9 @@ local function NodeOpaqueTest()
local layer = getBaseLayer()
for i = 0, 49 do
local background = CCSprite:create("Images/background1.png")
local blendFunc = BlendFunc:new()
blendFunc.src = GL_ONE
blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA
background:setBlendFunc(blendFunc)
background:setAnchorPoint(CCPoint(0, 0))
local background = cc.Sprite:create("Images/background1.png")
background:setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)
background:setAnchorPoint(cc.p(0, 0))
layer:addChild(background)
end
@ -634,12 +622,9 @@ local function NodeNonOpaqueTest()
local layer = getBaseLayer()
for i = 0, 49 do
background = CCSprite:create("Images/background1.jpg")
local blendFunc = BlendFunc:new()
blendFunc.src = GL_ONE
blendFunc.dst = GL_ZERO
background:setBlendFunc(blendFunc)
background:setAnchorPoint(CCPoint(0, 0))
background = cc.Sprite:create("Images/background1.jpg")
background:setBlendFunc(gl.ONE, gl.ZERO)
background:setAnchorPoint(cc.p(0, 0))
layer:addChild(background)
end
Helper.titleLabel:setString("Node Non Opaque Test")
@ -648,7 +633,7 @@ local function NodeNonOpaqueTest()
end
function CocosNodeTest()
local scene = CCScene:create()
local scene = cc.Scene:create()
Helper.createFunctionTable = {
CameraCenterTest,

View File

@ -8,7 +8,7 @@ local function OpenGLTestMainLayer()
local curCase = 0
local accum = 0
local labelBMFont = nil
local size = CCDirector:getInstance():getWinSize()
local size = cc.Director:getInstance():getWinSize()
local curLayer = nil
local schedulEntry = nil
local function OrderCallbackMenu()
@ -30,23 +30,23 @@ local function OpenGLTestMainLayer()
ShowCurrentTest()
end
local ordercallbackmenu = CCMenu:create()
local size = CCDirector:getInstance():getWinSize()
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
local ordercallbackmenu = cc.Menu:create()
local size = cc.Director:getInstance():getWinSize()
local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2)
item1:registerScriptTapHandler(backCallback)
ordercallbackmenu:addChild(item1,kItemTagBasic)
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2)
item2:registerScriptTapHandler(restartCallback)
ordercallbackmenu:addChild(item2,kItemTagBasic)
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2)
ordercallbackmenu:addChild(item3,kItemTagBasic)
item3:registerScriptTapHandler(nextCallback)
item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2))
item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2))
item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
ordercallbackmenu:setPosition(CCPoint(0, 0))
ordercallbackmenu:setPosition(cc.p(0, 0))
return ordercallbackmenu
end
@ -125,14 +125,14 @@ local function OpenGLTestMainLayer()
local function InitTitle(layer)
--Title
local lableTitle = CCLabelTTF:create(GetTitle(), "Arial", 40)
local lableTitle = cc.LabelTTF:create(GetTitle(), "Arial", 40)
layer:addChild(lableTitle, 15)
lableTitle:setPosition(CCPoint(size.width/2, size.height-32))
lableTitle:setColor(Color3B(255,255,40))
lableTitle:setPosition(cc.p(size.width/2, size.height-32))
lableTitle:setColor(cc.c3b(255,255,40))
--SubTitle
local subLabelTitle = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16)
local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16)
layer:addChild(subLabelTitle, 15)
subLabelTitle:setPosition(CCPoint(size.width/2, size.height-80))
subLabelTitle:setPosition(cc.p(size.width/2, size.height-80))
end
local function updateRetroEffect(fTime)
@ -145,10 +145,11 @@ local function OpenGLTestMainLayer()
return
end
local i = 0
local len = children:count()
local len = table.getn(children)
for i= 0 ,len - 1 do
local child = tolua.cast(children:objectAtIndex(i), "CCSprite")
local oldPosX,oldPosY = child:getPosition()
local child = tolua.cast(children[i + 1], "Sprite")
local oldPos = child:getPosition()
local oldPosX,oldPosY = oldPos.x, oldPos.y
child:setPosition(oldPosX,math.sin(accum * 2 + i / 2.0) * 20)
local scaleY = math.sin(accum * 2 + i / 2.0 + 0.707)
child:setScaleY(scaleY)
@ -156,15 +157,15 @@ local function OpenGLTestMainLayer()
end
local function createShaderRetroEffect()
local RetroEffectlayer = CCLayer:create()
local RetroEffectlayer = cc.Layer:create()
InitTitle(RetroEffectlayer)
local program = CCGLProgram:create("Shaders/example_ColorBars.vsh", "Shaders/example_ColorBars.fsh")
program:addAttribute(CCConstants.ATTRIBUTE_NAME_POSITION, CCConstants.VERTEX_ATTRIB_POSITION)
program:addAttribute(CCConstants.ATTRIBUTE_NAME_TEX_COORD, CCConstants.VERTEX_ATTRIB_TEX_COORDS)
local program = cc.GLProgram:create("Shaders/example_ColorBars.vsh", "Shaders/example_ColorBars.fsh")
program:addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION)
program:addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS)
program:link()
program:updateUniforms()
label = CCLabelBMFont:create("RETRO EFFECT","fonts/west_england-64.fnt")
label = cc.LabelBMFont:create("RETRO EFFECT","fonts/west_england-64.fnt")
label:setShaderProgram( program )
label:setPosition(size.width/2, size.height/2)
@ -179,21 +180,21 @@ local function OpenGLTestMainLayer()
local uniformResolution = 0
local time = 0
local squareVertexPositionBuffer = {}
local majorLayer = CCLayer:create()
local majorLayer = cc.Layer:create()
InitTitle(majorLayer)
--loadShaderVertex
local shader = CCGLProgram:create("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh")
local shader = cc.GLProgram:create("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh")
shader:addAttribute("aVertex", CCConstants.VERTEX_ATTRIB_POSITION)
shader:addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION)
shader:link()
shader:updateUniforms()
local program = shader:getProgram()
local glNode = gl.glNodeCreate()
glNode:setContentSize(CCSize(256,256))
glNode:setAnchorPoint(CCPoint(0.5, 0.5))
glNode:setContentSize(cc.size(256,256))
glNode:setAnchorPoint(cc.p(0.5, 0.5))
uniformCenter = gl.getUniformLocation(program,"center")
uniformResolution = gl.getUniformLocation( program, "resolution")
glNode:setShaderProgram(shader)
@ -215,14 +216,14 @@ local function OpenGLTestMainLayer()
shader:use()
shader:setUniformsForBuiltins()
--Uniforms
shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationWith2f( uniformResolution, 256, 256)
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationF32( uniformResolution, 256, 256)
gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_POSITION)
gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION)
--Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
gl.bindBuffer(gl.ARRAY_BUFFER,0)
end
@ -241,11 +242,11 @@ local function OpenGLTestMainLayer()
local uniformResolution = 0
local time = 0
local squareVertexPositionBuffer = {}
local mandelbrotLayer = CCLayer:create()
local mandelbrotLayer = cc.Layer:create()
InitTitle(mandelbrotLayer)
--loadShaderVertex
local shader = CCGLProgram:create("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh")
local shader = cc.GLProgram:create("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh")
shader:addAttribute("aVertex", 0)
shader:link()
@ -254,8 +255,8 @@ local function OpenGLTestMainLayer()
local program = shader:getProgram()
local glNode = gl.glNodeCreate()
glNode:setContentSize(CCSize(256,256))
glNode:setAnchorPoint(CCPoint(0.5, 0.5))
glNode:setContentSize(cc.size(256,256))
glNode:setAnchorPoint(cc.p(0.5, 0.5))
uniformCenter = gl.getUniformLocation(program,"center")
uniformResolution = gl.getUniformLocation( program, "resolution")
glNode:setShaderProgram(shader)
@ -277,14 +278,14 @@ local function OpenGLTestMainLayer()
shader:use()
shader:setUniformsForBuiltins()
--Uniforms
shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationWith2f( uniformResolution, 256, 256)
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationF32( uniformResolution, 256, 256)
gl.glEnableVertexAttribs(0x1)
--Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
gl.bindBuffer(gl.ARRAY_BUFFER,0)
end
@ -303,11 +304,11 @@ local function OpenGLTestMainLayer()
local uniformResolution = 0
local time = 0
local squareVertexPositionBuffer = {}
local heartLayer = CCLayer:create()
local heartLayer = cc.Layer:create()
InitTitle(heartLayer)
--loadShaderVertex
local shader = CCGLProgram:create("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh")
local shader = cc.GLProgram:create("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh")
shader:addAttribute("aVertex", 0)
shader:link()
@ -316,8 +317,8 @@ local function OpenGLTestMainLayer()
local program = shader:getProgram()
local glNode = gl.glNodeCreate()
glNode:setContentSize(CCSize(256,256))
glNode:setAnchorPoint(CCPoint(0.5, 0.5))
glNode:setContentSize(cc.size(256,256))
glNode:setAnchorPoint(cc.p(0.5, 0.5))
uniformCenter = gl.getUniformLocation(program,"center")
uniformResolution = gl.getUniformLocation( program, "resolution")
glNode:setShaderProgram(shader)
@ -339,14 +340,14 @@ local function OpenGLTestMainLayer()
shader:use()
shader:setUniformsForBuiltins()
--Uniforms
shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationWith2f( uniformResolution, 256, 256)
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationF32( uniformResolution, 256, 256)
gl.glEnableVertexAttribs(0x1)
--Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
gl.bindBuffer(gl.ARRAY_BUFFER,0)
end
@ -365,11 +366,11 @@ local function OpenGLTestMainLayer()
local uniformResolution = 0
local time = 0
local squareVertexPositionBuffer = {}
local plasmaLayer = CCLayer:create()
local plasmaLayer = cc.Layer:create()
InitTitle(plasmaLayer)
--loadShaderVertex
local shader = CCGLProgram:create("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh")
local shader = cc.GLProgram:create("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh")
shader:addAttribute("aVertex", 0)
shader:link()
@ -378,8 +379,8 @@ local function OpenGLTestMainLayer()
local program = shader:getProgram()
local glNode = gl.glNodeCreate()
glNode:setContentSize(CCSize(256,256))
glNode:setAnchorPoint(CCPoint(0.5, 0.5))
glNode:setContentSize(cc.size(256,256))
glNode:setAnchorPoint(cc.p(0.5, 0.5))
uniformCenter = gl.getUniformLocation(program,"center")
uniformResolution = gl.getUniformLocation( program, "resolution")
glNode:setShaderProgram(shader)
@ -401,14 +402,14 @@ local function OpenGLTestMainLayer()
shader:use()
shader:setUniformsForBuiltins()
--Uniforms
shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationWith2f( uniformResolution, 256, 256)
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationF32( uniformResolution, 256, 256)
gl.glEnableVertexAttribs(0x1)
--Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
gl.bindBuffer(gl.ARRAY_BUFFER,0)
end
@ -427,11 +428,11 @@ local function OpenGLTestMainLayer()
local uniformResolution = 0
local time = 0
local squareVertexPositionBuffer = {}
local flowerLayer = CCLayer:create()
local flowerLayer = cc.Layer:create()
InitTitle(flowerLayer)
--loadShaderVertex
local shader = CCGLProgram:create("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh")
local shader = cc.GLProgram:create("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh")
shader:addAttribute("aVertex", 0)
shader:link()
@ -440,8 +441,8 @@ local function OpenGLTestMainLayer()
local program = shader:getProgram()
local glNode = gl.glNodeCreate()
glNode:setContentSize(CCSize(256,256))
glNode:setAnchorPoint(CCPoint(0.5, 0.5))
glNode:setContentSize(cc.size(256,256))
glNode:setAnchorPoint(cc.p(0.5, 0.5))
uniformCenter = gl.getUniformLocation(program,"center")
uniformResolution = gl.getUniformLocation( program, "resolution")
glNode:setShaderProgram(shader)
@ -463,14 +464,14 @@ local function OpenGLTestMainLayer()
shader:use()
shader:setUniformsForBuiltins()
--Uniforms
shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationWith2f( uniformResolution, 256, 256)
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationF32( uniformResolution, 256, 256)
gl.glEnableVertexAttribs(0x1)
--Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
gl.bindBuffer(gl.ARRAY_BUFFER,0)
end
@ -489,11 +490,11 @@ local function OpenGLTestMainLayer()
local uniformResolution = 0
local time = 0
local squareVertexPositionBuffer = {}
local juliaLayer = CCLayer:create()
local juliaLayer = cc.Layer:create()
InitTitle(juliaLayer)
--loadShaderVertex
local shader = CCGLProgram:create("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh")
local shader = cc.GLProgram:create("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh")
shader:addAttribute("aVertex", 0)
shader:link()
@ -502,8 +503,8 @@ local function OpenGLTestMainLayer()
local program = shader:getProgram()
local glNode = gl.glNodeCreate()
glNode:setContentSize(CCSize(256,256))
glNode:setAnchorPoint(CCPoint(0.5, 0.5))
glNode:setContentSize(cc.size(256,256))
glNode:setAnchorPoint(cc.p(0.5, 0.5))
uniformCenter = gl.getUniformLocation(program,"center")
uniformResolution = gl.getUniformLocation( program, "resolution")
glNode:setShaderProgram(shader)
@ -525,14 +526,14 @@ local function OpenGLTestMainLayer()
shader:use()
shader:setUniformsForBuiltins()
--Uniforms
shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationWith2f( uniformResolution, 256, 256)
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
shader:setUniformLocationF32( uniformResolution, 256, 256)
gl.glEnableVertexAttribs(0x1)
--Draw fullscreen Square
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
gl.bindBuffer(gl.ARRAY_BUFFER,0)
end
@ -547,18 +548,18 @@ local function OpenGLTestMainLayer()
end
local function createGLGetActiveTest()
local glGetActiveLayer = CCLayer:create()
local glGetActiveLayer = cc.Layer:create()
InitTitle(glGetActiveLayer)
local sprite = CCSprite:create("Images/grossini.png")
local sprite = cc.Sprite:create("Images/grossini.png")
sprite:setPosition( size.width/2, size.height/2)
glGetActiveLayer:addChild(sprite)
local glNode = gl.glNodeCreate()
glGetActiveLayer:addChild(glNode,-10)
local scheduler = CCDirector:getInstance():getScheduler()
local scheduler = cc.Director:getInstance():getScheduler()
local function getCurrentResult()
local var = {}
local glProgam = tolua.cast(sprite:getShaderProgram(),"CCGLProgram")
local glProgam = tolua.cast(sprite:getShaderProgram(),"GLProgram")
if nil ~= glProgam then
local p = glProgam:getProgram()
local aaSize,aaType,aaName = gl.getActiveAttrib(p,0)
@ -597,14 +598,14 @@ local function OpenGLTestMainLayer()
local texture = {}
local squareVertexPositionBuffer = {}
local squareVertexTextureBuffer = {}
local texImage2dLayer = CCLayer:create()
local texImage2dLayer = cc.Layer:create()
InitTitle(texImage2dLayer)
local glNode = gl.glNodeCreate()
texImage2dLayer:addChild(glNode, 10)
glNode:setPosition(size.width/2, size.height/2)
glNode:setContentSize(CCSize(128,128))
glNode:setAnchorPoint(CCPoint(0.5,0.5))
local shaderCache = CCShaderCache:getInstance()
glNode:setContentSize(cc.size(128,128))
glNode:setAnchorPoint(cc.p(0.5,0.5))
local shaderCache = cc.ShaderCache:getInstance()
local shader = shaderCache:getProgram("ShaderPositionTexture")
local function initGL()
texture.texture_id = gl.createTexture()
@ -646,14 +647,14 @@ local function OpenGLTestMainLayer()
shader:setUniformsForBuiltins()
gl.bindTexture(gl.TEXTURE_2D, texture.texture_id)
gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_TEX_COORDS or CCConstants.VERTEX_ATTRIB_FLAG_POSITION)
gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_TEX_COORDS or cc.VERTEX_ATTRIB_FLAG_POSITION)
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION,2,gl.FLOAT,false,0,0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,gl.FLOAT,false,0,0)
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexTextureBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_TEX_COORDS,2,gl.FLOAT,false,0,0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,gl.FLOAT,false,0,0)
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
@ -668,7 +669,7 @@ local function OpenGLTestMainLayer()
end
local function CreateSupportedExtensionsLayer()
local extensionsLayer = CCLayer:create()
local extensionsLayer = cc.Layer:create()
InitTitle(extensionsLayer)
local glNode = gl.glNodeCreate()
extensionsLayer:addChild(glNode,-10)
@ -687,7 +688,7 @@ local function OpenGLTestMainLayer()
end
local function CreateReadPixelsTest()
local readPixelsLayer = CCLayer:create()
local readPixelsLayer = cc.Layer:create()
InitTitle(readPixelsLayer)
local glNode = gl.glNodeCreate()
readPixelsLayer:addChild(glNode,-10)
@ -695,10 +696,10 @@ local function OpenGLTestMainLayer()
local x = size.width
local y = size.height
local blue = CCLayerColor:create(Color4B(0, 0, 255, 255))
local red = CCLayerColor:create(Color4B(255, 0, 0, 255))
local green = CCLayerColor:create(Color4B(0, 255, 0, 255))
local white = CCLayerColor:create(Color4B(255, 255, 255, 255))
local blue = cc.LayerColor:create(cc.c4b(0, 0, 255, 255))
local red = cc.LayerColor:create(cc.c4b(255, 0, 0, 255))
local green = cc.LayerColor:create(cc.c4b(0, 255, 0, 255))
local white = cc.LayerColor:create(cc.c4b(255, 255, 255, 255))
blue:setScale(0.5)
blue:setPosition(-x / 4, -y / 4)
@ -717,7 +718,7 @@ local function OpenGLTestMainLayer()
readPixelsLayer:addChild(green,12)
readPixelsLayer:addChild(red,13)
local scheduler = CCDirector:getInstance():getScheduler()
local scheduler = cc.Director:getInstance():getScheduler()
local function getCurrentResult()
local x = size.width
@ -773,16 +774,16 @@ local function OpenGLTestMainLayer()
end
local function createClearTest()
local clearLayer = CCLayer:create()
local clearLayer = cc.Layer:create()
InitTitle(clearLayer)
local blue = CCLayerColor:create(Color4B(0, 0, 255, 255))
local blue = cc.LayerColor:create(cc.c4b(0, 0, 255, 255))
clearLayer:addChild( blue, 1 )
local glNode = gl.glNodeCreate()
clearLayer:addChild(glNode,10)
--gl.init()
local scheduler = CCDirector:getInstance():getScheduler()
local scheduler = cc.Director:getInstance():getScheduler()
local function clearDraw()
gl.clear(gl.COLOR_BUFFER_BIT)
@ -813,7 +814,7 @@ local function OpenGLTestMainLayer()
end
local function createNodeWebGLAPITest()
local nodeWebGLAPILayer = CCLayer:create()
local nodeWebGLAPILayer = cc.Layer:create()
InitTitle(nodeWebGLAPILayer)
local glNode = gl.glNodeCreate()
nodeWebGLAPILayer:addChild(glNode,10)
@ -971,11 +972,11 @@ local function OpenGLTestMainLayer()
end
local function createGLNodeCCAPITest()
local nodeCCAPILayer = CCLayer:create()
local nodeCCAPILayer = cc.Layer:create()
InitTitle(nodeCCAPILayer)
local glNode = gl.glNodeCreate()
nodeCCAPILayer:addChild(glNode,10)
local shader = CCShaderCache:getInstance():getProgram("ShaderPositionColor")
local shader = cc.ShaderCache:getInstance():getProgram("ShaderPositionColor")
local triangleVertexPositionBuffer = {}
local triangleVertexColorBuffer = {}
local squareVertexPositionBuffer = {}
@ -1026,22 +1027,22 @@ local function OpenGLTestMainLayer()
local function GLNodeCCAPIDraw()
shader:use()
shader:setUniformsForBuiltins()
gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_COLOR or CCConstants.VERTEX_ATTRIB_FLAG_POSITION)
gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_COLOR or cc.VERTEX_ATTRIB_FLAG_POSITION)
--
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexColorBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)
gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexColorBuffer.buffer_id)
gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0)
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3)
@ -1056,7 +1057,7 @@ local function OpenGLTestMainLayer()
end
local function createGLTexParamterTest()
local glTexParamLayer = CCLayer:create()
local glTexParamLayer = cc.Layer:create()
InitTitle(glTexParamLayer)
local glNode = gl.glNodeCreate()
glTexParamLayer:addChild(glNode,10)
@ -1079,14 +1080,14 @@ local function OpenGLTestMainLayer()
end
local function createGetUniformTest()
local getUniformLayer = CCLayer:create()
local getUniformLayer = cc.Layer:create()
InitTitle(getUniformLayer)
local glNode = gl.glNodeCreate()
getUniformLayer:addChild(glNode,10)
local pMatrix = {1,2,3,4, 4,3,2,1, 1,2,4,8, 1.1,1.2,1.3,1.4}
local function runTest()
local shader = CCShaderCache:getInstance():getProgram("ShaderPositionTextureColor")
local shader = cc.ShaderCache:getInstance():getProgram("ShaderPositionTextureColor")
local program = shader:getProgram()
shader:use()
@ -1147,10 +1148,10 @@ local function OpenGLTestMainLayer()
end
function ShowCurrentTest()
local curScene = CCScene:create()
local curScene = cc.Scene:create()
if nil ~= curScene then
if nil ~= curLayer then
local scheduler = CCDirector:getInstance():getScheduler()
local scheduler = cc.Director:getInstance():getScheduler()
if nil ~= schedulEntry then
scheduler:unscheduleScriptEntry(schedulEntry)
end
@ -1160,7 +1161,7 @@ local function OpenGLTestMainLayer()
curScene:addChild(curLayer)
curLayer:addChild(OrderCallbackMenu(),15)
curScene:addChild(CreateBackMenuItem())
CCDirector:getInstance():replaceScene(curScene)
cc.Director:getInstance():replaceScene(curScene)
end
end
end
@ -1170,7 +1171,7 @@ local function OpenGLTestMainLayer()
end
function OpenGLTestMain()
local scene = CCScene:create()
local scene = cc.Scene:create()
scene:addChild(OpenGLTestMainLayer())
scene:addChild(CreateBackMenuItem())
return scene

View File

@ -2,7 +2,7 @@ local kTagNode = 0
local kTagGrossini = 1
local function createParallaxLayer(title, subtitle)
local layer = CCLayer:create()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
local titleStr = title == nil and "No title" or title
local subTitleStr = subtitle == nil and "" or subtitle
@ -20,61 +20,56 @@ end
local function Parallax1()
local ret = createParallaxLayer("Parallax: parent and 3 children")
-- Top Layer, a simple image
local cocosImage = CCSprite:create(s_Power)
local cocosImage = cc.Sprite:create(s_Power)
-- scale the image (optional)
cocosImage:setScale( 2.5 )
-- change the transform anchor point to 0,0 (optional)
cocosImage:setAnchorPoint( CCPoint(0,0) )
cocosImage:setAnchorPoint( cc.p(0,0) )
-- Middle layer: a Tile map atlas
local tilemap = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16)
local tilemap = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16)
tilemap:releaseMap()
-- change the transform anchor to 0,0 (optional)
tilemap:setAnchorPoint( CCPoint(0, 0) )
tilemap:setAnchorPoint( cc.p(0, 0) )
-- Anti Aliased images
tilemap:getTexture():setAntiAliasTexParameters()
-- background layer: another image
local background = CCSprite:create(s_back)
local background = cc.Sprite:create(s_back)
-- scale the image (optional)
background:setScale( 1.5 )
-- change the transform anchor point (optional)
background:setAnchorPoint( CCPoint(0,0) )
background:setAnchorPoint( cc.p(0,0) )
-- create a void node, a parent node
local voidNode = CCParallaxNode:create()
local voidNode = cc.ParallaxNode:create()
-- NOW add the 3 layers to the 'void' node
-- background image is moved at a ratio of 0.4x, 0.5y
voidNode:addChild(background, -1, CCPoint(0.4,0.5), CCPoint(0,0))
voidNode:addChild(background, -1, cc.p(0.4,0.5), cc.p(0,0))
-- tiles are moved at a ratio of 2.2x, 1.0y
voidNode:addChild(tilemap, 1, CCPoint(2.2,1.0), CCPoint(0,-200) )
voidNode:addChild(tilemap, 1, cc.p(2.2,1.0), cc.p(0,-200) )
-- top image is moved at a ratio of 3.0x, 2.5y
voidNode:addChild(cocosImage, 2, CCPoint(3.0,2.5), CCPoint(200,800) )
voidNode:addChild(cocosImage, 2, cc.p(3.0,2.5), cc.p(200,800) )
-- now create some actions that will move the 'void' node
-- and the children of the 'void' node will move at different
-- speed, thus, simulation the 3D environment
local goUp = CCMoveBy:create(4, CCPoint(0,-500) )
local goUp = cc.MoveBy:create(4, cc.p(0,-500) )
local goDown = goUp:reverse()
local go = CCMoveBy:create(8, CCPoint(-1000,0) )
local go = cc.MoveBy:create(8, cc.p(-1000,0) )
local goBack = go:reverse()
local arr = CCArray:create()
arr:addObject(goUp)
arr:addObject(go)
arr:addObject(goDown)
arr:addObject(goBack)
local seq = CCSequence:create(arr)
voidNode:runAction( (CCRepeatForever:create(seq) ))
local seq = cc.Sequence:create(goUp, go, goDown, goBack)
voidNode:runAction( (cc.RepeatForever:create(seq) ))
ret:addChild( voidNode )
return ret
@ -91,45 +86,45 @@ local function Parallax2()
ret:setTouchEnabled( true )
-- Top Layer, a simple image
local cocosImage = CCSprite:create(s_Power)
local cocosImage = cc.Sprite:create(s_Power)
-- scale the image (optional)
cocosImage:setScale( 2.5 )
-- change the transform anchor point to 0,0 (optional)
cocosImage:setAnchorPoint( CCPoint(0,0) )
cocosImage:setAnchorPoint( cc.p(0,0) )
-- Middle layer: a Tile map atlas
local tilemap = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16)
local tilemap = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16)
tilemap:releaseMap()
-- change the transform anchor to 0,0 (optional)
tilemap:setAnchorPoint( CCPoint(0, 0) )
tilemap:setAnchorPoint( cc.p(0, 0) )
-- Anti Aliased images
tilemap:getTexture():setAntiAliasTexParameters()
-- background layer: another image
local background = CCSprite:create(s_back)
local background = cc.Sprite:create(s_back)
-- scale the image (optional)
background:setScale( 1.5 )
-- change the transform anchor point (optional)
background:setAnchorPoint( CCPoint(0,0) )
background:setAnchorPoint( cc.p(0,0) )
-- create a void node, a parent node
local voidNode = CCParallaxNode:create()
local voidNode = cc.ParallaxNode:create()
-- NOW add the 3 layers to the 'void' node
-- background image is moved at a ratio of 0.4x, 0.5y
voidNode:addChild(background, -1, CCPoint(0.4,0.5), CCPoint(0, 0))
voidNode:addChild(background, -1, cc.p(0.4,0.5), cc.p(0, 0))
-- tiles are moved at a ratio of 1.0, 1.0y
voidNode:addChild(tilemap, 1, CCPoint(1.0,1.0), CCPoint(0,-200) )
voidNode:addChild(tilemap, 1, cc.p(1.0,1.0), cc.p(0,-200) )
-- top image is moved at a ratio of 3.0x, 2.5y
voidNode:addChild( cocosImage, 2, CCPoint(3.0,2.5), CCPoint(200,1000) )
voidNode:addChild( cocosImage, 2, cc.p(3.0,2.5), cc.p(200,1000) )
ret:addChild(voidNode, 0, kTagNode)
local prev = {x = 0, y = 0}
local function onTouchEvent(eventType, x, y)
@ -144,7 +139,7 @@ local function Parallax2()
local diffX = x - prev.x
local diffY = y - prev.y
node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) )
node:setPosition( cc.pAdd(cc.p(newX, newY), cc.p(diffX, diffY)) )
prev.x = x
prev.y = y
end
@ -157,8 +152,8 @@ end
function ParallaxTestMain()
cclog("ParallaxMain")
Helper.index = 1
CCDirector:getInstance():setDepthTest(true)
local scene = CCScene:create()
cc.Director:getInstance():setDepthTest(true)
local scene = cc.Scene:create()
Helper.createFunctionTable = {
Parallax1,

View File

@ -3,68 +3,68 @@ local kBasicZOrder = 10
local kNodesIncrease = 250
local TEST_COUNT = 7
local s = CCDirector:getInstance():getWinSize()
local s = cc.Director:getInstance():getWinSize()
-----------------------------------
-- For test functions
-----------------------------------
local function performanceActions(sprite)
sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0
local rot = CCRotateBy:create(period, 360.0 * math.random())
local rot = CCRotateBy:create(period, 360.0 * math.random())
local permanentRotation = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot:reverse()))
local rot = cc.RotateBy:create(period, 360.0 * math.random())
local rot = cc.RotateBy:create(period, 360.0 * math.random())
local permanentRotation = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(rot, rot:reverse()))
sprite:runAction(permanentRotation)
local growDuration = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0
local grow = CCScaleBy:create(growDuration, 0.5, 0.5)
local permanentScaleLoop = CCRepeatForever:create(CCSequence:createWithTwoActions(grow, grow:reverse()))
local grow = cc.ScaleBy:create(growDuration, 0.5, 0.5)
local permanentScaleLoop = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(grow, grow:reverse()))
sprite:runAction(permanentScaleLoop)
end
local function performanceActions20(sprite)
if math.random() < 0.2 then
sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
else
sprite:setPosition(CCPoint(-1000, -1000))
sprite:setPosition(cc.p(-1000, -1000))
end
local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0
local rot = CCRotateBy:create(period, 360.0 * math.random())
local permanentRotation = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot:reverse()))
local rot = cc.RotateBy:create(period, 360.0 * math.random())
local permanentRotation = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(rot, rot:reverse()))
sprite:runAction(permanentRotation)
local growDuration = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0
local grow = CCScaleBy:create(growDuration, 0.5, 0.5)
local permanentScaleLoop = CCRepeatForever:create(CCSequence:createWithTwoActions(grow, grow:reverse()))
local grow = cc.ScaleBy:create(growDuration, 0.5, 0.5)
local permanentScaleLoop = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(grow, grow:reverse()))
sprite:runAction(permanentScaleLoop)
end
local function performanceRotationScale(sprite)
sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
sprite:setRotation(math.random() * 360)
sprite:setScale(math.random() * 2)
end
local function performancePosition(sprite)
sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
end
local function performanceout20(sprite)
if math.random() < 0.2 then
sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
else
sprite:setPosition(CCPoint(-1000, -1000))
sprite:setPosition(cc.p(-1000, -1000))
end
end
local function performanceOut100(sprite)
sprite:setPosition(CCPoint( -1000, -1000))
sprite:setPosition(cc.p( -1000, -1000))
end
local function performanceScale(sprite)
sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height)))
sprite:setScale(math.random() * 100 / 50)
end
@ -72,43 +72,43 @@ end
-- Subtest
-----------------------------------
local subtestNumber = 1
local batchNode = nil -- CCSpriteBatchNode
local parent = nil -- CCNode
local batchNode = nil -- cc.SpriteBatchNode
local parent = nil -- cc.Node
local function initWithSubTest(nSubTest, p)
subtestNumber = nSubTest
parent = p
batchNode = nil
local mgr = CCTextureCache:getInstance()
local mgr = cc.TextureCache:getInstance()
-- remove all texture
mgr:removeTexture(mgr:addImage("Images/grossinis_sister1.png"))
mgr:removeTexture(mgr:addImage("Images/grossini_dance_atlas.png"))
mgr:removeTexture(mgr:addImage("Images/spritesheet1.png"))
if subtestNumber == 2 then
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888)
batchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888)
batchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100)
p:addChild(batchNode, 0)
elseif subtestNumber == 3 then
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444)
batchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444)
batchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100)
p:addChild(batchNode, 0)
elseif subtestNumber == 5 then
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888)
batchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888)
batchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100)
p:addChild(batchNode, 0)
elseif subtestNumber == 6 then
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444)
batchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444)
batchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100)
p:addChild(batchNode, 0)
elseif subtestNumber == 8 then
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888)
batchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888)
batchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100)
p:addChild(batchNode, 0)
elseif subtestNumber == 9 then
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444)
batchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444)
batchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100)
p:addChild(batchNode, 0)
end
@ -117,21 +117,21 @@ local function initWithSubTest(nSubTest, p)
batchNode:retain()
end
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT)
end
local function createSpriteWithTag(tag)
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888)
local sprite = nil
if subtestNumber == 1 then
sprite = CCSprite:create("Images/grossinis_sister1.png")
sprite = cc.Sprite:create("Images/grossinis_sister1.png")
parent:addChild(sprite, -1, tag + 100)
elseif subtestNumber == 2 then
sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(0, 0, 52, 139))
sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(0, 0, 52, 139))
batchNode:addChild(sprite, 0, tag + 100)
elseif subtestNumber == 3 then
sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(0, 0, 52, 139))
sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(0, 0, 52, 139))
batchNode:addChild(sprite, 0, tag + 100)
elseif subtestNumber == 4 then
local idx = math.floor((math.random() * 1400 / 100)) + 1
@ -142,7 +142,7 @@ local function createSpriteWithTag(tag)
num = idx
end
local str = "Images/grossini_dance_" .. num .. ".png"
sprite = CCSprite:create(str)
sprite = cc.Sprite:create(str)
parent:addChild(sprite, -1, tag + 100)
elseif subtestNumber == 5 then
local y, x
@ -151,7 +151,7 @@ local function createSpriteWithTag(tag)
x = math.mod(r, 5)
x = x * 85
y = y * 121
sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 85, 121))
sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 85, 121))
batchNode:addChild(sprite, 0, tag + 100)
elseif subtestNumber == 6 then
local y, x
@ -160,7 +160,7 @@ local function createSpriteWithTag(tag)
x = math.mod(r, 5)
x = x * 85
y = y * 121
sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 85, 121))
sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 85, 121))
batchNode:addChild(sprite, 0, tag + 100)
elseif subtestNumber == 7 then
local y, x
@ -168,7 +168,7 @@ local function createSpriteWithTag(tag)
y = math.floor(r / 8)
x = math.mod(r, 8)
local str = "Images/sprites_test/sprite-"..x.."-"..y..".png"
sprite = CCSprite:create(str)
sprite = cc.Sprite:create(str)
parent:addChild(sprite, -1, tag + 100)
elseif subtestNumber == 8 then
local y, x
@ -177,7 +177,7 @@ local function createSpriteWithTag(tag)
x = math.mod(r, 8)
x = x * 32
y = y * 32
sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 32, 32))
sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 32, 32))
batchNode:addChild(sprite, 0, tag + 100)
elseif subtestNumber == 9 then
local y, x
@ -186,11 +186,11 @@ local function createSpriteWithTag(tag)
x = math.mod(r, 8)
x = x * 32
y = y * 32
sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 32, 32))
sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 32, 32))
batchNode:addChild(sprite, 0, tag + 100)
end
CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default)
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT)
return sprite
end
@ -215,7 +215,7 @@ local maxCases = 7
local function showThisTest()
local scene = CreateSpriteTestScene()
CCDirector:getInstance():replaceScene(scene)
cc.Director:getInstance():replaceScene(scene)
end
local function backCallback(sender)
@ -240,23 +240,23 @@ local function nextCallback(sender)
end
local function toPerformanceMainLayer(sender)
CCDirector:getInstance():replaceScene(PerformanceTest())
cc.Director:getInstance():replaceScene(PerformanceTest())
end
local function initWithLayer(layer, controlMenuVisible)
CCMenuItemFont:setFontName("Arial")
CCMenuItemFont:setFontSize(24)
local mainItem = CCMenuItemFont:create("Back")
cc.MenuItemFont:setFontName("Arial")
cc.MenuItemFont:setFontSize(24)
local mainItem = cc.MenuItemFont:create("Back")
mainItem:registerScriptTapHandler(toPerformanceMainLayer)
mainItem:setPosition(s.width - 50, 25)
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(mainItem)
menu:setPosition(CCPoint(0, 0))
menu:setPosition(cc.p(0, 0))
if controlMenuVisible == true then
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
@ -342,56 +342,56 @@ local function initWithMainTest(scene, asubtest, nNodes)
lastRenderedCount = 0
quantityNodes = 0
CCMenuItemFont:setFontSize(65)
local decrease = CCMenuItemFont:create(" - ")
cc.MenuItemFont:setFontSize(65)
local decrease = cc.MenuItemFont:create(" - ")
decrease:registerScriptTapHandler(onDecrease)
decrease:setColor(Color3B(0, 200, 20))
local increase = CCMenuItemFont:create(" + ")
decrease:setColor(cc.c3b(0, 200, 20))
local increase = cc.MenuItemFont:create(" + ")
increase:registerScriptTapHandler(onIncrease)
increase:setColor(Color3B(0, 200, 20))
increase:setColor(cc.c3b(0, 200, 20))
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(decrease)
menu:addChild(increase)
menu:alignItemsHorizontally()
menu:setPosition(s.width / 2, s.height - 65)
scene:addChild(menu, 1)
infoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30)
infoLabel:setColor(Color3B(0, 200, 20))
infoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30)
infoLabel:setColor(cc.c3b(0, 200, 20))
infoLabel:setPosition(s.width / 2, s.height - 90)
scene:addChild(infoLabel, 1)
maxCases = TEST_COUNT
-- Sub Tests
CCMenuItemFont:setFontSize(32)
subMenu = CCMenu:create()
cc.MenuItemFont:setFontSize(32)
subMenu = cc.Menu:create()
for i = 1, 9 do
local str = i .. " "
local itemFont = CCMenuItemFont:create(str)
local itemFont = cc.MenuItemFont:create(str)
itemFont:registerScriptTapHandler(testNCallback)
--itemFont:setTag(i)
subMenu:addChild(itemFont, kBasicZOrder + i, kBasicZOrder + i)
if i <= 3 then
itemFont:setColor(Color3B(200, 20, 20))
itemFont:setColor(cc.c3b(200, 20, 20))
elseif i <= 6 then
itemFont:setColor(Color3B(0, 200, 20))
itemFont:setColor(cc.c3b(0, 200, 20))
else
itemFont:setColor(Color3B(0, 20, 200))
itemFont:setColor(cc.c3b(0, 20, 200))
end
end
subMenu:alignItemsHorizontally()
subMenu:setPosition(CCPoint(s.width / 2, 80))
subMenu:setPosition(cc.p(s.width / 2, 80))
scene:addChild(subMenu, 1)
-- add title label
titleLabel = CCLabelTTF:create("No title", "Arial", 40)
titleLabel = cc.LabelTTF:create("No title", "Arial", 40)
scene:addChild(titleLabel, 1)
titleLabel:setPosition(s.width / 2, s.height - 32)
titleLabel:setColor(Color3B(255, 255, 40))
titleLabel:setColor(cc.c3b(255, 255, 40))
while quantityNodes < nNodes do
onIncrease()
@ -406,7 +406,7 @@ function doPerformSpriteTest1(sprite)
end
local function SpriteTestLayer1()
local layer = CCLayer:create()
local layer = cc.Layer:create()
initWithLayer(layer, true)
local str = "A (" .. subtestNumber .. ") position"
@ -423,7 +423,7 @@ function doPerformSpriteTest2(sprite)
end
local function SpriteTestLayer2()
local layer = CCLayer:create()
local layer = cc.Layer:create()
initWithLayer(layer, true)
local str = "B (" .. subtestNumber .. ") scale"
@ -440,7 +440,7 @@ function doPerformSpriteTest3(sprite)
end
local function SpriteTestLayer3()
local layer = CCLayer:create()
local layer = cc.Layer:create()
initWithLayer(layer, true)
local str = "C (" .. subtestNumber .. ") scale + rot"
@ -457,7 +457,7 @@ function doPerformSpriteTest4(sprite)
end
local function SpriteTestLayer4()
local layer = CCLayer:create()
local layer = cc.Layer:create()
initWithLayer(layer, true)
local str = "D (" .. subtestNumber .. ") 100% out"
@ -474,7 +474,7 @@ function doPerformSpriteTest5(sprite)
end
local function SpriteTestLayer5()
local layer = CCLayer:create()
local layer = cc.Layer:create()
initWithLayer(layer, true)
local str = "E (" .. subtestNumber .. ") 80% out"
@ -491,7 +491,7 @@ function doPerformSpriteTest6(sprite)
end
local function SpriteTestLayer6()
local layer = CCLayer:create()
local layer = cc.Layer:create()
initWithLayer(layer, true)
local str = "F (" .. subtestNumber .. ") actions"
@ -508,7 +508,7 @@ function doPerformSpriteTest7(sprite)
end
local function SpriteTestLayer7()
local layer = CCLayer:create()
local layer = cc.Layer:create()
initWithLayer(layer, true)
local str = "G (" .. subtestNumber .. ") actions 80% out"
@ -521,7 +521,7 @@ end
-- PerformanceSpriteTest
-----------------------------------
function CreateSpriteTestScene()
local scene = CCScene:create()
local scene = cc.Scene:create()
initWithMainTest(scene, subtestNumber, kNodesIncrease)
if curCase == 0 then

View File

@ -7,7 +7,7 @@
local function RenderTextureSave()
local ret = createTestLayer("Touch the screen",
"Press 'Save Image' to create an snapshot of the render texture")
local s = CCDirector:getInstance():getWinSize()
local s = cc.Director:getInstance():getWinSize()
local m_pTarget = nil
local m_pBrush = nil
local m_pTarget = nil
@ -20,20 +20,20 @@ local function RenderTextureSave()
local png = string.format("image-%d.png", counter)
local jpg = string.format("image-%d.jpg", counter)
m_pTarget:saveToFile(png, kCCImageFormatPNG)
m_pTarget:saveToFile(jpg, kCCImageFormatJPEG)
m_pTarget:saveToFile(png, cc.IMAGE_FORMAT_PNG)
m_pTarget:saveToFile(jpg, cc.IMAGE_FORMAT_JPEG)
local pImage = m_pTarget:newCCImage()
local pImage = m_pTarget:newImage()
local tex = CCTextureCache:getInstance():addUIImage(pImage, png)
local tex = cc.TextureCache:getInstance():addUIImage(pImage, png)
pImage:release()
local sprite = CCSprite:createWithTexture(tex)
local sprite = cc.Sprite:createWithTexture(tex)
sprite:setScale(0.3)
ret:addChild(sprite)
sprite:setPosition(CCPoint(40, 40))
sprite:setPosition(cc.p(40, 40))
sprite:setRotation(counter * 3)
cclog("Image saved %s and %s", png, jpg)
@ -44,25 +44,25 @@ local function RenderTextureSave()
if event == "exit" then
m_pBrush:release()
m_pTarget:release()
CCTextureCache:getInstance():removeUnusedTextures()
cc.TextureCache:getInstance():removeUnusedTextures()
end
end
ret:registerScriptHandler(onNodeEvent)
-- create a render texture, this is what we are going to draw into
m_pTarget = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888)
m_pTarget = cc.RenderTexture:create(s.width, s.height, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888)
m_pTarget:retain()
m_pTarget:setPosition(CCPoint(s.width / 2, s.height / 2))
m_pTarget:setPosition(cc.p(s.width / 2, s.height / 2))
-- note that the render texture is a CCNode, and contains a sprite of its texture for convience,
-- so we can just parent it to the scene like any other CCNode
-- note that the render texture is a cc.Node, and contains a sprite of its texture for convience,
-- so we can just parent it to the scene like any other cc.Node
ret:addChild(m_pTarget, -1)
-- create a brush image to draw into the texture with
m_pBrush = CCSprite:create("Images/fire.png")
m_pBrush = cc.Sprite:create("Images/fire.png")
m_pBrush:retain()
m_pBrush:setColor(Color3B(255, 0, 0))
m_pBrush:setColor(cc.c3b(255, 0, 0))
m_pBrush:setOpacity(20)
@ -76,15 +76,15 @@ local function RenderTextureSave()
local diffX = x - prev.x
local diffY = y - prev.y
local startP = CCPoint(x, y)
local endP = CCPoint(prev.x, prev.y)
local startP = cc.p(x, y)
local endP = cc.p(prev.x, prev.y)
-- begin drawing to the render texture
m_pTarget:begin()
-- for extra points, we'll draw this smoothly from the last position and vary the sprite's
-- scale/rotation/offset
local distance = startP:getDistance(endP)
local distance = cc.pGetDistance(startP, endP)
if distance > 1 then
local d = distance
local i = 0
@ -92,13 +92,13 @@ local function RenderTextureSave()
local difx = endP.x - startP.x
local dify = endP.y - startP.y
local delta = i / distance
m_pBrush:setPosition(CCPoint(startP.x + (difx * delta), startP.y + (dify * delta)))
m_pBrush:setPosition(cc.p(startP.x + (difx * delta), startP.y + (dify * delta)))
m_pBrush:setRotation(math.random(0, 359))
local r = math.random(0, 49) / 50.0 + 0.25
m_pBrush:setScale(r)
-- Use CCRANDOM_0_1() will cause error when loading libtests.so on android, I don't know why.
m_pBrush:setColor(Color3B(math.random(0, 126) + 128, 255, 255))
-- Use cc.RANDOM_0_1() will cause error when loading libtests.so on android, I don't know why.
m_pBrush:setColor(cc.c3b(math.random(0, 126) + 128, 255, 255))
-- Call visit to draw the brush, don't call draw..
m_pBrush:visit()
end
@ -115,18 +115,15 @@ local function RenderTextureSave()
ret:setTouchEnabled(true)
ret:registerScriptTouchHandler(onTouchEvent)
-- Save Image menu
CCMenuItemFont:setFontSize(16)
local item1 = CCMenuItemFont:create("Save Image")
cc.MenuItemFont:setFontSize(16)
local item1 = cc.MenuItemFont:create("Save Image")
item1:registerScriptTapHandler(saveImage)
local item2 = CCMenuItemFont:create("Clear")
local item2 = cc.MenuItemFont:create("Clear")
item2:registerScriptTapHandler(clearImage)
local arr = CCArray:create()
arr:addObject(item1)
arr:addObject(item2)
local menu = CCMenu:createWithArray(arr)
local menu = cc.Menu:create(item1, item2)
ret:addChild(menu)
menu:alignItemsVertically()
menu:setPosition(CCPoint(VisibleRect:rightTop().x - 80, VisibleRect:rightTop().y - 30))
menu:setPosition(cc.p(VisibleRect:rightTop().x - 80, VisibleRect:rightTop().y - 30))
return ret
end
@ -150,20 +147,20 @@ end
-- * B1: non-premulti sprite
-- * B2: non-premulti render
-- */
-- local background = CCLayerColor:create(Color4B(200,200,200,255))
-- local background = cc.LayerColor:create(cc.c4b(200,200,200,255))
-- addChild(background)
-- local spr_premulti = CCSprite:create("Images/fire.png")
-- spr_premulti:setPosition(CCPoint(16,48))
-- local spr_premulti = cc.Sprite:create("Images/fire.png")
-- spr_premulti:setPosition(cc.p(16,48))
-- local spr_nonpremulti = CCSprite:create("Images/fire.png")
-- spr_nonpremulti:setPosition(CCPoint(16,16))
-- local spr_nonpremulti = cc.Sprite:create("Images/fire.png")
-- spr_nonpremulti:setPosition(cc.p(16,16))
-- /* A2 & B2 setup */
-- local rend = CCRenderTexture:create(32, 64, kCCTexture2DPixelFormat_RGBA8888)
-- local rend = cc.RenderTexture:create(32, 64, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888)
-- if (NULL == rend)
@ -178,14 +175,14 @@ end
-- spr_nonpremulti:visit()
-- rend:end()
-- local s = CCDirector:getInstance():getWinSize()
-- local s = cc.Director:getInstance():getWinSize()
-- --/* A1: setup */
-- spr_premulti:setPosition(CCPoint(s.width/2-16, s.height/2+16))
-- spr_premulti:setPosition(cc.p(s.width/2-16, s.height/2+16))
-- --/* B1: setup */
-- spr_nonpremulti:setPosition(CCPoint(s.width/2-16, s.height/2-16))
-- spr_nonpremulti:setPosition(cc.p(s.width/2-16, s.height/2-16))
-- rend:setPosition(CCPoint(s.width/2+16, s.height/2))
-- rend:setPosition(cc.p(s.width/2+16, s.height/2))
-- addChild(spr_nonpremulti)
-- addChild(spr_premulti)
@ -207,7 +204,7 @@ end
-- local pLayer = nextTestCase()
-- addChild(pLayer)
-- CCDirector:getInstance():replaceScene(this)
-- cc.Director:getInstance():replaceScene(this)
-- end
-- --/**
@ -217,35 +214,35 @@ end
-- local function RenderTextureZbuffer()
-- this:setTouchEnabled(true)
-- local size = CCDirector:getInstance():getWinSize()
-- local label = CCLabelTTF:create("vertexZ = 50", "Marker Felt", 64)
-- label:setPosition(CCPoint(size.width / 2, size.height * 0.25))
-- local size = cc.Director:getInstance():getWinSize()
-- local label = cc.LabelTTF:create("vertexZ = 50", "Marker Felt", 64)
-- label:setPosition(cc.p(size.width / 2, size.height * 0.25))
-- this:addChild(label)
-- local label2 = CCLabelTTF:create("vertexZ = 0", "Marker Felt", 64)
-- label2:setPosition(CCPoint(size.width / 2, size.height * 0.5))
-- local label2 = cc.LabelTTF:create("vertexZ = 0", "Marker Felt", 64)
-- label2:setPosition(cc.p(size.width / 2, size.height * 0.5))
-- this:addChild(label2)
-- local label3 = CCLabelTTF:create("vertexZ = -50", "Marker Felt", 64)
-- label3:setPosition(CCPoint(size.width / 2, size.height * 0.75))
-- local label3 = cc.LabelTTF:create("vertexZ = -50", "Marker Felt", 64)
-- label3:setPosition(cc.p(size.width / 2, size.height * 0.75))
-- this:addChild(label3)
-- label:setVertexZ(50)
-- label2:setVertexZ(0)
-- label3:setVertexZ(-50)
-- CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("Images/bugs/circle.plist")
-- mgr = CCSpriteBatchNode:create("Images/bugs/circle.png", 9)
-- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("Images/bugs/circle.plist")
-- mgr = cc.SpriteBatchNode:create("Images/bugs/circle.png", 9)
-- this:addChild(mgr)
-- sp1 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp2 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp3 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp4 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp5 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp6 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp7 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp8 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp9 = CCSprite:createWithSpriteFrameName("circle.png")
-- sp1 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- sp2 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- sp3 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- sp4 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- sp5 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- sp6 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- sp7 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- sp8 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- sp9 = cc.Sprite:createWithSpriteFrameName("circle.png")
-- mgr:addChild(sp1, 9)
-- mgr:addChild(sp2, 8)
@ -268,7 +265,7 @@ end
-- sp9:setVertexZ(-400)
-- sp9:setScale(2)
-- sp9:setColor(Color3B::YELLOW)
-- sp9:setColor(cc.c3b::YELLOW)
-- end
-- local function title()
@ -281,13 +278,13 @@ end
-- return "Touch screen. It should be green"
-- end
-- local function ccTouchesBegan(cocos2d:CCSet *touches, cocos2d:CCEvent *event)
-- local function ccTouchesBegan(cocos2d:cc.Set *touches, cocos2d:cc.Event *event)
-- CCSetIterator iter
-- CCTouch *touch
-- cc.SetIterator iter
-- cc.Touch *touch
-- for (iter = touches:begin() iter != touches:end() ++iter)
-- touch = (CCTouch *)(*iter)
-- touch = (cc.Touch *)(*iter)
-- local location = touch:getLocation()
-- sp1:setPosition(location)
@ -302,13 +299,13 @@ end
-- end
-- end
-- local function ccTouchesMoved(CCSet* touches, CCEvent* event)
-- local function ccTouchesMoved(cc.Set* touches, cc.Event* event)
-- CCSetIterator iter
-- CCTouch *touch
-- cc.SetIterator iter
-- cc.Touch *touch
-- for (iter = touches:begin() iter != touches:end() ++iter)
-- touch = (CCTouch *)(*iter)
-- touch = (cc.Touch *)(*iter)
-- local location = touch:getLocation()
-- sp1:setPosition(location)
@ -323,35 +320,35 @@ end
-- end
-- end
-- local function ccTouchesEnded(CCSet* touches, CCEvent* event)
-- local function ccTouchesEnded(cc.Set* touches, cc.Event* event)
-- this:renderScreenShot()
-- end
-- local function renderScreenShot()
-- local texture = CCRenderTexture:create(512, 512)
-- local texture = cc.RenderTexture:create(512, 512)
-- if (NULL == texture)
-- return
-- end
-- texture:setAnchorPoint(CCPoint(0, 0))
-- texture:setAnchorPoint(cc.p(0, 0))
-- texture:begin()
-- this:visit()
-- texture:end()
-- local sprite = CCSprite:createWithTexture(texture:getSprite():getTexture())
-- local sprite = cc.Sprite:createWithTexture(texture:getSprite():getTexture())
-- sprite:setPosition(CCPoint(256, 256))
-- sprite:setPosition(cc.p(256, 256))
-- sprite:setOpacity(182)
-- sprite:setFlipY(1)
-- this:addChild(sprite, 999999)
-- sprite:setColor(Color3B::GREEN)
-- sprite:setColor(cc.c3b::GREEN)
-- sprite:runAction(CCSequence:create(CCFadeTo:create(2, 0),
-- CCHide:create(),
-- sprite:runAction(cc.Sequence:create(cc.FadeTo:create(2, 0),
-- cc.Hide:create(),
-- NULL))
-- end
@ -359,12 +356,12 @@ end
-- local function RenderTextureTestDepthStencil()
-- local s = CCDirector:getInstance():getWinSize()
-- local s = cc.Director:getInstance():getWinSize()
-- local sprite = CCSprite:create("Images/fire.png")
-- sprite:setPosition(CCPoint(s.width * 0.25, 0))
-- local sprite = cc.Sprite:create("Images/fire.png")
-- sprite:setPosition(cc.p(s.width * 0.25, 0))
-- sprite:setScale(10)
-- local rend = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8)
-- local rend = cc.RenderTexture:create(s.width, s.height, kcc.Texture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8)
-- glStencilMask(0xFF)
-- rend:beginWithClear(0, 0, 0, 0, 0, 0)
@ -377,7 +374,7 @@ end
-- sprite:visit()
-- --! move sprite half width and height, and draw only where not marked
-- sprite:setPosition(CCPoint.__add(sprite:getPosition(), CCPoint.__mul(CCPoint(sprite:getContentSize().width * sprite:getScale(), sprite:getContentSize().height * sprite:getScale()), 0.5)))
-- sprite:setPosition(cc.p__add(sprite:getPosition(), cc.p__mul(cc.p(sprite:getContentSize().width * sprite:getScale(), sprite:getContentSize().height * sprite:getScale()), 0.5)))
-- glStencilFunc(GL_NOTEQUAL, 1, 0xFF)
-- glColorMask(1, 1, 1, 1)
-- sprite:visit()
@ -386,7 +383,7 @@ end
-- glDisable(GL_STENCIL_TEST)
-- rend:setPosition(CCPoint(s.width * 0.5, s.height * 0.5))
-- rend:setPosition(cc.p(s.width * 0.5, s.height * 0.5))
-- this:addChild(rend)
-- end
@ -416,29 +413,29 @@ end
-- * B1: non-premulti sprite
-- * B2: non-premulti render
-- */
-- local background = CCLayerColor:create(Color4B(40,40,40,255))
-- local background = cc.LayerColor:create(cc.c4b(40,40,40,255))
-- addChild(background)
-- -- sprite 1
-- sprite1 = CCSprite:create("Images/fire.png")
-- sprite1 = cc.Sprite:create("Images/fire.png")
-- -- sprite 2
-- sprite2 = CCSprite:create("Images/fire_rgba8888.pvr")
-- sprite2 = cc.Sprite:create("Images/fire_rgba8888.pvr")
-- local s = CCDirector:getInstance():getWinSize()
-- local s = cc.Director:getInstance():getWinSize()
-- /* Create the render texture */
-- local renderTexture = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444)
-- local renderTexture = cc.RenderTexture:create(s.width, s.height, kcc.Texture2DPixelFormat_RGBA4444)
-- this:renderTexture = renderTexture
-- renderTexture:setPosition(CCPoint(s.width/2, s.height/2))
-- -- [renderTexture setPosition:CCPoint(s.width, s.height)]
-- renderTexture:setPosition(cc.p(s.width/2, s.height/2))
-- -- [renderTexture setPosition:cc.p(s.width, s.height)]
-- -- renderTexture.scale = 2
-- /* add the sprites to the render texture */
-- renderTexture:addChild(sprite1)
-- renderTexture:addChild(sprite2)
-- renderTexture:setClearColor(Color4F(0, 0, 0, 0))
-- renderTexture:setClearColor(cc.c4f(0, 0, 0, 0))
-- renderTexture:setClearFlags(GL_COLOR_BUFFER_BIT)
-- /* add the render texture to the scene */
@ -449,14 +446,14 @@ end
-- scheduleUpdate()
-- -- Toggle clear on / off
-- local item = CCMenuItemFont:create("Clear On/Off", this, menu_selector(RenderTextureTargetNode:touched))
-- local menu = CCMenu:create(item, NULL)
-- local item = cc.MenuItemFont:create("Clear On/Off", this, menu_selector(RenderTextureTargetNode:touched))
-- local menu = cc.Menu:create(item, NULL)
-- addChild(menu)
-- menu:setPosition(CCPoint(s.width/2, s.height/2))
-- menu:setPosition(cc.p(s.width/2, s.height/2))
-- end
-- local function touched(CCObject* sender)
-- local function touched(cc.Object* sender)
-- if (renderTexture:getClearFlags() == 0)
@ -465,7 +462,7 @@ end
-- else
-- renderTexture:setClearFlags(0)
-- renderTexture:setClearColor(Color4F( CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1))
-- renderTexture:setClearColor(cc.c4f( cc.RANDOM_0_1(), cc.RANDOM_0_1(), cc.RANDOM_0_1(), 1))
-- end
-- end
@ -473,8 +470,8 @@ end
-- static float time = 0
-- float r = 80
-- sprite1:setPosition(CCPoint(cosf(time * 2) * r, sinf(time * 2) * r))
-- sprite2:setPosition(CCPoint(sinf(time * 2) * r, cosf(time * 2) * r))
-- sprite1:setPosition(cc.p(cosf(time * 2) * r, sinf(time * 2) * r))
-- sprite2:setPosition(cc.p(sinf(time * 2) * r, cosf(time * 2) * r))
-- time += dt
-- end
@ -493,7 +490,7 @@ end
-- local function SimpleSprite() : rt(NULL) {}
-- local function SimpleSprite* SpriteRenderTextureBug:SimpleSprite:create(const char* filename, const CCRect &rect)
-- local function SimpleSprite* SpriteRenderTextureBug:SimpleSprite:create(const char* filename, const cc.rect &rect)
-- SimpleSprite *sprite = new SimpleSprite()
-- if (sprite && sprite:initWithFile(filename, rect))
@ -502,7 +499,7 @@ end
-- end
-- else
-- CC_SAFE_DELETE(sprite)
-- cc._SAFE_DELETE(sprite)
-- end
-- return sprite
@ -512,14 +509,14 @@ end
-- if (rt == NULL)
-- local s = CCDirector:getInstance():getWinSize()
-- rt = new CCRenderTexture()
-- rt:initWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888)
-- local s = cc.Director:getInstance():getWinSize()
-- rt = new cc.RenderTexture()
-- rt:initWithWidthAndHeight(s.width, s.height, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888)
-- end
-- rt:beginWithClear(0.0, 0.0, 0.0, 1.0)
-- rt:end()
-- CC_NODE_DRAW_SETUP()
-- cc._NODE_DRAW_SETUP()
-- BlendFunc blend = getBlendFunc()
-- ccGLBlendFunc(blend.src, blend.dst)
@ -530,22 +527,22 @@ end
-- -- Attributes
-- --
-- ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex)
-- ccGLEnableVertexAttribs(kcc.VertexAttribFlag_PosColorTex)
-- #define kQuadSize sizeof(m_sQuad.bl)
-- long offset = (long)&m_sQuad
-- -- vertex
-- int diff = offsetof( V3F_C4B_T2F, vertices)
-- glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff))
-- glVertexAttribPointer(kcc.VertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff))
-- -- texCoods
-- diff = offsetof( V3F_C4B_T2F, texCoords)
-- glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff))
-- glVertexAttribPointer(kcc.VertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff))
-- -- color
-- diff = offsetof( V3F_C4B_T2F, colors)
-- glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff))
-- glVertexAttribPointer(kcc.VertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff))
-- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)
-- end
@ -554,51 +551,51 @@ end
-- setTouchEnabled(true)
-- local s = CCDirector:getInstance():getWinSize()
-- addNewSpriteWithCoords(CCPoint(s.width/2, s.height/2))
-- local s = cc.Director:getInstance():getWinSize()
-- addNewSpriteWithCoords(cc.p(s.width/2, s.height/2))
-- end
-- local function SimpleSprite* SpriteRenderTextureBug:addNewSpriteWithCoords(const CCPoint& p)
-- local function SimpleSprite* SpriteRenderTextureBug:addNewSpriteWithCoords(const cc.p& p)
-- int idx = CCRANDOM_0_1() * 1400 / 100
-- int idx = cc.RANDOM_0_1() * 1400 / 100
-- int x = (idx%5) * 85
-- int y = (idx/5) * 121
-- SpriteRenderTextureBug:SimpleSprite *sprite = SpriteRenderTextureBug:SimpleSprite:create("Images/grossini_dance_atlas.png",
-- CCRect(x,y,85,121))
-- cc.rect(x,y,85,121))
-- addChild(sprite)
-- sprite:setPosition(p)
-- local action = NULL
-- float rd = CCRANDOM_0_1()
-- float rd = cc.RANDOM_0_1()
-- if (rd < 0.20)
-- action = CCScaleBy:create(3, 2)
-- action = cc.ScaleBy:create(3, 2)
-- else if (rd < 0.40)
-- action = CCRotateBy:create(3, 360)
-- action = cc.RotateBy:create(3, 360)
-- else if (rd < 0.60)
-- action = CCBlink:create(1, 3)
-- action = cc.Blink:create(1, 3)
-- else if (rd < 0.8 )
-- action = CCTintBy:create(2, 0, -255, -255)
-- action = cc.TintBy:create(2, 0, -255, -255)
-- else
-- action = CCFadeOut:create(2)
-- action = cc.FadeOut:create(2)
-- local action_back = action:reverse()
-- local seq = CCSequence:create(action, action_back, NULL)
-- local seq = cc.Sequence:create(action, action_back, NULL)
-- sprite:runAction(CCRepeatForever:create(seq))
-- sprite:runAction(cc.RepeatForever:create(seq))
-- --return sprite
-- return NULL
-- end
-- local function ccTouchesEnded(CCSet* touches, CCEvent* event)
-- local function ccTouchesEnded(cc.Set* touches, cc.Event* event)
-- CCSetIterator iter = touches:begin()
-- cc.SetIterator iter = touches:begin()
-- for( iter != touches:end() ++iter)
-- local location = ((CCTouch*)(*iter)):getLocation()
-- local location = ((cc.Touch*)(*iter)):getLocation()
-- addNewSpriteWithCoords(location)
-- end
-- end
@ -616,7 +613,7 @@ end
function RenderTextureTestMain()
cclog("RenderTextureTestMain")
Helper.index = 1
local scene = CCScene:create()
local scene = cc.Scene:create()
Helper.createFunctionTable = {
RenderTextureSave,

View File

@ -1,60 +1,60 @@
local size = CCDirector:getInstance():getWinSize()
local size = cc.Director:getInstance():getWinSize()
local function CreateSpriteLayer()
local layer = CCLayer:create()
local layer = cc.Layer:create()
local x, y
x = size.width
y = size.height
local sprite = CCSprite:create(s_pPathGrossini)
local spriteSister1 = CCSprite:create(s_pPathSister1)
local spriteSister2 = CCSprite:create(s_pPathSister2)
local sprite = cc.Sprite:create(s_pPathGrossini)
local spriteSister1 = cc.Sprite:create(s_pPathSister1)
local spriteSister2 = cc.Sprite:create(s_pPathSister2)
sprite:setScale(1.5)
spriteSister1:setScale(1.5)
spriteSister2:setScale(1.5)
sprite:setPosition(CCPoint(x / 2, y / 2))
spriteSister1:setPosition(CCPoint(40, y / 2))
spriteSister2:setPosition(CCPoint(x - 40, y / 2))
sprite:setPosition(cc.p(x / 2, y / 2))
spriteSister1:setPosition(cc.p(40, y / 2))
spriteSister2:setPosition(cc.p(x - 40, y / 2))
layer:addChild(sprite)
layer:addChild(spriteSister1)
layer:addChild(spriteSister2)
local rot = CCRotateBy:create(16, -3600)
local rot = cc.RotateBy:create(16, -3600)
sprite:runAction(rot)
local jump1 = CCJumpBy:create(4, CCPoint(-400, 0), 100, 4)
local jump1 = cc.JumpBy:create(4, cc.p(-400, 0), 100, 4)
local jump2 = jump1:reverse()
local rot1 = CCRotateBy:create(4, 360 * 2)
local rot1 = cc.RotateBy:create(4, 360 * 2)
local rot2 = rot1:reverse()
local jump3 = CCJumpBy:create(4, CCPoint(-400, 0), 100, 4)
local jump3 = cc.JumpBy:create(4, cc.p(-400, 0), 100, 4)
local jump4 = jump3:reverse()
local rot3 = CCRotateBy:create(4, 360 * 2)
local rot3 = cc.RotateBy:create(4, 360 * 2)
local rot4 = rot3:reverse()
spriteSister1:runAction(CCRepeat:create(CCSequence:createWithTwoActions(jump2, jump1), 5))
spriteSister2:runAction(CCRepeat:create(CCSequence:createWithTwoActions(jump3, jump4), 5))
spriteSister1:runAction(cc.Repeat:create(cc.Sequence:create(jump2, jump1), 5))
spriteSister2:runAction(cc.Repeat:create(cc.Sequence:create(jump3, jump4), 5))
spriteSister1:runAction(CCRepeat:create(CCSequence:createWithTwoActions(rot1, rot2), 5))
spriteSister2:runAction(CCRepeat:create(CCSequence:createWithTwoActions(rot4, rot3), 5))
spriteSister1:runAction(cc.Repeat:create(cc.Sequence:create(rot1, rot2), 5))
spriteSister2:runAction(cc.Repeat:create(cc.Sequence:create(rot4, rot3), 5))
return layer
end
local function CreateTestLayer()
local layer = CCLayer:create()
local layer = cc.Layer:create()
local x, y
x = size.width
y = size.height
local label = CCLabelTTF:create("cocos2d", "Tahoma", 64)
local label = cc.LabelTTF:create("cocos2d", "Tahoma", 64)
label:setPosition(x / 2, y / 2)
layer:addChild(label)
@ -62,42 +62,42 @@ local function CreateTestLayer()
end
local function CreateRotateWorldLayer()
local layer = CCLayer:create()
local layer = cc.Layer:create()
local x, y
x = size.width
y = size.height
local blue = CCLayerColor:create(Color4B(0,0,255,255))
local red = CCLayerColor:create(Color4B(255,0,0,255))
local green = CCLayerColor:create(Color4B(0,255,0,255))
local white = CCLayerColor:create(Color4B(255,255,255,255))
local blue = cc.LayerColor:create(cc.c4b(0,0,255,255))
local red = cc.LayerColor:create(cc.c4b(255,0,0,255))
local green = cc.LayerColor:create(cc.c4b(0,255,0,255))
local white = cc.LayerColor:create(cc.c4b(255,255,255,255))
blue:setScale(0.5)
blue:setPosition(CCPoint(- x / 4, - y / 4))
blue:setPosition(cc.p(- x / 4, - y / 4))
blue:addChild(CreateSpriteLayer())
red:setScale(0.5)
red:setPosition(CCPoint(x / 4, - y / 4))
red:setPosition(cc.p(x / 4, - y / 4))
green:setScale(0.5)
green:setPosition(CCPoint(- x / 4, y / 4))
green:setPosition(cc.p(- x / 4, y / 4))
green:addChild(CreateTestLayer())
white:setScale(0.5)
white:setPosition(CCPoint(x / 4, y / 4))
white:setPosition(cc.p(x / 4, y / 4))
white:ignoreAnchorPointForPosition(false)
white:setPosition(CCPoint(x / 4 * 3, y / 4 * 3))
white:setPosition(cc.p(x / 4 * 3, y / 4 * 3))
layer:addChild(blue, -1)
layer:addChild(white)
layer:addChild(green)
layer:addChild(red)
local rot = CCRotateBy:create(8, 720)
local rot1 = CCRotateBy:create(8, 720)
local rot2 = CCRotateBy:create(8, 720)
local rot3 = CCRotateBy:create(8, 720)
local rot = cc.RotateBy:create(8, 720)
local rot1 = cc.RotateBy:create(8, 720)
local rot2 = cc.RotateBy:create(8, 720)
local rot3 = cc.RotateBy:create(8, 720)
blue:runAction(rot)
red:runAction(rot1)
@ -112,12 +112,12 @@ end
--------------------------------
function RotateWorldTest()
cclog("RotateWorldTest")
local scene = CCScene:create()
local scene = cc.Scene:create()
local layer = CreateRotateWorldLayer()
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
scene:runAction(CCRotateBy:create(4, -360))
scene:runAction(cc.RotateBy:create(4, -360))
return scene
end

View File

@ -16,22 +16,22 @@ local SceneTestLayer3 = nil
--------------------------------------------------------------------
SceneTestLayer1 = function()
local ret = CCLayer:create()
local ret = cc.Layer:create()
local function onPushScene(tag, pSender)
local scene = CCScene:create()
local scene = cc.Scene:create()
local layer = SceneTestLayer2()
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
CCDirector:getInstance():pushScene( scene )
cc.Director:getInstance():pushScene( scene )
end
local function onPushSceneTran(tag, pSender)
local scene = CCScene:create()
local scene = cc.Scene:create()
local layer = SceneTestLayer2()
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
CCDirector:getInstance():pushScene( CCTransitionSlideInT:create(1, scene) )
cc.Director:getInstance():pushScene( cc.TransitionSlideInT:create(1, scene) )
end
@ -39,28 +39,24 @@ SceneTestLayer1 = function()
cclog("onQuit")
end
local item1 = CCMenuItemFont:create( "Test pushScene")
local item1 = cc.MenuItemFont:create( "Test pushScene")
item1:registerScriptTapHandler(onPushScene)
local item2 = CCMenuItemFont:create( "Test pushScene w/transition")
local item2 = cc.MenuItemFont:create( "Test pushScene w/transition")
item2:registerScriptTapHandler(onPushSceneTran)
local item3 = CCMenuItemFont:create( "Quit")
local item3 = cc.MenuItemFont:create( "Quit")
item3:registerScriptTapHandler(onQuit)
local arr = CCArray:create()
arr:addObject(item1)
arr:addObject(item2)
arr:addObject(item3)
local menu = CCMenu:createWithArray(arr)
local menu = cc.Menu:create(item1, item2, item3)
menu:alignItemsVertically()
ret:addChild( menu )
local s = CCDirector:getInstance():getWinSize()
local sprite = CCSprite:create(s_pPathGrossini)
local s = cc.Director:getInstance():getWinSize()
local sprite = cc.Sprite:create(s_pPathGrossini)
ret:addChild(sprite)
sprite:setPosition( CCPoint(s.width-40, s.height/2) )
local rotate = CCRotateBy:create(2, 360)
local repeatAction = CCRepeatForever:create(rotate)
sprite:setPosition( cc.p(s.width-40, s.height/2) )
local rotate = cc.RotateBy:create(2, 360)
local repeatAction = cc.RepeatForever:create(rotate)
sprite:runAction(repeatAction)
local function onNodeEvent(event)
@ -82,51 +78,47 @@ end
--------------------------------------------------------------------
SceneTestLayer2 = function()
local ret = CCLayer:create()
local ret = cc.Layer:create()
local m_timeCounter = 0
local function onGoBack(tag, pSender)
CCDirector:getInstance():popScene()
cc.Director:getInstance():popScene()
end
local function onReplaceScene(tag, pSender)
local scene = CCScene:create()
local scene = cc.Scene:create()
local layer = SceneTestLayer3()
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
CCDirector:getInstance():replaceScene( scene )
cc.Director:getInstance():replaceScene( scene )
end
local function onReplaceSceneTran(tag, pSender)
local scene = CCScene:create()
local scene = cc.Scene:create()
local layer = SceneTestLayer3()
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
CCDirector:getInstance():replaceScene( CCTransitionFlipX:create(2, scene) )
cc.Director:getInstance():replaceScene( cc.TransitionFlipX:create(2, scene) )
end
local item1 = CCMenuItemFont:create( "replaceScene")
local item1 = cc.MenuItemFont:create( "replaceScene")
item1:registerScriptTapHandler(onReplaceScene)
local item2 = CCMenuItemFont:create( "replaceScene w/transition")
local item2 = cc.MenuItemFont:create( "replaceScene w/transition")
item2:registerScriptTapHandler(onReplaceSceneTran)
local item3 = CCMenuItemFont:create( "Go Back")
local item3 = cc.MenuItemFont:create( "Go Back")
item3:registerScriptTapHandler(onGoBack)
local arr = CCArray:create()
arr:addObject(item1)
arr:addObject(item2)
arr:addObject(item3)
local menu = CCMenu:createWithArray(arr)
local menu = cc.Menu:create(item1, item2, item3)
menu:alignItemsVertically()
ret:addChild( menu )
local s = CCDirector:getInstance():getWinSize()
local sprite = CCSprite:create(s_pPathGrossini)
local s = cc.Director:getInstance():getWinSize()
local sprite = cc.Sprite:create(s_pPathGrossini)
ret:addChild(sprite)
sprite:setPosition( CCPoint(s.width-40, s.height/2) )
local rotate = CCRotateBy:create(2, 360)
local repeat_action = CCRepeatForever:create(rotate)
sprite:setPosition( cc.p(s.width-40, s.height/2) )
local rotate = cc.RotateBy:create(2, 360)
local repeat_action = cc.RepeatForever:create(rotate)
sprite:runAction(repeat_action)
return ret
@ -139,44 +131,39 @@ end
--------------------------------------------------------------------
SceneTestLayer3 = function()
local ret = CCLayerColor:create(Color4B(0,0,255,255))
local s = CCDirector:getInstance():getWinSize()
local ret = cc.LayerColor:create(cc.c4b(0,0,255,255))
local s = cc.Director:getInstance():getWinSize()
local function item0Clicked(tag, pSender)
local newScene = CCScene:create()
local newScene = cc.Scene:create()
newScene:addChild(SceneTestLayer3())
CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, newScene, Color3B(0,255,255)))
cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, newScene, cc.c3b(0,255,255)))
end
local function item1Clicked(tag, pSender)
CCDirector:getInstance():popScene()
cc.Director:getInstance():popScene()
end
local function item2Clicked(tag, pSender)
CCDirector:getInstance():popToRootScene()
cc.Director:getInstance():popToRootScene()
end
local item0 = CCMenuItemFont:create("Touch to pushScene (self)")
local item0 = cc.MenuItemFont:create("Touch to pushScene (self)")
item0:registerScriptTapHandler(item0Clicked)
local item1 = CCMenuItemFont:create("Touch to popScene")
local item1 = cc.MenuItemFont:create("Touch to popScene")
item1:registerScriptTapHandler(item1Clicked)
local item2 = CCMenuItemFont:create("Touch to popToRootScene")
local item2 = cc.MenuItemFont:create("Touch to popToRootScene")
item2:registerScriptTapHandler(item2Clicked)
local arr = CCArray:create()
arr:addObject(item0)
arr:addObject(item1)
arr:addObject(item2)
local menu = CCMenu:createWithArray(arr)
local menu = cc.Menu:create(item0, item1, item2)
ret:addChild(menu)
menu:alignItemsVertically()
local sprite = CCSprite:create(s_pPathGrossini)
local sprite = cc.Sprite:create(s_pPathGrossini)
ret:addChild(sprite)
sprite:setPosition( CCPoint(s.width/2, 40) )
local rotate = CCRotateBy:create(2, 360)
local repeatAction = CCRepeatForever:create(rotate)
sprite:setPosition( cc.p(s.width/2, 40) )
local rotate = cc.RotateBy:create(2, 360)
local repeatAction = cc.RepeatForever:create(rotate)
sprite:runAction(repeatAction)
return ret
end
@ -185,7 +172,7 @@ end
function SceneTestMain()
cclog("SceneTestMain")
local scene = CCScene:create()
local scene = cc.Scene:create()
local layer = SceneTestLayer1()
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())

View File

@ -4,12 +4,12 @@ require "luaScript/VisibleRect"
require "luaScript/TouchesTest/Paddle"
Ball = class("Ball", function(texture)
return CCSprite:createWithTexture(texture)
return cc.Sprite:createWithTexture(texture)
end)
Ball.__index = Ball
Ball.m_velocity = CCPoint(0,0)
Ball.m_velocity = cc.p(0,0)
local M_PI = 3.1415926
@ -19,56 +19,56 @@ function Ball:radius()
end
function Ball:move(delta)
local getPosition = CCPoint(self:getPosition())
local position = CCPoint.__mul(self.m_velocity, delta)
self:setPosition( CCPoint.__add(getPosition, position) );
local getPosition = cc.p(self:getPosition())
local position = cc.pMul(self.m_velocity, delta)
self:setPosition( cc.pAdd(getPosition, position) )
if (getPosition.x > VisibleRect:right().x - self:radius()) then
self:setPosition( CCPoint( VisibleRect:right().x - self:radius(), getPosition.y) );
self.m_velocity.x = self.m_velocity.x * -1;
self:setPosition( cc.p( VisibleRect:right().x - self:radius(), getPosition.y) )
self.m_velocity.x = self.m_velocity.x * -1
elseif (getPosition.x < VisibleRect:left().x + self:radius()) then
self:setPosition( CCPoint(VisibleRect:left().x + self:radius(), getPosition.y) );
self.m_velocity.x = self.m_velocity.x * -1;
self:setPosition( cc.p(VisibleRect:left().x + self:radius(), getPosition.y) )
self.m_velocity.x = self.m_velocity.x * -1
end
end
function Ball:collideWithPaddle(paddle)
local paddleRect = paddle:rect()
local paddleGetPosition = CCPoint(paddle:getPosition())
local selfGetPosition = CCPoint(self:getPosition())
local paddleGetPosition = cc.p(paddle:getPosition())
local selfGetPosition = cc.p(self:getPosition())
paddleRect.origin.x = paddleRect.origin.x + paddleGetPosition.x;
paddleRect.origin.y = paddleRect.origin.y + paddleGetPosition.y;
paddleRect.x = paddleRect.x + paddleGetPosition.x
paddleRect.y = paddleRect.y + paddleGetPosition.y
local lowY = paddleRect:getMinY();
local midY = paddleRect:getMidY();
local highY = paddleRect:getMaxY();
local lowY = cc.rectGetMinY(paddleRect)
local midY = cc.rectGetMidY(paddleRect)
local highY = cc.rectGetMaxY(paddleRect)
local leftX = paddleRect:getMinX();
local rightX = paddleRect:getMaxX();
local leftX = cc.rectGetMinX(paddleRect)
local rightX = cc.rectGetMaxX(paddleRect)
if (selfGetPosition.x > leftX and selfGetPosition.x < rightX) then
local hit = false;
local angleOffset = 0.0;
local hit = false
local angleOffset = 0.0
if (selfGetPosition.y > midY and selfGetPosition.y <= highY + self:radius()) then
self:setPosition( CCPoint(selfGetPosition.x, highY + self:radius()) );
hit = true;
angleOffset = M_PI / 2;
self:setPosition( cc.p(selfGetPosition.x, highY + self:radius()) )
hit = true
angleOffset = M_PI / 2
elseif (selfGetPosition.y < midY and selfGetPosition.y >= lowY - self:radius()) then
self:setPosition( CCPoint(selfGetPosition.x, lowY - self:radius()) );
hit = true;
angleOffset = -M_PI / 2;
self:setPosition( cc.p(selfGetPosition.x, lowY - self:radius()) )
hit = true
angleOffset = -M_PI / 2
end
if (hit) then
local hitAngle = (CCPoint.__sub(paddleGetPosition, paddleGetPosition)):getAngle() + angleOffset;
local hitAngle = cc.pToAngleSelf(cc.pSub(paddleGetPosition, paddleGetPosition)) + angleOffset
local scalarVelocity = (self.m_velocity):getLength() * 1.05;
local velocityAngle = -(self.m_velocity):getAngle() + 0.5 * hitAngle;
local scalarVelocity = cc.pGetLength(self.m_velocity) * 1.05
local velocityAngle = -cc.pToAngleSelf(self.m_velocity) + 0.5 * hitAngle
self.m_velocity = CCPoint.__mul(CCPoint:forAngle(velocityAngle), scalarVelocity);
self.m_velocity = cc.pMul(cc.pForAngle(velocityAngle), scalarVelocity)
end
end
@ -89,7 +89,7 @@ function Ball.ballWithTexture(aTexture)
end
local ball = Ball.new(aTexture)
ball:autorelease()
--ball:autorelease()
return ball
end

View File

@ -2,7 +2,7 @@ require "luaScript/extern"
require "luaScript/VisibleRect"
Paddle = class("Paddle", function(texture)
return CCSprite:createWithTexture(texture)
return cc.Sprite:createWithTexture(texture)
end)
Paddle.__index = Paddle
@ -15,14 +15,14 @@ Paddle.m_state = kPaddleStateGrabbed
function Paddle:rect()
local s = self:getTexture():getContentSize()
return CCRect(-s.width / 2, -s.height / 2, s.width, s.height)
return cc.rect(-s.width / 2, -s.height / 2, s.width, s.height)
end
function Paddle:containsTouchLocation(x,y)
local position = CCPoint(self:getPosition())
local position = cc.p(self:getPosition())
local s = self:getTexture():getContentSize()
local touchRect = CCRect(-s.width / 2 + position.x, -s.height / 2 + position.y, s.width, s.height)
local b = touchRect:containsPoint(CCPoint(x,y))
local touchRect = cc.rect(-s.width / 2 + position.x, -s.height / 2 + position.y, s.width, s.height)
local b = cc.rectContainsPoint(touchRect, cc.p(x,y))
return b
end
@ -36,7 +36,7 @@ function Paddle:ccTouchBegan(x, y)
end
function Paddle:ccTouchMoved(x, y)
self:setPosition( CCPoint(x,y) );
self:setPosition( cc.p(x,y) );
end
function Paddle:ccTouchEnded(x, y)

View File

@ -16,14 +16,14 @@ local m_paddles = {}
local layer = nil
local function backCallback(sender)
local scene = CCScene:create()
local scene = cc.Scene:create()
scene:addChild(CreateBackMenuItem())
CCDirector:getInstance():replaceScene(scene)
cc.Director:getInstance():replaceScene(scene)
end
local function resetAndScoreBallForPlayer(player)
m_ballStartingVelocity = CCPoint.__mul(m_ballStartingVelocity, -1.1);
m_ballStartingVelocity = cc.pMul(m_ballStartingVelocity, -1.1);
m_ball:setVelocity( m_ballStartingVelocity );
m_ball:setPosition( VisibleRect:center() );
end
@ -39,7 +39,7 @@ local function doStep(delta)
m_ball:collideWithPaddle( paddle );
end
local ballPosition = CCPoint(m_ball:getPosition())
local ballPosition = cc.p(m_ball:getPosition())
if (ballPosition.y > VisibleRect:top().y - kStatusBarHeight + m_ball:radius()) then
resetAndScoreBallForPlayer( kLowPlayer );
elseif (ballPosition.y < VisibleRect:bottom().y-m_ball:radius()) then
@ -60,10 +60,10 @@ local function onTouch(event, x, y)
end
local function CreateTouchesLayer()
layer = CCLayer:create()
layer = cc.Layer:create()
m_ballStartingVelocity = CCPoint(20.0, -100.0);
local mgr = CCTextureCache:getInstance()
m_ballStartingVelocity = cc.p(20.0, -100.0);
local mgr = cc.TextureCache:getInstance()
local texture = mgr:addImage(s_Ball)
m_ball = Ball.ballWithTexture(texture);
@ -72,24 +72,24 @@ local function CreateTouchesLayer()
layer:addChild( m_ball );
m_ball:retain();
local paddleTexture = CCTextureCache:getInstance():addImage(s_Paddle);
local paddleTexture = cc.TextureCache:getInstance():addImage(s_Paddle);
local paddlesM = {}
local paddle = Paddle:paddleWithTexture(paddleTexture);
paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:bottom().y + 15) );
paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:bottom().y + 15) );
paddlesM[#paddlesM+1] = paddle
paddle = Paddle:paddleWithTexture( paddleTexture );
paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 15) );
paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 15) );
paddlesM[#paddlesM+1] = paddle
paddle = Paddle:paddleWithTexture( paddleTexture );
paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:bottom().y + 100) );
paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:bottom().y + 100) );
paddlesM[#paddlesM+1] = paddle
paddle = Paddle:paddleWithTexture( paddleTexture );
paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 100) );
paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 100) );
paddlesM[#paddlesM+1] = paddle
m_paddles = paddlesM
@ -117,7 +117,7 @@ local function nextAction()
end
function TouchesTest()
local scene = CCScene:create()
local scene = cc.Scene:create()
scene:addChild(nextAction())
scene:addChild(CreateBackMenuItem())
return scene

View File

@ -4,7 +4,7 @@ require "luaScript/TransitionsTest/TransitionsName"
local SceneIdx = -1
local CurSceneNo = 2
local TRANSITION_DURATION = 1.2
local s = CCDirector:getInstance():getWinSize()
local s = cc.Director:getInstance():getWinSize()
local function switchSceneTypeNo()
if CurSceneNo == 1 then
@ -38,56 +38,56 @@ end
local function backCallback(sender)
local scene = backAction()
CCDirector:getInstance():replaceScene(scene)
cc.Director:getInstance():replaceScene(scene)
end
local function restartCallback(sender)
local scene = restartAction()
CCDirector:getInstance():replaceScene(scene)
cc.Director:getInstance():replaceScene(scene)
end
local function nextCallback(sender)
local scene = nextAction()
CCDirector:getInstance():replaceScene(scene)
cc.Director:getInstance():replaceScene(scene)
end
-----------------------------
-- TestLayer1
-----------------------------
local function createLayer1()
local layer = CCLayer:create()
local layer = cc.Layer:create()
local x, y = s.width, s.height
local bg1 = CCSprite:create(s_back1)
bg1:setPosition(CCPoint(s.width / 2, s.height / 2))
local bg1 = cc.Sprite:create(s_back1)
bg1:setPosition(cc.p(s.width / 2, s.height / 2))
layer:addChild(bg1, -1)
local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32)
local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32)
layer:addChild(titleLabel)
titleLabel:setColor(Color3B(255,32,32))
titleLabel:setColor(cc.c3b(255,32,32))
titleLabel:setPosition(x / 2, y - 100)
local label = CCLabelTTF:create("SCENE 1", "Marker Felt", 38)
label:setColor(Color3B(16,16,255))
local label = cc.LabelTTF:create("SCENE 1", "Marker Felt", 38)
label:setColor(cc.c3b(16,16,255))
label:setPosition(x / 2, y / 2)
layer:addChild(label)
-- menu
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:setPosition(CCPoint(0, 0))
item1:setPosition(CCPoint(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item2:setPosition(CCPoint(s.width / 2, item2:getContentSize().height / 2))
item3:setPosition(CCPoint(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
menu:setPosition(cc.p(0, 0))
item1:setPosition(cc.p(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item2:setPosition(cc.p(s.width / 2, item2:getContentSize().height / 2))
item3:setPosition(cc.p(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
layer:addChild(menu, 1)
@ -98,39 +98,39 @@ end
-- TestLayer2
-----------------------------
local function createLayer2()
local layer = CCLayer:create()
local layer = cc.Layer:create()
local x, y = s.width, s.height
local bg1 = CCSprite:create(s_back2)
bg1:setPosition(CCPoint(s.width / 2, s.height / 2))
local bg1 = cc.Sprite:create(s_back2)
bg1:setPosition(cc.p(s.width / 2, s.height / 2))
layer:addChild(bg1, -1)
local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 )
local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 )
layer:addChild(titleLabel)
titleLabel:setColor(Color3B(255,32,32))
titleLabel:setColor(cc.c3b(255,32,32))
titleLabel:setPosition(x / 2, y - 100)
local label = CCLabelTTF:create("SCENE 2", "Marker Felt", 38)
label:setColor(Color3B(16,16,255))
local label = cc.LabelTTF:create("SCENE 2", "Marker Felt", 38)
label:setColor(cc.c3b(16,16,255))
label:setPosition(x / 2, y / 2)
layer:addChild(label)
-- menu
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
local menu = CCMenu:create()
local menu = cc.Menu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:setPosition(CCPoint(0, 0))
item1:setPosition(CCPoint(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item2:setPosition(CCPoint(s.width / 2, item2:getContentSize().height / 2))
item3:setPosition(CCPoint(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
menu:setPosition(cc.p(0, 0))
item1:setPosition(cc.p(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item2:setPosition(cc.p(s.width / 2, item2:getContentSize().height / 2))
item3:setPosition(cc.p(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
layer:addChild(menu, 1)
@ -141,7 +141,7 @@ end
-- Create Transition Test
-----------------------------
local function createTransition(index, t, scene)
CCDirector:getInstance():setDepthTest(false)
cc.Director:getInstance():setDepthTest(false)
if firstEnter == true then
firstEnter = false
@ -149,96 +149,96 @@ local function createTransition(index, t, scene)
end
if index == Transition_Table.CCTransitionJumpZoom then
scene = CCTransitionJumpZoom:create(t, scene)
scene = cc.TransitionJumpZoom:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressRadialCCW then
scene = CCTransitionProgressRadialCCW:create(t, scene)
scene = cc.TransitionProgressRadialCCW:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressRadialCW then
scene = CCTransitionProgressRadialCW:create(t, scene)
scene = cc.TransitionProgressRadialCW:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressHorizontal then
scene = CCTransitionProgressHorizontal:create(t, scene)
scene = cc.TransitionProgressHorizontal:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressVertical then
scene = CCTransitionProgressVertical:create(t, scene)
scene = cc.TransitionProgressVertical:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressInOut then
scene = CCTransitionProgressInOut:create(t, scene)
scene = cc.TransitionProgressInOut:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressOutIn then
scene = CCTransitionProgressOutIn:create(t, scene)
scene = cc.TransitionProgressOutIn:create(t, scene)
elseif index == Transition_Table.CCTransitionCrossFade then
scene = CCTransitionCrossFade:create(t, scene)
scene = cc.TransitionCrossFade:create(t, scene)
elseif index == Transition_Table.TransitionPageForward then
CCDirector:getInstance():setDepthTest(true)
scene = CCTransitionPageTurn:create(t, scene, false)
cc.Director:getInstance():setDepthTest(true)
scene = cc.TransitionPageTurn:create(t, scene, false)
elseif index == Transition_Table.TransitionPageBackward then
CCDirector:getInstance():setDepthTest(true)
scene = CCTransitionPageTurn:create(t, scene, true)
cc.Director:getInstance():setDepthTest(true)
scene = cc.TransitionPageTurn:create(t, scene, true)
elseif index == Transition_Table.CCTransitionFadeTR then
scene = CCTransitionFadeTR:create(t, scene)
scene = cc.TransitionFadeTR:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeBL then
scene = CCTransitionFadeBL:create(t, scene)
scene = cc.TransitionFadeBL:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeUp then
scene = CCTransitionFadeUp:create(t, scene)
scene = cc.TransitionFadeUp:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeDown then
scene = CCTransitionFadeDown:create(t, scene)
scene = cc.TransitionFadeDown:create(t, scene)
elseif index == Transition_Table.CCTransitionTurnOffTiles then
scene = CCTransitionTurnOffTiles:create(t, scene)
scene = cc.TransitionTurnOffTiles:create(t, scene)
elseif index == Transition_Table.CCTransitionSplitRows then
scene = CCTransitionSplitRows:create(t, scene)
scene = cc.TransitionSplitRows:create(t, scene)
elseif index == Transition_Table.CCTransitionSplitCols then
scene = CCTransitionSplitCols:create(t, scene)
scene = cc.TransitionSplitCols:create(t, scene)
elseif index == Transition_Table.CCTransitionFade then
scene = CCTransitionFade:create(t, scene)
scene = cc.TransitionFade:create(t, scene)
elseif index == Transition_Table.FadeWhiteTransition then
scene = CCTransitionFade:create(t, scene, Color3B(255, 255, 255))
scene = cc.TransitionFade:create(t, scene, cc.c3b(255, 255, 255))
elseif index == Transition_Table.FlipXLeftOver then
scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationLeftOver)
scene = cc.TransitionFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER )
elseif index == Transition_Table.FlipXRightOver then
scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationRightOver)
scene = cc.TransitionFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER )
elseif index == Transition_Table.FlipYUpOver then
scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationUpOver)
scene = cc.TransitionFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_UP_OVER)
elseif index == Transition_Table.FlipYDownOver then
scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationDownOver)
scene = cc.TransitionFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_DOWN_OVER )
elseif index == Transition_Table.FlipAngularLeftOver then
scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver)
scene = cc.TransitionFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER )
elseif index == Transition_Table.FlipAngularRightOver then
scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationRightOver)
scene = cc.TransitionFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER )
elseif index == Transition_Table.ZoomFlipXLeftOver then
scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationLeftOver)
scene = cc.TransitionZoomFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER )
elseif index == Transition_Table.ZoomFlipXRightOver then
scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationRightOver)
scene = cc.TransitionZoomFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER )
elseif index == Transition_Table.ZoomFlipYUpOver then
scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationUpOver)
scene = cc.TransitionZoomFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_UP_OVER)
elseif index == Transition_Table.ZoomFlipYDownOver then
scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationDownOver)
scene = cc.TransitionZoomFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_DOWN_OVER )
elseif index == Transition_Table.ZoomFlipAngularLeftOver then
scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver)
scene = cc.TransitionZoomFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER )
elseif index == Transition_Table.ZoomFlipAngularRightOver then
scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationRightOver)
scene = cc.TransitionZoomFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER )
elseif index == Transition_Table.CCTransitionShrinkGrow then
scene = CCTransitionShrinkGrow:create(t, scene)
scene = cc.TransitionShrinkGrow:create(t, scene)
elseif index == Transition_Table.CCTransitionRotoZoom then
scene = CCTransitionRotoZoom:create(t, scene)
scene = cc.TransitionRotoZoom:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInL then
scene = CCTransitionMoveInL:create(t, scene)
scene = cc.TransitionMoveInL:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInR then
scene = CCTransitionMoveInR:create(t, scene)
scene = cc.TransitionMoveInR:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInT then
scene = CCTransitionMoveInT:create(t, scene)
scene = cc.TransitionMoveInT:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInB then
scene = CCTransitionMoveInB:create(t, scene)
scene = cc.TransitionMoveInB:create(t, scene)
elseif index == Transition_Table.CCTransitionSlideInL then
scene = CCTransitionSlideInL:create(t, scene)
scene = cc.TransitionSlideInL:create(t, scene)
elseif index == Transition_Table.CCTransitionSlideInR then
scene = CCTransitionSlideInR:create(t, scene)
scene = cc.TransitionSlideInR:create(t, scene)
elseif index == Transition_Table.CCTransitionSlideInT then
scene = CCTransitionSlideInT:create(t, scene)
scene = cc.TransitionSlideInT:create(t, scene)
elseif index == Transition_Table.CCTransitionSlideInB then
scene = CCTransitionSlideInB:create(t, scene)
scene = cc.TransitionSlideInB:create(t, scene)
end
return scene
end
function generateTranScene()
local scene = CCScene:create()
local scene = cc.Scene:create()
local layer = nil
if CurSceneNo == 1 then
@ -255,7 +255,7 @@ end
function TransitionsTest()
cclog("TransitionsTest")
local scene = CCScene:create()
local scene = cc.Scene:create()
SceneIdx = -1
CurSceneNo = 2

View File

@ -6,62 +6,62 @@ local function doTest()
-- set default value
CCUserDefault:getInstance():setStringForKey("string", "value1")
CCUserDefault:getInstance():setIntegerForKey("integer", 10)
CCUserDefault:getInstance():setFloatForKey("float", 2.3)
CCUserDefault:getInstance():setDoubleForKey("double", 2.4)
CCUserDefault:getInstance():setBoolForKey("bool", true)
cc.UserDefault:getInstance():setStringForKey("string", "value1")
cc.UserDefault:getInstance():setIntegerForKey("integer", 10)
cc.UserDefault:getInstance():setFloatForKey("float", 2.3)
cc.UserDefault:getInstance():setDoubleForKey("double", 2.4)
cc.UserDefault:getInstance():setBoolForKey("bool", true)
-- print value
local ret = CCUserDefault:getInstance():getStringForKey("string")
local ret = cc.UserDefault:getInstance():getStringForKey("string")
cclog("string is %s", ret)
local d = CCUserDefault:getInstance():getDoubleForKey("double")
local d = cc.UserDefault:getInstance():getDoubleForKey("double")
cclog("double is %f", d)
local i = CCUserDefault:getInstance():getIntegerForKey("integer")
local i = cc.UserDefault:getInstance():getIntegerForKey("integer")
cclog("integer is %d", i)
local f = CCUserDefault:getInstance():getFloatForKey("float")
local f = cc.UserDefault:getInstance():getFloatForKey("float")
cclog("float is %f", f)
local b = CCUserDefault:getInstance():getBoolForKey("bool")
local b = cc.UserDefault:getInstance():getBoolForKey("bool")
if b == true then
cclog("bool is true")
else
cclog("bool is false")
end
--CCUserDefault:getInstance():flush()
--cc.UserDefault:getInstance():flush()
cclog("********************** after change value ***********************")
-- change the value
CCUserDefault:getInstance():setStringForKey("string", "value2")
CCUserDefault:getInstance():setIntegerForKey("integer", 11)
CCUserDefault:getInstance():setFloatForKey("float", 2.5)
CCUserDefault:getInstance():setDoubleForKey("double", 2.6)
CCUserDefault:getInstance():setBoolForKey("bool", false)
cc.UserDefault:getInstance():setStringForKey("string", "value2")
cc.UserDefault:getInstance():setIntegerForKey("integer", 11)
cc.UserDefault:getInstance():setFloatForKey("float", 2.5)
cc.UserDefault:getInstance():setDoubleForKey("double", 2.6)
cc.UserDefault:getInstance():setBoolForKey("bool", false)
CCUserDefault:getInstance():flush()
cc.UserDefault:getInstance():flush()
-- print value
ret = CCUserDefault:getInstance():getStringForKey("string")
ret = cc.UserDefault:getInstance():getStringForKey("string")
cclog("string is %s", ret)
d = CCUserDefault:getInstance():getDoubleForKey("double")
d = cc.UserDefault:getInstance():getDoubleForKey("double")
cclog("double is %f", d)
i = CCUserDefault:getInstance():getIntegerForKey("integer")
i = cc.UserDefault:getInstance():getIntegerForKey("integer")
cclog("integer is %d", i)
f = CCUserDefault:getInstance():getFloatForKey("float")
f = cc.UserDefault:getInstance():getFloatForKey("float")
cclog("float is %f", f)
b = CCUserDefault:getInstance():getBoolForKey("bool")
b = cc.UserDefault:getInstance():getBoolForKey("bool")
if b == true then
cclog("bool is true")
else
@ -70,11 +70,11 @@ local function doTest()
end
function UserDefaultTestMain()
local ret = CCScene:create()
local s = CCDirector:getInstance():getWinSize()
local label = CCLabelTTF:create("CCUserDefault test see log", "Arial", 28)
local ret = cc.Scene:create()
local s = cc.Director:getInstance():getWinSize()
local label = cc.LabelTTF:create("UserDefault test see log", "Arial", 28)
ret:addChild(label, 0)
label:setPosition( CCPoint(s.width/2, s.height-50) )
label:setPosition( cc.p(s.width/2, s.height-50) )
doTest()
return ret
end

View File

@ -1,4 +1,4 @@
local scheduler = CCDirector:getInstance():getScheduler()
local scheduler = cc.Director:getInstance():getScheduler()
--------------------------------------------------------------------
--
-- ZwoptexGenericTest
@ -9,33 +9,33 @@ local function ZwoptexGenericTest()
"Coordinate Formats, Rotation, Trimming, flipX/Y")
local spriteFrameIndex = 0
local counter = 0
local s = CCDirector:getInstance():getWinSize()
local s = cc.Director:getInstance():getWinSize()
local schedulerEntry = nil
local schedulerFlipSpriteEntry = nil
local sprite1 = nil
local sprite2 = nil
local function onEnter()
CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini.plist")
CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini-generic.plist")
cc.SpriteFrameCache:getInstance():addSpriteFrames("zwoptex/grossini.plist")
cc.SpriteFrameCache:getInstance():addSpriteFrames("zwoptex/grossini-generic.plist")
local layer1 = CCLayerColor:create(Color4B(255, 0, 0, 255), 85, 121)
layer1:setPosition(CCPoint(s.width/2-80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5)))
local layer1 = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 85, 121)
layer1:setPosition(cc.p(s.width/2-80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5)))
ret:addChild(layer1)
sprite1 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName("grossini_dance_01.png"))
sprite1:setPosition(CCPoint( s.width/2-80, s.height/2))
sprite1 = cc.Sprite:createWithSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame("grossini_dance_01.png"))
sprite1:setPosition(cc.p( s.width/2-80, s.height/2))
ret:addChild(sprite1)
sprite1:setFlipX(false)
sprite1:setFlipY(false)
local layer2 = CCLayerColor:create(Color4B(255, 0, 0, 255), 85, 121)
layer2:setPosition(CCPoint(s.width/2+80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5)))
local layer2 = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 85, 121)
layer2:setPosition(cc.p(s.width/2+80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5)))
ret:addChild(layer2)
sprite2 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName("grossini_dance_generic_01.png"))
sprite2:setPosition(CCPoint( s.width/2 + 80, s.height/2))
sprite2 = cc.Sprite:createWithSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame("grossini_dance_generic_01.png"))
sprite2:setPosition(cc.p( s.width/2 + 80, s.height/2))
ret:addChild(sprite2)
sprite2:setFlipX(false)
@ -74,8 +74,8 @@ local function ZwoptexGenericTest()
local str1 = string.format("grossini_dance_%02d.png", spriteFrameIndex)
local str2 = string.format("grossini_dance_generic_%02d.png", spriteFrameIndex)
sprite1:setDisplayFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName(str1))
sprite2:setDisplayFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName(str2))
sprite1:setDisplayFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str1))
sprite2:setDisplayFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str2))
end
sprite1:retain()
@ -97,7 +97,7 @@ local function ZwoptexGenericTest()
end
sprite1:release()
sprite2:release()
local cache = CCSpriteFrameCache:getInstance()
local cache = cc.SpriteFrameCache:getInstance()
cache:removeSpriteFramesFromFile("zwoptex/grossini.plist")
cache:removeSpriteFramesFromFile("zwoptex/grossini-generic.plist")
end
@ -118,7 +118,7 @@ end
function ZwoptexTestMain()
cclog("ZwoptexTestMain")
Helper.index = 1
local scene = CCScene:create()
local scene = cc.Scene:create()
Helper.createFunctionTable = {
ZwoptexGenericTest
}

View File

@ -60,16 +60,16 @@ function class(classname, super)
end
function schedule(node, callback, delay)
local delay = CCDelayTime:create(delay)
local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback))
local action = CCRepeatForever:create(sequence)
local delay = cc.DelayTime:create(delay)
local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback))
local action = cc.RepeatForever:create(sequence)
node:runAction(action)
return action
end
function performWithDelay(node, callback, delay)
local delay = CCDelayTime:create(delay)
local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback))
local delay = cc.DelayTime:create(delay)
local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback))
node:runAction(sequence)
return sequence
end

View File

@ -8,6 +8,7 @@ require "luaScript/helper"
require "luaScript/testResource"
require "luaScript/VisibleRect"
require "luaScript/AccelerometerTest/AccelerometerTest"
require "luaScript/ActionManagerTest/ActionManagerTest"
require "luaScript/ActionsEaseTest/ActionsEaseTest"
require "luaScript/ActionsProgressTest/ActionsProgressTest"
@ -19,35 +20,30 @@ require "luaScript/CurrentLanguageTest/CurrentLanguageTest"
require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest"
require "luaScript/EffectsTest/EffectsTest"
require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest"
require "luaScript/ExtensionTest/ExtensionTest"
require "luaScript/FontTest/FontTest"
require "luaScript/IntervalTest/IntervalTest"
require "luaScript/KeypadTest/KeypadTest"
require "luaScript/LabelTest/LabelTest"
require "luaScript/LayerTest/LayerTest"
--[[
require "luaScript/TransitionsTest/TransitionsTest"
require "luaScript/RotateWorldTest/RotateWorldTest"
require "luaScript/ParticleTest/ParticleTest"
require "luaScript/MenuTest/MenuTest"
require "luaScript/MotionStreakTest/MotionStreakTest"
require "luaScript/NodeTest/NodeTest"
require "luaScript/TouchesTest/TouchesTest"
require "luaScript/SpriteTest/SpriteTest"
require "luaScript/PerformanceTest/PerformanceTest"
require "luaScript/OpenGLTest/OpenGLTest"
require "luaScript/ParallaxTest/ParallaxTest"
require "luaScript/TileMapTest/TileMapTest"
require "luaScript/MenuTest/MenuTest"
require "luaScript/ParticleTest/ParticleTest"
require "luaScript/PerformanceTest/PerformanceTest"
require "luaScript/RenderTextureTest/RenderTextureTest"
require "luaScript/RotateWorldTest/RotateWorldTest"
require "luaScript/SpriteTest/SpriteTest"
require "luaScript/SceneTest/SceneTest"
require "luaScript/Texture2dTest/Texture2dTest"
require "luaScript/RenderTextureTest/RenderTextureTest"
require "luaScript/ZwoptexTest/ZwoptexTest"
require "luaScript/TileMapTest/TileMapTest"
require "luaScript/TouchesTest/TouchesTest"
require "luaScript/TransitionsTest/TransitionsTest"
require "luaScript/UserDefaultTest/UserDefaultTest"
require "luaScript/ExtensionTest/ExtensionTest"
require "luaScript/AccelerometerTest/AccelerometerTest"
require "luaScript/OpenGLTest/OpenGLTest"
]]--
require "luaScript/ZwoptexTest/ZwoptexTest"
local LINE_SPACE = 40

View File

@ -49,6 +49,7 @@ extern "C" {
#include "lua_cocos2dx_auto.hpp"
#include "lua_cocos2dx_extension_auto.hpp"
#include "lua_cocos2dx_manual.hpp"
#include "LuaBasicConversions.h"
namespace {
int lua_print(lua_State * luastate)
@ -125,6 +126,7 @@ bool LuaStack::init(void)
{NULL, NULL}
};
luaL_register(_state, "_G", global_functions);
g_luaType.clear();
register_all_cocos2dx(_state);
tolua_opengl_open(_state);
register_all_cocos2dx_extension(_state);

View File

@ -23,9 +23,16 @@
****************************************************************************/
#include "LuaBasicConversions.h"
#ifdef __cplusplus
extern "C" {
#include "tolua++.h"
#endif
#include "tolua_fix.h"
#ifdef __cplusplus
}
#endif
std::map<int, std::string> g_luaType;
#if COCOS2D_DEBUG >=1
void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err)
@ -881,6 +888,50 @@ bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints
return ok;
}
bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret)
{
if (nullptr == L || argc == 0 )
return false;
bool ok = true;
Array* array = Array::create();
for (int i = 0; i < argc; i++)
{
double num = 0.0;
if (lua_isnumber(L, i + 2))
{
ok &= luaval_to_number(L, i + 2, &num);
if (!ok)
break;
array->addObject(Integer::create((int)num));
}
else if (lua_isstring(L, i + 2))
{
std::string str = lua_tostring(L, i + 2);
array->addObject(String::create(str));
}
else if (lua_isuserdata(L, i + 2))
{
tolua_Error err;
if (!tolua_isusertype(L, i + 2, "Object", 0, &err))
{
luaval_to_native_err(L,"#ferror:",&err);
ok = false;
break;
}
Object* obj = static_cast<Object*>(tolua_tousertype(L, i + 2, nullptr));
array->addObject(obj);
}
}
*ret = array;
return ok;
}
void point_to_luaval(lua_State* L,const Point& pt)
{
if (NULL == L)
@ -1064,171 +1115,171 @@ void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue)
void array_to_luaval(lua_State* L,Array* inValue)
{
if (NULL == L || NULL == inValue)
if (nullptr == L || nullptr == inValue)
return;
if (0 == inValue->count() )
return;
Object* obj = NULL;
Object* obj = nullptr;
lua_newtable(L);
std::string className = "";
int pos = 0;
String* strVal = NULL;
Dictionary* dictVal = NULL;
Array* arrVal = NULL;
Double* doubleVal = NULL;
Bool* boolVal = NULL;
Float* floatVal = NULL;
Integer* intVal = NULL;
String* strVal = nullptr;
Dictionary* dictVal = nullptr;
Array* arrVal = nullptr;
Double* doubleVal = nullptr;
Bool* boolVal = nullptr;
Float* floatVal = nullptr;
Integer* intVal = nullptr;
int indexTable = 1;
CCARRAY_FOREACH(inValue, obj)
{
if (NULL == obj)
if (nullptr == obj)
continue;
className = typeid(*obj).name();
pos = className.rfind(":");
if (pos > 0 && pos + 1 < className.length() )
uint32_t typeId = cocos2d::getHashCodeByString(typeid(*obj).name());
auto iter = g_luaType.find(typeId);
if (g_luaType.end() != iter)
{
className = className.substr(pos + 1, std::string::npos);
luaL_getmetatable(L, className.c_str()); /* stack: table mt */
if (!lua_isnil(L, -1))
className = iter->second;
if (nullptr != dynamic_cast<cocos2d::Object *>(obj))
{
lua_pop(L, 1);
tolua_pushusertype(L, (void*)obj, className.c_str());
}
else
{
lua_pop(L, -1);
if((strVal = dynamic_cast<cocos2d::String *>(obj)))
{
lua_pushstring(L, strVal->getCString());
}
else if ((dictVal = dynamic_cast<cocos2d::Dictionary*>(obj)))
{
dictionary_to_luaval(L, dictVal);
}
else if ((arrVal = dynamic_cast<cocos2d::Array*>(obj)))
{
array_to_luaval(L, arrVal);
}
else if ((doubleVal = dynamic_cast<Double*>(obj)))
{
lua_pushnumber(L, (lua_Number)doubleVal->getValue());
}
else if ((floatVal = dynamic_cast<Float*>(obj)))
{
lua_pushnumber(L, (lua_Number)floatVal->getValue());
}
else if ((intVal = dynamic_cast<Integer*>(obj)))
{
lua_pushinteger(L, (lua_Integer)intVal->getValue());
}
else if ((boolVal = dynamic_cast<Bool*>(obj)))
{
lua_pushboolean(L, boolVal->getValue());
} else
{
CCASSERT(false, "the type isn't suppored.");
}
lua_pushnumber(L, (lua_Number)indexTable);
int ID = (obj) ? (int)obj->_ID : -1;
int* luaID = (obj) ? &obj->_luaID : NULL;
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,className.c_str());
lua_rawset(L, -3);
obj->retain();
++indexTable;
}
}
else if((strVal = dynamic_cast<cocos2d::String *>(obj)))
{
lua_pushnumber(L, (lua_Number)indexTable);
lua_pushstring(L, strVal->getCString());
lua_rawset(L, -3);
++indexTable;
}
else if ((dictVal = dynamic_cast<cocos2d::Dictionary*>(obj)))
{
dictionary_to_luaval(L, dictVal);
}
else if ((arrVal = dynamic_cast<cocos2d::Array*>(obj)))
{
array_to_luaval(L, arrVal);
}
else if ((doubleVal = dynamic_cast<Double*>(obj)))
{
lua_pushnumber(L, (lua_Number)indexTable);
lua_pushnumber(L, (lua_Number)doubleVal->getValue());
lua_rawset(L, -3);
++indexTable;
}
else if ((floatVal = dynamic_cast<Float*>(obj)))
{
lua_pushnumber(L, (lua_Number)indexTable);
lua_pushnumber(L, (lua_Number)floatVal->getValue());
lua_rawset(L, -3);
++indexTable;
}
else if ((intVal = dynamic_cast<Integer*>(obj)))
{
lua_pushnumber(L, (lua_Number)indexTable);
lua_pushinteger(L, (lua_Integer)intVal->getValue());
lua_rawset(L, -3);
++indexTable;
}
else if ((boolVal = dynamic_cast<Bool*>(obj)))
{
lua_pushnumber(L, (lua_Number)indexTable);
lua_pushboolean(L, boolVal->getValue());
lua_rawset(L, -3);
++indexTable;
}
else
{
CCASSERT(false, "the type isn't suppored.");
}
}
}
void dictionary_to_luaval(lua_State* L, Dictionary* dict)
{
if (NULL == L || NULL == dict)
if (nullptr == L || nullptr == dict)
return;
if (0 == dict->count() )
return;
DictElement* element = NULL;
DictElement* element = nullptr;
lua_newtable(L);
std::string className = "";
int pos = 0;
String* strVal = NULL;
Dictionary* dictVal = NULL;
Array* arrVal = NULL;
Double* doubleVal = NULL;
Bool* boolVal = NULL;
Float* floatVal = NULL;
Integer* intVal = NULL;
Object* obj = NULL;
String* strVal = nullptr;
Dictionary* dictVal = nullptr;
Array* arrVal = nullptr;
Double* doubleVal = nullptr;
Bool* boolVal = nullptr;
Float* floatVal = nullptr;
Integer* intVal = nullptr;
CCDICT_FOREACH(dict, element)
{
if (NULL == element)
continue;
className = typeid(*element).name();
pos = className.rfind(":");
if (pos > 0 && pos + 1 < className.length() )
uint32_t typeId = cocos2d::getHashCodeByString(typeid(element->getObject()).name());
auto iter = g_luaType.find(typeId);
if (g_luaType.end() != iter)
{
obj = element->getObject();
if (NULL == obj)
continue;
className = className.substr(pos + 1, std::string::npos);
luaL_getmetatable(L, className.c_str()); /* stack: table mt */
if (!lua_isnil(L, -1))
className = iter->second;
if ( nullptr != dynamic_cast<cocos2d::Object *>(element->getObject()))
{
lua_pop(L, 1);
tolua_pushusertype(L, (void*)obj, className.c_str());
}
else
{
lua_pop(L, -1);
if((strVal = dynamic_cast<cocos2d::String *>(obj)))
{
lua_pushstring(L, element->getStrKey());
lua_pushstring(L, strVal->getCString());
lua_rawset(L, -3);
}
else if ((dictVal = dynamic_cast<cocos2d::Dictionary*>(obj)))
{
dictionary_to_luaval(L, dictVal);
}
else if ((arrVal = dynamic_cast<cocos2d::Array*>(obj)))
{
array_to_luaval(L, arrVal);
}
else if ((doubleVal = dynamic_cast<Double*>(obj)))
{
lua_pushstring(L, element->getStrKey());
lua_pushnumber(L, (lua_Number)doubleVal->getValue());
lua_rawset(L, -3);
}
else if ((floatVal = dynamic_cast<Float*>(obj)))
{
lua_pushstring(L, element->getStrKey());
lua_pushnumber(L, (lua_Number)floatVal->getValue());
lua_rawset(L, -3);
}
else if ((intVal = dynamic_cast<Integer*>(obj)))
{
lua_pushstring(L, element->getStrKey());
lua_pushinteger(L, (lua_Integer)intVal->getValue());
lua_rawset(L, -3);
}
else if ((boolVal = dynamic_cast<Bool*>(obj)))
{
lua_pushstring(L, element->getStrKey());
lua_pushboolean(L, boolVal->getValue());
lua_rawset(L, -3);
}
else
{
CCASSERT(false, "the type isn't suppored.");
}
lua_pushstring(L, element->getStrKey());
int ID = (element->getObject()) ? (int)element->getObject()->_ID : -1;
int* luaID = (element->getObject()) ? &(element->getObject()->_luaID) : NULL;
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)element->getObject(),className.c_str());
lua_rawset(L, -3);
element->getObject()->retain();
}
}
else if((strVal = dynamic_cast<cocos2d::String *>(element->getObject())))
{
lua_pushstring(L, element->getStrKey());
lua_pushstring(L, strVal->getCString());
lua_rawset(L, -3);
}
else if ((dictVal = dynamic_cast<cocos2d::Dictionary*>(element->getObject())))
{
dictionary_to_luaval(L, dictVal);
}
else if ((arrVal = dynamic_cast<cocos2d::Array*>(element->getObject())))
{
array_to_luaval(L, arrVal);
}
else if ((doubleVal = dynamic_cast<Double*>(element->getObject())))
{
lua_pushstring(L, element->getStrKey());
lua_pushnumber(L, (lua_Number)doubleVal->getValue());
lua_rawset(L, -3);
}
else if ((floatVal = dynamic_cast<Float*>(element->getObject())))
{
lua_pushstring(L, element->getStrKey());
lua_pushnumber(L, (lua_Number)floatVal->getValue());
lua_rawset(L, -3);
}
else if ((intVal = dynamic_cast<Integer*>(element->getObject())))
{
lua_pushstring(L, element->getStrKey());
lua_pushinteger(L, (lua_Integer)intVal->getValue());
lua_rawset(L, -3);
}
else if ((boolVal = dynamic_cast<Bool*>(element->getObject())))
{
lua_pushstring(L, element->getStrKey());
lua_pushboolean(L, boolVal->getValue());
lua_rawset(L, -3);
}
else
{
CCASSERT(false, "the type isn't suppored.");
}
}
}

View File

@ -3,12 +3,19 @@
extern "C" {
#include "lua.h"
#include "tolua++.h"
}
#include "cocos2d.h"
using namespace cocos2d;
extern std::map<int, std::string> g_luaType;
#if COCOS2D_DEBUG >=1
void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err);
#endif
// to native
extern bool luaval_to_int32(lua_State* L,int lo,int* outValue);
extern bool luaval_to_uint32(lua_State* L, int lo, unsigned int* outValue);
@ -29,6 +36,7 @@ extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outVa
extern bool luaval_to_array(lua_State* L,int lo, Array** outValue);
extern bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue);
extern bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints);
extern bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret);
// from native
extern void point_to_luaval(lua_State* L,const Point& pt);

View File

@ -1 +1 @@
faeffa101e0d6ba77fa19f3bd83b12a267209994
13bc27135b11b87249075c37897972a41802f216

View File

@ -1 +1 @@
2a962b5abd27e8a47e73534fe2e521e181cc64be
e29ba39a2c542d0e15e41231b795fadbdad66af3

View File

@ -1982,6 +1982,76 @@ int register_all_cocos2dx(lua_State* tolua_S);

View File

@ -1 +1 @@
4b98d069e4cc8f6af4dc2c64c6ec3fa2590bd927
171d6ef055d78d7211eb55d8a8de5eda09476d0a

View File

@ -1 +1 @@
a63246415c81d091a2eb88c4ba396b6d3c80c027
00379738c9ad94edf867bd46e85597812c340f29

View File

@ -246,6 +246,143 @@ int register_all_cocos2dx_extension(lua_State* tolua_S);

View File

@ -135,6 +135,12 @@ addOwnerOutletName : function () {},
*/
getOwnerCallbackNames : function () {},
/**
* @method addDocumentCallbackControlEvents
* @param {cocos2d::extension::Control::EventType}
*/
addDocumentCallbackControlEvents : function () {},
/**
* @method setCCBRootPath
* @param {const char*}
@ -166,6 +172,12 @@ readSoundKeyframesForSeq : function () {},
*/
getCCBRootPath : function () {},
/**
* @method getOwnerCallbackControlEvents
* @return A value converted from C/C++ "cocos2d::Array*"
*/
getOwnerCallbackControlEvents : function () {},
/**
* @method getOwnerOutletNodes
* @return A value converted from C/C++ "cocos2d::Array*"
@ -178,6 +190,12 @@ getOwnerOutletNodes : function () {},
*/
readUTF8 : function () {},
/**
* @method addOwnerCallbackControlEvents
* @param {cocos2d::extension::Control::EventType}
*/
addOwnerCallbackControlEvents : function () {},
/**
* @method getOwnerOutletNames
* @return A value converted from C/C++ "cocos2d::Array*"
@ -1062,6 +1080,13 @@ getLastCompletedSequenceName : function () {},
*/
setRootNode : function () {},
/**
* @method runAnimationsForSequenceNamedTweenDuration
* @param {const char*}
* @param {float}
*/
runAnimationsForSequenceNamedTweenDuration : function () {},
/**
* @method addDocumentOutletName
* @param {std::string}
@ -1106,6 +1131,12 @@ actionForCallbackChannel : function () {},
*/
getDocumentOutletNames : function () {},
/**
* @method addDocumentCallbackControlEvents
* @param {cocos2d::extension::Control::EventType}
*/
addDocumentCallbackControlEvents : function () {},
/**
* @method init
* @return A value converted from C/C++ "bool"
@ -1119,11 +1150,10 @@ init : function () {},
getKeyframeCallbacks : function () {},
/**
* @method runAnimationsForSequenceNamedTweenDuration
* @param {const char*}
* @param {float}
* @method getDocumentCallbackControlEvents
* @return A value converted from C/C++ "cocos2d::Array*"
*/
runAnimationsForSequenceNamedTweenDuration : function () {},
getDocumentCallbackControlEvents : function () {},
/**
* @method setRootContainerSize
@ -1232,6 +1262,828 @@ CCBAnimationManager : function () {},
};
/**
* @class ControlHuePicker
*/
cc.ControlHuePicker = {
/**
* @method setEnabled
* @param {bool}
*/
setEnabled : function () {},
/**
* @method initWithTargetAndPos
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Node*}
* @param {cocos2d::Point}
*/
initWithTargetAndPos : function () {},
/**
* @method setHue
* @param {float}
*/
setHue : function () {},
/**
* @method getStartPos
* @return A value converted from C/C++ "cocos2d::Point"
*/
getStartPos : function () {},
/**
* @method getHue
* @return A value converted from C/C++ "float"
*/
getHue : function () {},
/**
* @method ccTouchBegan
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchBegan : function () {},
/**
* @method setBackground
* @param {cocos2d::Sprite*}
*/
setBackground : function () {},
/**
* @method setHuePercentage
* @param {float}
*/
setHuePercentage : function () {},
/**
* @method getBackground
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getBackground : function () {},
/**
* @method ccTouchMoved
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchMoved : function () {},
/**
* @method getSlider
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getSlider : function () {},
/**
* @method getHuePercentage
* @return A value converted from C/C++ "float"
*/
getHuePercentage : function () {},
/**
* @method setSlider
* @param {cocos2d::Sprite*}
*/
setSlider : function () {},
/**
* @method create
* @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*"
* @param {cocos2d::Node*}
* @param {cocos2d::Point}
*/
create : function () {},
/**
* @method ControlHuePicker
* @constructor
*/
ControlHuePicker : function () {},
};
/**
* @class ControlSaturationBrightnessPicker
*/
cc.ControlSaturationBrightnessPicker = {
/**
* @method getShadow
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getShadow : function () {},
/**
* @method initWithTargetAndPos
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Node*}
* @param {cocos2d::Point}
*/
initWithTargetAndPos : function () {},
/**
* @method getStartPos
* @return A value converted from C/C++ "cocos2d::Point"
*/
getStartPos : function () {},
/**
* @method getOverlay
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getOverlay : function () {},
/**
* @method setEnabled
* @param {bool}
*/
setEnabled : function () {},
/**
* @method getSlider
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getSlider : function () {},
/**
* @method getBackground
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getBackground : function () {},
/**
* @method getSaturation
* @return A value converted from C/C++ "float"
*/
getSaturation : function () {},
/**
* @method getBrightness
* @return A value converted from C/C++ "float"
*/
getBrightness : function () {},
/**
* @method create
* @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*"
* @param {cocos2d::Node*}
* @param {cocos2d::Point}
*/
create : function () {},
/**
* @method ControlSaturationBrightnessPicker
* @constructor
*/
ControlSaturationBrightnessPicker : function () {},
};
/**
* @class ControlColourPicker
*/
cc.ControlColourPicker = {
/**
* @method setEnabled
* @param {bool}
*/
setEnabled : function () {},
/**
* @method getHuePicker
* @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*"
*/
getHuePicker : function () {},
/**
* @method setColor
* @param {cocos2d::Color3B}
*/
setColor : function () {},
/**
* @method hueSliderValueChanged
* @param {cocos2d::Object*}
* @param {cocos2d::extension::Control::EventType}
*/
hueSliderValueChanged : function () {},
/**
* @method getcolourPicker
* @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*"
*/
getcolourPicker : function () {},
/**
* @method setBackground
* @param {cocos2d::Sprite*}
*/
setBackground : function () {},
/**
* @method init
* @return A value converted from C/C++ "bool"
*/
init : function () {},
/**
* @method setcolourPicker
* @param {cocos2d::extension::ControlSaturationBrightnessPicker*}
*/
setcolourPicker : function () {},
/**
* @method colourSliderValueChanged
* @param {cocos2d::Object*}
* @param {cocos2d::extension::Control::EventType}
*/
colourSliderValueChanged : function () {},
/**
* @method setHuePicker
* @param {cocos2d::extension::ControlHuePicker*}
*/
setHuePicker : function () {},
/**
* @method getBackground
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getBackground : function () {},
/**
* @method create
* @return A value converted from C/C++ "cocos2d::extension::ControlColourPicker*"
*/
create : function () {},
/**
* @method ControlColourPicker
* @constructor
*/
ControlColourPicker : function () {},
};
/**
* @class ControlPotentiometer
*/
cc.ControlPotentiometer = {
/**
* @method setPreviousLocation
* @param {cocos2d::Point}
*/
setPreviousLocation : function () {},
/**
* @method setProgressTimer
* @param {cocos2d::ProgressTimer*}
*/
setProgressTimer : function () {},
/**
* @method potentiometerMoved
* @param {cocos2d::Point}
*/
potentiometerMoved : function () {},
/**
* @method ccTouchEnded
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchEnded : function () {},
/**
* @method getMinimumValue
* @return A value converted from C/C++ "float"
*/
getMinimumValue : function () {},
/**
* @method setThumbSprite
* @param {cocos2d::Sprite*}
*/
setThumbSprite : function () {},
/**
* @method ccTouchMoved
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchMoved : function () {},
/**
* @method ccTouchBegan
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchBegan : function () {},
/**
* @method setEnabled
* @param {bool}
*/
setEnabled : function () {},
/**
* @method setValue
* @param {float}
*/
setValue : function () {},
/**
* @method setMaximumValue
* @param {float}
*/
setMaximumValue : function () {},
/**
* @method setMinimumValue
* @param {float}
*/
setMinimumValue : function () {},
/**
* @method potentiometerEnded
* @param {cocos2d::Point}
*/
potentiometerEnded : function () {},
/**
* @method distanceBetweenPointAndPoint
* @return A value converted from C/C++ "float"
* @param {cocos2d::Point}
* @param {cocos2d::Point}
*/
distanceBetweenPointAndPoint : function () {},
/**
* @method getProgressTimer
* @return A value converted from C/C++ "cocos2d::ProgressTimer*"
*/
getProgressTimer : function () {},
/**
* @method getMaximumValue
* @return A value converted from C/C++ "float"
*/
getMaximumValue : function () {},
/**
* @method angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint
* @return A value converted from C/C++ "float"
* @param {cocos2d::Point}
* @param {cocos2d::Point}
* @param {cocos2d::Point}
* @param {cocos2d::Point}
*/
angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : function () {},
/**
* @method isTouchInside
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Touch*}
*/
isTouchInside : function () {},
/**
* @method getValue
* @return A value converted from C/C++ "float"
*/
getValue : function () {},
/**
* @method potentiometerBegan
* @param {cocos2d::Point}
*/
potentiometerBegan : function () {},
/**
* @method getThumbSprite
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getThumbSprite : function () {},
/**
* @method initWithTrackSprite_ProgressTimer_ThumbSprite
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Sprite*}
* @param {cocos2d::ProgressTimer*}
* @param {cocos2d::Sprite*}
*/
initWithTrackSprite_ProgressTimer_ThumbSprite : function () {},
/**
* @method getPreviousLocation
* @return A value converted from C/C++ "cocos2d::Point"
*/
getPreviousLocation : function () {},
/**
* @method create
* @return A value converted from C/C++ "cocos2d::extension::ControlPotentiometer*"
* @param {const char*}
* @param {const char*}
* @param {const char*}
*/
create : function () {},
/**
* @method ControlPotentiometer
* @constructor
*/
ControlPotentiometer : function () {},
};
/**
* @class ControlSlider
*/
cc.ControlSlider = {
/**
* @method locationFromTouch
* @return A value converted from C/C++ "cocos2d::Point"
* @param {cocos2d::Touch*}
*/
locationFromTouch : function () {},
/**
* @method setProgressSprite
* @param {cocos2d::Sprite*}
*/
setProgressSprite : function () {},
/**
* @method getMaximumAllowedValue
* @return A value converted from C/C++ "float"
*/
getMaximumAllowedValue : function () {},
/**
* @method getMinimumAllowedValue
* @return A value converted from C/C++ "float"
*/
getMinimumAllowedValue : function () {},
/**
* @method getMinimumValue
* @return A value converted from C/C++ "float"
*/
getMinimumValue : function () {},
/**
* @method setThumbSprite
* @param {cocos2d::Sprite*}
*/
setThumbSprite : function () {},
/**
* @method setMinimumValue
* @param {float}
*/
setMinimumValue : function () {},
/**
* @method setMinimumAllowedValue
* @param {float}
*/
setMinimumAllowedValue : function () {},
/**
* @method setEnabled
* @param {bool}
*/
setEnabled : function () {},
/**
* @method setValue
* @param {float}
*/
setValue : function () {},
/**
* @method setMaximumValue
* @param {float}
*/
setMaximumValue : function () {},
/**
* @method needsLayout
*/
needsLayout : function () {},
/**
* @method getBackgroundSprite
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getBackgroundSprite : function () {},
/**
* @method initWithSprites
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Sprite*}
* @param {cocos2d::Sprite*}
* @param {cocos2d::Sprite*}
*/
initWithSprites : function () {},
/**
* @method getMaximumValue
* @return A value converted from C/C++ "float"
*/
getMaximumValue : function () {},
/**
* @method isTouchInside
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Touch*}
*/
isTouchInside : function () {},
/**
* @method getValue
* @return A value converted from C/C++ "float"
*/
getValue : function () {},
/**
* @method getThumbSprite
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getThumbSprite : function () {},
/**
* @method getProgressSprite
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getProgressSprite : function () {},
/**
* @method setBackgroundSprite
* @param {cocos2d::Sprite*}
*/
setBackgroundSprite : function () {},
/**
* @method setMaximumAllowedValue
* @param {float}
*/
setMaximumAllowedValue : function () {},
/**
* @method ControlSlider
* @constructor
*/
ControlSlider : function () {},
};
/**
* @class ControlStepper
*/
cc.ControlStepper = {
/**
* @method setMinusSprite
* @param {cocos2d::Sprite*}
*/
setMinusSprite : function () {},
/**
* @method ccTouchBegan
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchBegan : function () {},
/**
* @method getMinusLabel
* @return A value converted from C/C++ "cocos2d::LabelTTF*"
*/
getMinusLabel : function () {},
/**
* @method setWraps
* @param {bool}
*/
setWraps : function () {},
/**
* @method ccTouchEnded
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchEnded : function () {},
/**
* @method isContinuous
* @return A value converted from C/C++ "bool"
*/
isContinuous : function () {},
/**
* @method getMinusSprite
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getMinusSprite : function () {},
/**
* @method updateLayoutUsingTouchLocation
* @param {cocos2d::Point}
*/
updateLayoutUsingTouchLocation : function () {},
/**
* @method setValueWithSendingEvent
* @param {double}
* @param {bool}
*/
setValueWithSendingEvent : function () {},
/**
* @method getPlusLabel
* @return A value converted from C/C++ "cocos2d::LabelTTF*"
*/
getPlusLabel : function () {},
/**
* @method stopAutorepeat
*/
stopAutorepeat : function () {},
/**
* @method ccTouchMoved
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchMoved : function () {},
/**
* @method setMaximumValue
* @param {double}
*/
setMaximumValue : function () {},
/**
* @method setPlusSprite
* @param {cocos2d::Sprite*}
*/
setPlusSprite : function () {},
/**
* @method setMinusLabel
* @param {cocos2d::LabelTTF*}
*/
setMinusLabel : function () {},
/**
* @method setValue
* @param {double}
*/
setValue : function () {},
/**
* @method setStepValue
* @param {double}
*/
setStepValue : function () {},
/**
* @method getPlusSprite
* @return A value converted from C/C++ "cocos2d::Sprite*"
*/
getPlusSprite : function () {},
/**
* @method update
* @param {float}
*/
update : function () {},
/**
* @method setMinimumValue
* @param {double}
*/
setMinimumValue : function () {},
/**
* @method startAutorepeat
*/
startAutorepeat : function () {},
/**
* @method initWithMinusSpriteAndPlusSprite
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Sprite*}
* @param {cocos2d::Sprite*}
*/
initWithMinusSpriteAndPlusSprite : function () {},
/**
* @method getValue
* @return A value converted from C/C++ "double"
*/
getValue : function () {},
/**
* @method setPlusLabel
* @param {cocos2d::LabelTTF*}
*/
setPlusLabel : function () {},
/**
* @method create
* @return A value converted from C/C++ "cocos2d::extension::ControlStepper*"
* @param {cocos2d::Sprite*}
* @param {cocos2d::Sprite*}
*/
create : function () {},
/**
* @method ControlStepper
* @constructor
*/
ControlStepper : function () {},
};
/**
* @class ControlSwitch
*/
cc.ControlSwitch = {
/**
* @method setEnabled
* @param {bool}
*/
setEnabled : function () {},
/**
* @method ccTouchBegan
* @return A value converted from C/C++ "bool"
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchBegan : function () {},
/**
* @method isOn
* @return A value converted from C/C++ "bool"
*/
isOn : function () {},
/**
* @method ccTouchCancelled
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchCancelled : function () {},
/**
* @method ccTouchEnded
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchEnded : function () {},
/**
* @method ccTouchMoved
* @param {cocos2d::Touch*}
* @param {cocos2d::Event*}
*/
ccTouchMoved : function () {},
/**
* @method hasMoved
* @return A value converted from C/C++ "bool"
*/
hasMoved : function () {},
/**
* @method locationFromTouch
* @return A value converted from C/C++ "cocos2d::Point"
* @param {cocos2d::Touch*}
*/
locationFromTouch : function () {},
/**
* @method ControlSwitch
* @constructor
*/
ControlSwitch : function () {},
};
/**
* @class TableViewCell
*/

View File

@ -291,6 +291,93 @@ tolua_lerror:
return 0;
}
static int tolua_cocos2dx_Menu_alignItemsInRows(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
Menu* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<Menu*>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_Menu_alignItemsInRows'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc > 0)
{
Array* array = NULL;
if (luavals_variadic_to_array(tolua_S, argc, &array))
{
self->alignItemsInRowsWithArray(array);
}
return 0;
}
CCLOG("wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInRows: %d, was expecting %d\n", argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'alignItemsInRows'.\n",&tolua_err);
#endif
return 0;
}
static int tolua_cocos2dx_Menu_alignItemsInColumns(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
Menu* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<Menu*>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Menu_alignItemsInColumns'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc > 0)
{
Array* array = NULL;
if (luavals_variadic_to_array(tolua_S, argc, &array))
{
self->alignItemsInColumnsWithArray(array);
}
return 0;
}
CCLOG("wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInColumns: %d, was expecting %d\n", argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'alignItemsInRows'.\n",&tolua_err);
#endif
return 0;
}
static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S)
{
if (NULL == tolua_S)
@ -304,18 +391,34 @@ static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S)
#endif
argc = lua_gettop(tolua_S) - 1;
if(1 == argc)
if(argc >= 1)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,2,"MenuItem",0,&tolua_err) )
MenuItemToggle* tolua_ret = MenuItemToggle::create();
if (NULL == tolua_ret)
{
goto tolua_lerror;
return 0;
}
for (uint32_t i = 0; i < argc; ++i)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S, i + 2,"MenuItem",0,&tolua_err) )
{
goto tolua_lerror;
}
#endif
MenuItem* item = (MenuItem*) tolua_tousertype(tolua_S,2,0);
MenuItemToggle* tolua_ret = (MenuItemToggle*) MenuItemToggle::create(item);
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
MenuItem* item = static_cast<MenuItem*>(tolua_tousertype(tolua_S, i + 2,0));
if (0 == i)
{
tolua_ret->initWithItem(item);
}
else
{
tolua_ret->addSubItem(item);
}
}
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"MenuItemToggle");
return 1;
@ -534,7 +637,7 @@ tolua_lerror:
#endif
}
int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S)
static int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S)
{
if (NULL == tolua_S)
return 0;
@ -579,7 +682,7 @@ tolua_lerror:
#endif
}
int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S)
static int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S)
{
if (NULL == tolua_S)
return 0;
@ -618,7 +721,7 @@ tolua_lerror:
#endif
}
int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S)
static int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S)
{
if (NULL == tolua_S)
return 0;
@ -663,9 +766,9 @@ tolua_lerror:
#endif
}
int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S)
static int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S)
{
if (NULL == tolua_S)
if (nullptr == tolua_S)
return 0;
int argc = 0;
@ -703,7 +806,6 @@ tolua_lerror:
#endif
}
static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S)
{
if (NULL == tolua_S)
@ -1590,6 +1692,559 @@ static int tolua_cocos2dx_LayerColor_setBlendFunc(lua_State* tolua_S)
return tolua_cocos2dx_setBlendFunc<LayerColor>(tolua_S,"LayerColor");
}
static int tolua_cocos2dx_ParticleSystem_setBlendFunc(lua_State* tolua_S)
{
return tolua_cocos2dx_setBlendFunc<ParticleSystem>(tolua_S,"ParticleSystem");
}
static int tolua_cocos2dx_LayerMultiplex_create(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
Array* array = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertable(tolua_S, 1, "LayerMultiplex", 0, &tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc > 0)
{
if (luavals_variadic_to_array(tolua_S, argc, &array) && nullptr != array )
{
LayerMultiplex* tolua_ret = LayerMultiplex::createWithArray(array);
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"LayerMultiplex");
return 1;
}
else
{
CCLOG("error in tolua_cocos2dx_LayerMultiplex_create \n");
return 0;
}
}
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2dx_Camera_getCenterXYZ(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
Camera* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<Camera *>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self)
{
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getCenterXYZ'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (0 == argc)
{
float x;
float y;
float z;
self->getCenterXYZ(&x, &y, &z);
tolua_pushnumber(tolua_S,(lua_Number)x);
tolua_pushnumber(tolua_S, (lua_Number)y);
tolua_pushnumber(tolua_S, (lua_Number)z);
return 3;
}
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'getCenterXYZ'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2dx_Camera_getEyeXYZ(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
Camera* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<Camera *>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getEyeXYZ'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (0 == argc)
{
float x;
float y;
float z;
self->getEyeXYZ(&x, &y, &z);
tolua_pushnumber(tolua_S,(lua_Number)x);
tolua_pushnumber(tolua_S, (lua_Number)y);
tolua_pushnumber(tolua_S, (lua_Number)z);
return 3;
}
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'getEyeXYZ'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2dx_Camera_getUpXYZ(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
Camera* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<Camera *>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getUpXYZ'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (0 == argc)
{
float x;
float y;
float z;
self->getUpXYZ(&x, &y, &z);
tolua_pushnumber(tolua_S,(lua_Number)x);
tolua_pushnumber(tolua_S, (lua_Number)y);
tolua_pushnumber(tolua_S, (lua_Number)z);
return 3;
}
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'getUpXYZ'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2dx_FileUtils_getStringFromFile(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
FileUtils* self = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"FileUtils",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<FileUtils *>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self)
{
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_FileUtils_getStringFromFile'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (1 == argc)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str();
if (ok)
{
std::string fullPathName = FileUtils::getInstance()->fullPathForFilename(arg0);
String* contentsOfFile = String::createWithContentsOfFile(fullPathName.c_str());
if (nullptr != contentsOfFile)
{
const char* tolua_ret = contentsOfFile->getCString();
tolua_pushstring(tolua_S, tolua_ret);
}
return 1;
}
}
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'getStringFromFile'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2dx_UserDefault_getInstance(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertable(tolua_S,1,"UserDefault",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if(0 == argc)
{
UserDefault* tolua_ret = (UserDefault*) UserDefault::getInstance();
tolua_pushusertype(tolua_S,(void*)tolua_ret,"UserDefault");
return 1;
}
CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'getInstance'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2dx_GLProgram_create(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
bool ok = false;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertable(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if(2 == argc)
{
const char *arg0, *arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str();
GLProgram* tolua_ret = new GLProgram();
if (nullptr == tolua_ret)
return 0;
tolua_ret->autorelease();
tolua_ret->initWithVertexShaderFilename(arg0, arg1);
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"GLProgram");
return 1;
}
CCLOG("'create' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2d_GLProgram_getProgram(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
GLProgram* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror;
#endif
self = (GLProgram*) tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (nullptr == self)
{
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_GLProgram_getProgram'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (0 == argc)
{
unsigned const int tolua_ret = ( unsigned const int) self->getProgram();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
return 1;
}
CCLOG("'getProgram' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'getProgram'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2dx_GLProgram_setUniformLocationF32(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
GLProgram* self = nullptr;
int location = 0;
double f1 = 0.0;
double f2 = 0.0;
double f3 = 0.0;
double f4 = 0.0;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror;
#endif
self = (GLProgram*) tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (nullptr == self)
{
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_GLProgram_getProgram'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc >= 2 && argc <= 5)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err))
{
goto tolua_lerror;
}
#endif
location = (int) tolua_tonumber(tolua_S,2,0);
f1 = (float) tolua_tonumber(tolua_S,3,0);
if (2 == argc)
{
self->setUniformLocationWith1f(location,f1);
return 0;
}
if (argc >= 3)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isnumber(tolua_S,4,0,&tolua_err))
goto tolua_lerror;
#endif
f2 = (float) tolua_tonumber(tolua_S,3,0);
if (3 == argc)
{
self->setUniformLocationWith2f(location, f1, f2);
return 0;
}
}
if (argc >= 4)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isnumber(tolua_S,5,0,&tolua_err))
goto tolua_lerror;
#endif
f3 = (float) tolua_tonumber(tolua_S,3,0);
if (4 == argc)
{
self->setUniformLocationWith3f(location, f1, f2, f3);
return 0;
}
}
if (argc == 5)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isnumber(tolua_S,6,0,&tolua_err))
goto tolua_lerror;
#endif
f4 = (float) tolua_tonumber(tolua_S,3,0);
if (4 == argc)
{
self->setUniformLocationWith4f(location, f1, f2, f3, f4);
return 0;
}
}
}
CCLOG("'setUniformLocationF32' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'setUniformLocationF32'.",&tolua_err);
return 0;
#endif
}
static void extendGLProgram(lua_State* tolua_S)
{
lua_pushstring(tolua_S, "GLProgram");
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
lua_pushstring(tolua_S,"create");
lua_pushcfunction(tolua_S,tolua_cocos2dx_GLProgram_create );
lua_rawset(tolua_S,-3);
lua_pushstring(tolua_S,"getProgram");
lua_pushcfunction(tolua_S,tolua_cocos2d_GLProgram_getProgram );
lua_rawset(tolua_S,-3);
lua_pushstring(tolua_S,"setUniformLocationF32");
lua_pushcfunction(tolua_S,tolua_cocos2dx_GLProgram_setUniformLocationF32 );
lua_rawset(tolua_S,-3);
}
}
static int tolua_cocos2dx_Texture2D_setTexParameters(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
Texture2D* self = nullptr;
GLuint arg1 = 0;
GLuint arg2 = 0;
GLuint arg3 = 0;
GLuint arg4 = 0;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"Texture2D",0,&tolua_err)) goto tolua_lerror;
#endif
self = (Texture2D*) tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (nullptr == self)
{
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Texture2D_setTexParameters'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (4 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 4, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 5, 0, &tolua_err))
{
goto tolua_lerror;
}
#endif
arg1 = (GLuint)tolua_tonumber(tolua_S, 2, 0);
arg2 = (GLuint)tolua_tonumber(tolua_S, 3, 0);
arg3 = (GLuint)tolua_tonumber(tolua_S, 4, 0);
arg4 = (GLuint)tolua_tonumber(tolua_S, 5, 0);
Texture2D::TexParams param = { arg1, arg2, arg3, arg4 };
self->setTexParameters(param);
return 0;
}
CCLOG("'setTexParameters' function of Texture2D wrong number of arguments: %d, was expecting %d\n", argc,4);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'setTexParameters'.",&tolua_err);
return 0;
#endif
}
static void extendTexture2D(lua_State* tolua_S)
{
lua_pushstring(tolua_S, "Texture2D");
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
lua_pushstring(tolua_S,"setTexParameters");
lua_pushcfunction(tolua_S,tolua_cocos2dx_Texture2D_setTexParameters );
lua_rawset(tolua_S,-3);
}
}
int register_all_cocos2dx_manual(lua_State* tolua_S)
{
if (NULL == tolua_S)
@ -1659,6 +2314,12 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
lua_pushstring(tolua_S,"create");
lua_pushcfunction(tolua_S,tolua_cocos2d_Menu_create);
lua_rawset(tolua_S,-3);
lua_pushstring(tolua_S,"alignItemsInRows");
lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInRows);
lua_rawset(tolua_S,-3);
lua_pushstring(tolua_S,"alignItemsInColumns");
lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInColumns);
lua_rawset(tolua_S,-3);
}
lua_pushstring(tolua_S,"Node");
@ -1814,5 +2475,61 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
lua_rawset(tolua_S,-3);
}
lua_pushstring(tolua_S,"LayerMultiplex");
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
lua_pushstring(tolua_S,"create");
lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerMultiplex_create);
lua_rawset(tolua_S,-3);
}
lua_pushstring(tolua_S,"ParticleSystem");
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
lua_pushstring(tolua_S,"setBlendFunc");
lua_pushcfunction(tolua_S,tolua_cocos2dx_ParticleSystem_setBlendFunc);
lua_rawset(tolua_S,-3);
}
lua_pushstring(tolua_S, "Camera");
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
lua_pushstring(tolua_S,"getCenter");
lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getCenterXYZ );
lua_rawset(tolua_S,-3);
lua_pushstring(tolua_S,"getUp");
lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getUpXYZ );
lua_rawset(tolua_S,-3);
lua_pushstring(tolua_S,"getEye");
lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getEyeXYZ );
lua_rawset(tolua_S,-3);
}
lua_pushstring(tolua_S, "FileUtils");
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
lua_pushstring(tolua_S,"getStringFromFile");
lua_pushcfunction(tolua_S,tolua_cocos2dx_FileUtils_getStringFromFile );
lua_rawset(tolua_S,-3);
}
lua_pushstring(tolua_S, "UserDefault");
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
lua_pushstring(tolua_S,"getInstance");
lua_pushcfunction(tolua_S,tolua_cocos2dx_UserDefault_getInstance );
lua_rawset(tolua_S,-3);
}
extendGLProgram(tolua_S);
extendTexture2D(tolua_S);
return 0;
}

View File

@ -5,10 +5,30 @@ cc.DIRECTOR_PROJECTION_3D = 1
--Point
function cc.p(_x,_y)
return { x = _x, y = _y }
if nil == _y then
return { x = _x.x, y = _x.y }
else
return { x = _x, y = _y }
end
end
function cc.getPLength(pt)
function cc.pAdd(pt1,pt2)
return {x = pt1.x + pt2.x , y = pt1.y + pt2.y }
end
function cc.pSub(pt1,pt2)
return {x = pt1.x - pt2.x , y = pt1.y - pt2.y }
end
function cc.pMul(pt1,factor)
return { x = pt1.x * factor , y = pt1.y * factor }
end
function cc.pForAngle(a)
return { x = math.cos(a), y = math.sin(a) }
end
function cc.pGetLength(pt)
return math.sqrt( pt.x * pt.x + pt.y * pt.y );
end
@ -21,6 +41,33 @@ function cc.pNormalize(pt)
return { x = pt.x / length, y = pt.y / length }
end
function cc.pCross(self,other)
return self.x * other.y - self.y * other.x
end
function cc.pDot(self,other)
return self.x * other.x - self.y * other.y
end
function cc.pToAngleSelf(self)
return math.atan2(self.y, self.x)
end
function cc.pToAngle(self,other)
local a2 = cc.pNormalize(self)
local b2 = cc.pNormalize(other)
local angle = math.atan2(cc.pCross(a2, b2), cc.pDot(a2, b2) )
if angle < 1.192092896e-7 then
return 0.0
end
return angle
end
function cc.pGetDistance(startP,endP)
return cc.pGetLength(cc.pSub(startP,endP))
end
--Size
function cc.size( _width,_height )
return { width = _width, height = _height }
@ -31,6 +78,80 @@ function cc.rect(_x,_y,_width,_height)
return { x = _x, y = _y, width = _width, height = _height }
end
function cc.rectEqualToRect(rect1,rect2)
if ((rect1.x >= rect2.x) or (rect1.y >= rect2.y) or
( rect1.x + rect1.width <= rect2.x + rect2.width) or
( rect1.y + rect1.height <= rect2.y + rect2.height)) then
return false
end
return true
end
function cc.rectGetMaxX(rect)
return rect.x + rect.width
end
function cc.rectGetMidX(rect)
return rect.x + rect.width / 2.0
end
function cc.rectGetMinX(rect)
return rect.x;
end
function cc.rectGetMaxY(rect)
return rect.y + rect.height
end
function cc.rectGetMidY(rect)
return rect.y + rect.height / 2.0
end
function cc.rectGetMinY(rect)
return rect.y
end
function cc.rectContainsPoint( rect, point )
local ret = false
if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and
(point.y >= rect.y) and (point.y <= rect.y + rect.height) then
ret = true
end
return ret
end
function cc.rectIntersectsRect( rect1, rect2 )
local intersect = not ( rect1.x > rect2.x + rect2.width or
rect1.x + rect1.width < rect2.x or
rect1.y > rect2.y + rect2.height or
rect1.y + rect1.height < rect2.y )
return intersect
end
function cc.rectUnion( rect1, rect2 )
local rect = cc.rect(0, 0, 0, 0)
rect.x = math.min(rect1.x, rect2.x)
rect.y = math.min(rect1.y, rect2.y)
rect.width = math.max(rect1.x + rect1.width, rect2.x + rect2.width) - rect.x
rect.height = math.max(rect1.y + rect1.height, rect2.y + rect2.height) - rect.y
return rect
end
function cc.rectIntersection( rect1, rect2 )
local intersection = cc.rect(
math.max(rect1.x, rect2.x),
math.max(rect1.y, rect2.y),
0, 0)
intersection.width = math.min(rect1.x + rect1.width, rect2.x + rect2.width) - intersection.x
intersection.height = math.min(rect1.y + rect1.height, rect2.y + rect2.height) - intersection.y
return intersection;
end
--Color3B
function cc.c3b( _r,_g,_b )
return { r = _r, g = _g, b = _b }
@ -46,15 +167,4 @@ function cc.c4f( _r,_g,_b,_a )
return { r = _r, g = _g, b = _b, a = _a }
end
function cc.rectContainsPoint( rect, point )
local ret = false
if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and
(point.y >= rect.y) and (point.y <= rect.y + rect.height) then
ret = true
end
return ret;
end

View File

@ -88,17 +88,26 @@ cc.TMX_TILE_VERTICAL_FLAG = 0x40000000
cc.TEXT_ALIGNMENT_CENTER = 0x1
cc.TEXT_ALIGNMENT_LEFT = 0x0
cc.TEXT_ALIGNMENT_RIGHT = 0x2
cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x3
cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x5
cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0
cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x4
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0x9
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0x8
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x2
cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x7
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x1
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x6
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x0
cc.TEXTURE2_D_PIXEL_FORMAT_AUTO = 0x0
cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888 = 0x1
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x2
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x3
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x4
cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x5
cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x6
cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x7
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x8
cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x9
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0xa
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4A = 0xb
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0xc
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2A = 0xd
cc.TEXTURE2_D_PIXEL_FORMAT_ETC = 0xe
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT1 = 0xf
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT3 = 0x10
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT5 = 0x11
cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0
cc.TOUCHES_ALL_AT_ONCE = 0x0
cc.TOUCHES_ONE_BY_ONE = 0x1
cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1

View File

@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h %(cocosdir)s/CocosDenshion/inc
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$
classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault Image
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
@ -103,10 +103,10 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
Application::[^application.* ^run$],
Camera::[getEyeXYZ getCenterXYZ getUpXYZ],
ccFontDefinition::[*],
Object::[autorelease isEqual acceptVisitor update]
Object::[autorelease isEqual acceptVisitor update],
UserDefault::[getInstance (s|g)etDataForKey]
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY],
MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName],
ProgressTimer::[setReverseProgress=setReverseDirection],
Animation::[addSpriteFrameWithFileName=addSpriteFrameWithFile],
AnimationCache::[addAnimationsWithFile=addAnimations animationByName=getAnimation removeAnimationByName=removeAnimation],

View File

@ -26,7 +26,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control$ ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$
classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
@ -40,10 +40,12 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC
ScrollView::[(g|s)etDelegate$],
.*Delegate::[*],
.*Loader.*::[*],
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate],
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate .*HSV],
EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler],
TableView::[create (g|s)etDataSource$ (g|s)etDelegate],
Control::[removeHandleOfControlEvent addHandleOfControlEvent]
Control::[removeHandleOfControlEvent addHandleOfControlEvent],
ControlUtils::[*],
ControlSwitchSprite::[*]
rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager],
CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed]