Adding Texture2dTest. And format some lua codes.

This commit is contained in:
James Chen 2013-04-05 16:13:04 +08:00
parent 031e77ccbe
commit 2bff6d6480
16 changed files with 2672 additions and 721 deletions

View File

@ -1,10 +1,9 @@
local size = CCDirector:sharedDirector():getWinSize()
local layer = nil
local kTagSprite = 1
local function initWithLayer()
local sprite = CCSprite:create(s_pPathGrossini)
local sprite = CCSprite:create(s_pPathGrossini)
local bgLayer = CCLayerColor:create(ccc4(255,255,0,255))
layer:addChild(bgLayer, -1)
@ -15,54 +14,54 @@ local function initWithLayer()
sprite:runAction(CCJumpTo:create(4, CCPointMake(300,48), 100, 4))
bgLayer:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(
CCFadeIn:create(1),
CCFadeOut:create(1))))
CCFadeIn:create(1),
CCFadeOut:create(1))))
local function onTouchEnded(x, y)
local s = layer:getChildByTag(kTagSprite)
s:stopAllActions()
s:runAction(CCMoveTo:create(1, CCPointMake(x, y)))
local posX, posY = s:getPosition()
local o = x - posX
local a = y - posY
local at = math.atan(o / a) / math.pi * 180.0
local function onTouchEnded(x, y)
local s = layer:getChildByTag(kTagSprite)
s:stopAllActions()
s:runAction(CCMoveTo:create(1, CCPointMake(x, y)))
local posX, posY = s:getPosition()
local o = x - posX
local a = y - posY
local at = math.atan(o / a) / math.pi * 180.0
if a < 0 then
if o < 0 then
at = 180 + math.abs(at)
else
at = 180 - math.abs(at)
end
end
s:runAction(CCRotateTo:create(1, at))
if a < 0 then
if o < 0 then
at = 180 + math.abs(at)
else
at = 180 - math.abs(at)
end
end
s:runAction(CCRotateTo:create(1, at))
end
local function onTouch(eventType, x, y)
if eventType == "began" then
return true
if eventType == "began" then
return true
elseif eventType == "ended" then
return onTouchEnded(x, y)
end
end
layer:setTouchEnabled(true)
layer:setTouchEnabled(true)
layer:registerScriptTouchHandler(onTouch)
return layer
return layer
end
--------------------------------
-- Click And Move Test
--------------------------------
function ClickAndMoveTest()
cclog("ClickAndMoveTest")
local scene = CCScene:create()
layer = CCLayer:create()
cclog("ClickAndMoveTest")
local scene = CCScene:create()
layer = CCLayer:create()
initWithLayer()
initWithLayer()
scene:addChild(CreateBackMenuItem())
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
scene:addChild(layer)
return scene
return scene
end

View File

@ -13,29 +13,29 @@ local titleLabel = nil
local entry = nil
local function onEnterOrExit(tag)
local scheduler = CCDirector:sharedDirector():getScheduler()
if tag == "enter" then
entry = scheduler:scheduleScriptFunc(checkAnim, 0, false)
elseif tag == "exit" then
scheduler:unscheduleScriptEntry(entry)
end
local scheduler = CCDirector:sharedDirector():getScheduler()
if tag == "enter" then
entry = scheduler:scheduleScriptFunc(checkAnim, 0, false)
elseif tag == "exit" then
scheduler:unscheduleScriptEntry(entry)
end
end
local function checkAnim(dt)
local s2 = testLayer:getChildByTag(kTagBackground)
if s2 == nil then
return
end
local s2 = testLayer:getChildByTag(kTagBackground)
if s2 == nil then
return
end
if s2:numberOfRunningActions() == 0 then
if s2:getGrid() ~= nil then
s2:setGrid(nil)
end
end
if s2:getGrid() ~= nil then
s2:setGrid(nil)
end
end
end
local function backAction()
ActionIdx = ActionIdx - 1
ActionIdx = ActionIdx - 1
if ActionIdx < 0 then
ActionIdx = ActionIdx + MAX_LAYER
end
@ -44,120 +44,120 @@ local function backAction()
end
local function restartAction()
return CreateEffectsTestLayer()
return CreateEffectsTestLayer()
end
local function nextAction()
ActionIdx = ActionIdx + 1
ActionIdx = ActionIdx + 1
ActionIdx = math.mod(ActionIdx, MAX_LAYER)
return CreateEffectsTestLayer()
end
local function backCallback(sender)
local scene = CCScene:create()
local scene = CCScene:create()
scene:addChild(backAction())
scene:addChild(CreateBackMenuItem())
scene:addChild(backAction())
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():replaceScene(scene)
CCDirector:sharedDirector():replaceScene(scene)
end
local function restartCallback(sender)
local scene = CCScene:create()
local scene = CCScene:create()
scene:addChild(restartAction())
scene:addChild(CreateBackMenuItem())
scene:addChild(restartAction())
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():replaceScene(scene)
CCDirector:sharedDirector():replaceScene(scene)
end
local function nextCallback(sender)
local scene = CCScene:create()
local scene = CCScene:create()
scene:addChild(nextAction())
scene:addChild(CreateBackMenuItem())
scene:addChild(nextAction())
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():replaceScene(scene)
CCDirector:sharedDirector():replaceScene(scene)
end
--------------------------------------
-- Shaky3DDemo
--------------------------------------
local function Shaky3DDemo(t)
return CCShaky3D:create(t, CCSizeMake(15,10), 5, false);
return CCShaky3D:create(t, CCSizeMake(15,10), 5, false);
end
--------------------------------------
-- Waves3DDemo
--------------------------------------
local function Waves3DDemo(t)
return CCWaves3D:create(t, CCSizeMake(15,10), 5, 40);
return CCWaves3D:create(t, CCSizeMake(15,10), 5, 40);
end
--------------------------------------
-- FlipX3DDemo
--------------------------------------
local function FlipX3DDemo(t)
local flipx = CCFlipX3D:create(t)
local flipx_back = flipx:reverse()
local delay = CCDelayTime:create(2)
local flipx = CCFlipX3D:create(t)
local flipx_back = flipx:reverse()
local delay = CCDelayTime:create(2)
local array = CCArray:create()
array:addObject(flipx)
array:addObject(flipx_back)
array:addObject(delay)
return CCSequence:create(array)
local array = CCArray:create()
array:addObject(flipx)
array:addObject(flipx_back)
array:addObject(delay)
return CCSequence:create(array)
end
--------------------------------------
-- FlipY3DDemo
--------------------------------------
local function FlipY3DDemo(t)
local flipy = CCFlipY3D:create(t)
local flipy_back = flipy:reverse()
local delay = CCDelayTime:create(2)
local flipy = CCFlipY3D:create(t)
local flipy_back = flipy:reverse()
local delay = CCDelayTime:create(2)
local array = CCArray:create()
array:addObject(flipy)
array:addObject(flipy_back)
array:addObject(delay)
return CCSequence:create(array)
local array = CCArray:create()
array:addObject(flipy)
array:addObject(flipy_back)
array:addObject(delay)
return CCSequence:create(array)
end
--------------------------------------
-- Lens3DDemo
--------------------------------------
local function Lens3DDemo(t)
return CCLens3D:create(t, CCSizeMake(15,10), ccp(size.width/2,size.height/2), 240);
return CCLens3D:create(t, CCSizeMake(15,10), ccp(size.width/2,size.height/2), 240);
end
--------------------------------------
-- Ripple3DDemo
--------------------------------------
local function Ripple3DDemo(t)
return CCRipple3D:create(t, CCSizeMake(32,24), ccp(size.width/2,size.height/2), 240, 4, 160);
return CCRipple3D:create(t, CCSizeMake(32,24), ccp(size.width/2,size.height/2), 240, 4, 160);
end
--------------------------------------
-- LiquidDemo
--------------------------------------
local function LiquidDemo(t)
return CCLiquid:create(t, CCSizeMake(16,12), 4, 20);
return CCLiquid:create(t, CCSizeMake(16,12), 4, 20);
end
--------------------------------------
-- WavesDemo
--------------------------------------
local function WavesDemo(t)
return CCWaves:create(t, CCSizeMake(16,12), 4, 20, true, true);
return CCWaves:create(t, CCSizeMake(16,12), 4, 20, true, true);
end
--------------------------------------
-- TwirlDemo
--------------------------------------
local function TwirlDemo(t)
return CCTwirl:create(t, CCSizeMake(12,8), ccp(size.width/2, size.height/2), 1, 2.5);
return CCTwirl:create(t, CCSizeMake(12,8), ccp(size.width/2, size.height/2), 1, 2.5);
end
--------------------------------------
@ -171,96 +171,96 @@ end
-- ShatteredTiles3DDemo
--------------------------------------
local function ShatteredTiles3DDemo(t)
return CCShatteredTiles3D:create(t, CCSizeMake(16,12), 5, false);
return CCShatteredTiles3D:create(t, CCSizeMake(16,12), 5, false);
end
--------------------------------------
-- ShuffleTilesDemo
--------------------------------------
local function ShuffleTilesDemo(t)
local shuffle = CCShuffleTiles:create(t, CCSizeMake(16,12), 25);
local shuffle_back = shuffle:reverse()
local delay = CCDelayTime:create(2)
local shuffle = CCShuffleTiles:create(t, CCSizeMake(16,12), 25);
local shuffle_back = shuffle:reverse()
local delay = CCDelayTime:create(2)
local array = CCArray:create()
array:addObject(shuffle)
array:addObject(shuffle_back)
array:addObject(delay)
return CCSequence:create(array)
local array = CCArray:create()
array:addObject(shuffle)
array:addObject(shuffle_back)
array:addObject(delay)
return CCSequence:create(array)
end
--------------------------------------
-- FadeOutTRTilesDemo
--------------------------------------
local function FadeOutTRTilesDemo(t)
local fadeout = CCFadeOutTRTiles:create(t, CCSizeMake(16,12));
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local fadeout = CCFadeOutTRTiles:create(t, CCSizeMake(16,12));
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
end
--------------------------------------
-- FadeOutBLTilesDemo
--------------------------------------
local function FadeOutBLTilesDemo(t)
local fadeout = CCFadeOutBLTiles:create(t, CCSizeMake(16,12));
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local fadeout = CCFadeOutBLTiles:create(t, CCSizeMake(16,12));
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
end
--------------------------------------
-- FadeOutUpTilesDemo
--------------------------------------
local function FadeOutUpTilesDemo(t)
local fadeout = CCFadeOutUpTiles:create(t, CCSizeMake(16,12));
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local fadeout = CCFadeOutUpTiles:create(t, CCSizeMake(16,12));
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
end
--------------------------------------
-- FadeOutDownTilesDemo
--------------------------------------
local function FadeOutDownTilesDemo(t)
local fadeout = CCFadeOutDownTiles:create(t, CCSizeMake(16,12));
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local fadeout = CCFadeOutDownTiles:create(t, CCSizeMake(16,12));
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
end
--------------------------------------
-- TurnOffTilesDemo
--------------------------------------
local function TurnOffTilesDemo(t)
local fadeout = CCTurnOffTiles:create(t, CCSizeMake(48,32), 25);
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local fadeout = CCTurnOffTiles:create(t, CCSizeMake(48,32), 25);
local back = fadeout:reverse()
local delay = CCDelayTime:create(0.5)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
local array = CCArray:create()
array:addObject(fadeout)
array:addObject(back)
array:addObject(delay)
return CCSequence:create(array)
end
@ -268,98 +268,98 @@ end
-- WavesTiles3DDemo
--------------------------------------
local function WavesTiles3DDemo(t)
return CCWavesTiles3D:create(t, CCSizeMake(15,10), 4, 120);
return CCWavesTiles3D:create(t, CCSizeMake(15,10), 4, 120);
end
--------------------------------------
-- JumpTiles3DDemo
--------------------------------------
local function JumpTiles3DDemo(t)
return CCJumpTiles3D:create(t, CCSizeMake(15,10), 2, 30);
return CCJumpTiles3D:create(t, CCSizeMake(15,10), 2, 30);
end
--------------------------------------
-- SplitRowsDemo
--------------------------------------
local function SplitRowsDemo(t)
return CCSplitRows:create(t, 9);
return CCSplitRows:create(t, 9);
end
--------------------------------------
-- SplitColsDemo
--------------------------------------
local function SplitColsDemo(t)
return CCSplitCols:create(t, 9);
return CCSplitCols:create(t, 9);
end
--------------------------------------
-- PageTurn3DDemo
--------------------------------------
local function PageTurn3DDemo(t)
CCDirector:sharedDirector():setDepthTest(true)
return CCPageTurn3D:create(t, CCSizeMake(15,10));
CCDirector:sharedDirector():setDepthTest(true)
return CCPageTurn3D:create(t, CCSizeMake(15,10));
end
--------------------------------------
-- Effects Test
--------------------------------------
local function createEffect(idx, t)
CCDirector:sharedDirector():setDepthTest(false)
local action = nil
CCDirector:sharedDirector():setDepthTest(false)
local action = nil
if idx == 0 then
action = Shaky3DDemo(t)
elseif idx == 1 then
action = Waves3DDemo(t)
elseif idx == 2 then
action = FlipX3DDemo(t)
elseif idx == 3 then
action = FlipY3DDemo(t)
elseif idx == 4 then
action = Lens3DDemo(t)
elseif idx == 5 then
action = Ripple3DDemo(t)
elseif idx == 6 then
action = LiquidDemo(t)
elseif idx == 7 then
action = WavesDemo(t)
elseif idx == 8 then
action = TwirlDemo(t)
elseif idx == 9 then
action = ShakyTiles3DDemo(t)
elseif idx == 10 then
action = ShatteredTiles3DDemo(t)
elseif idx == 11 then
action = ShuffleTilesDemo(t)
elseif idx == 12 then
action = FadeOutTRTilesDemo(t)
elseif idx == 13 then
action = FadeOutBLTilesDemo(t)
elseif idx == 14 then
action = FadeOutUpTilesDemo(t)
elseif idx == 15 then
action = FadeOutDownTilesDemo(t)
elseif idx == 16 then
action = TurnOffTilesDemo(t)
elseif idx == 17 then
action = WavesTiles3DDemo(t)
elseif idx == 18 then
action = JumpTiles3DDemo(t)
elseif idx == 19 then
action = SplitRowsDemo(t)
elseif idx == 20 then
action = SplitColsDemo(t)
elseif idx == 21 then
action = PageTurn3DDemo(t)
end
elseif idx == 1 then
action = Waves3DDemo(t)
elseif idx == 2 then
action = FlipX3DDemo(t)
elseif idx == 3 then
action = FlipY3DDemo(t)
elseif idx == 4 then
action = Lens3DDemo(t)
elseif idx == 5 then
action = Ripple3DDemo(t)
elseif idx == 6 then
action = LiquidDemo(t)
elseif idx == 7 then
action = WavesDemo(t)
elseif idx == 8 then
action = TwirlDemo(t)
elseif idx == 9 then
action = ShakyTiles3DDemo(t)
elseif idx == 10 then
action = ShatteredTiles3DDemo(t)
elseif idx == 11 then
action = ShuffleTilesDemo(t)
elseif idx == 12 then
action = FadeOutTRTilesDemo(t)
elseif idx == 13 then
action = FadeOutBLTilesDemo(t)
elseif idx == 14 then
action = FadeOutUpTilesDemo(t)
elseif idx == 15 then
action = FadeOutDownTilesDemo(t)
elseif idx == 16 then
action = TurnOffTilesDemo(t)
elseif idx == 17 then
action = WavesTiles3DDemo(t)
elseif idx == 18 then
action = JumpTiles3DDemo(t)
elseif idx == 19 then
action = SplitRowsDemo(t)
elseif idx == 20 then
action = SplitColsDemo(t)
elseif idx == 21 then
action = PageTurn3DDemo(t)
end
return action
return action
end
function CreateEffectsTestLayer()
testLayer = CCLayerColor:create(ccc4(32,128,32,255))
testLayer = CCLayerColor:create(ccc4(32,128,32,255))
local x, y = size.width, size.height
local x, y = size.width, size.height
local node = CCNode:create()
local effect = createEffect(ActionIdx, 3)
@ -384,7 +384,7 @@ function CreateEffectsTestLayer()
local sc2_back = sc2:reverse()
tamara:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc2, sc2_back)))
titleLabel = CCLabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32)
titleLabel = CCLabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32)
titleLabel:setPosition(x / 2, y - 80)
testLayer:addChild(titleLabel)
titleLabel:setTag(kTagLabel)
@ -392,14 +392,14 @@ function CreateEffectsTestLayer()
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
local menu = CCMenu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:setPosition(CCPointMake(0, 0))
item1:setPosition(CCPointMake(size.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
@ -408,17 +408,17 @@ function CreateEffectsTestLayer()
testLayer:addChild(menu, 1)
testLayer:registerScriptHandler(onEnterOrExit)
testLayer:registerScriptHandler(onEnterOrExit)
return testLayer
return testLayer
end
function EffectsTest()
local scene = CCScene:create()
local scene = CCScene:create()
ActionIdx = -1
scene:addChild(nextAction())
scene:addChild(CreateBackMenuItem())
ActionIdx = -1
scene:addChild(nextAction())
scene:addChild(CreateBackMenuItem())
return scene
return scene
end

View File

@ -46,19 +46,19 @@ local function IntervalLayer()
local function step2(dt)
m_time2 = m_time2 + dt
local str = string.format("%2.1f", m_time2)
m_label2:setString( str )
m_label2:setString( str )
end
local function step3(dt)
m_time3 = m_time3 + dt
local str = string.format("%2.1f", m_time3)
m_label3:setString( str )
m_label3:setString( str )
end
local function step4(dt)
m_time4 = m_time4 + dt
local str = string.format("%2.1f", m_time4)
m_label4:setString( str )
m_label4:setString( str )
end
local schedulerEntry1 = nil
@ -101,9 +101,9 @@ local function IntervalLayer()
-- Sprite
local sprite = CCSprite:create(s_pPathGrossini)
sprite:setPosition( ccp(VisibleRect:left().x + 40, VisibleRect:bottom().y + 50) )
local jump = CCJumpBy:create(3, ccp(s.width-80,0), 50, 4)
ret:addChild(sprite)
local arr = CCArray:create()
arr:addObject(jump)
@ -113,9 +113,9 @@ local function IntervalLayer()
local item1 = CCMenuItemFont:create("Pause")
local function onPause(tag, pSender)
if CCDirector:sharedDirector():isPaused() then
CCDirector:sharedDirector():resume()
CCDirector:sharedDirector():resume()
else
CCDirector:sharedDirector():pause()
CCDirector:sharedDirector():pause()
end
end
@ -133,8 +133,7 @@ function IntervalTestMain()
cclog("IntervalTestMain")
local scene = CCScene:create()
local layer = IntervalLayer()
scene:addChild(layer, 0)
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
return scene
end

View File

@ -44,7 +44,7 @@ local function setEnableRecursiveCascading(node, enable)
node.__CCRGBAProtocol__:setCascadeColorEnabled(enable)
node.__CCRGBAProtocol__:setCascadeOpacityEnabled(enable)
end
local obj = nil
local children = node:getChildren()
if children == nil then
@ -65,20 +65,20 @@ local function LayerTestCascadingOpacityA()
local ret = createLayerDemoLayer("LayerRGBA: cascading opacity")
local s = CCDirector:sharedDirector():getWinSize()
local layer1 = CCLayerRGBA:create()
local sister1 = CCSprite:create("Images/grossinis_sister1.png")
local sister2 = CCSprite:create("Images/grossinis_sister2.png")
local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt")
layer1:addChild(sister1)
layer1:addChild(sister2)
layer1:addChild(label)
ret:addChild( layer1, 0, kTagLayer)
sister1:setPosition( ccp( s.width*1/3, s.height/2))
sister2:setPosition( ccp( s.width*2/3, s.height/2))
label:setPosition( ccp( s.width/2, s.height/2))
local arr = CCArray:create()
arr:addObject(CCFadeTo:create(4, 0))
arr:addObject(CCFadeTo:create(4, 255))
@ -92,7 +92,7 @@ local function LayerTestCascadingOpacityA()
arr:addObject(CCFadeTo:create(2, 255))
arr:addObject(CCDelayTime:create(1))
sister1:runAction(CCRepeatForever:create(CCSequence:create(arr)))
-- Enable cascading in scene
setEnableRecursiveCascading(ret, true)
return ret
@ -101,42 +101,42 @@ end
-- LayerTestCascadingOpacityB
local function LayerTestCascadingOpacityB()
local ret = createLayerDemoLayer("CCLayerColor: cascading opacity")
local s = CCDirector:sharedDirector():getWinSize()
local layer1 = CCLayerColor:create(ccc4(192, 0, 0, 255), s.width, s.height/2)
layer1:setCascadeColorEnabled(false)
layer1:setPosition( ccp(0, s.height/2))
local sister1 = CCSprite:create("Images/grossinis_sister1.png")
local sister2 = CCSprite:create("Images/grossinis_sister2.png")
local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt")
layer1:addChild(sister1)
layer1:addChild(sister2)
layer1:addChild(label)
ret:addChild( layer1, 0, kTagLayer)
sister1:setPosition( ccp( s.width*1/3, 0))
sister2:setPosition( ccp( s.width*2/3, 0))
label:setPosition( ccp( s.width/2, 0))
local arr = CCArray:create()
arr:addObject(CCFadeTo:create(4, 0))
arr:addObject(CCFadeTo:create(4, 255))
arr:addObject(CCDelayTime:create(1))
layer1:runAction(CCRepeatForever:create(CCSequence:create(arr)))
arr = CCArray:create()
arr:addObject(CCFadeTo:create(2, 0))
arr:addObject(CCFadeTo:create(2, 255))
arr:addObject(CCFadeTo:create(2, 0))
arr:addObject(CCFadeTo:create(2, 255))
arr:addObject(CCDelayTime:create(1))
sister1:runAction(CCRepeatForever:create(CCSequence:create(arr)))
-- Enable cascading in scene
setEnableRecursiveCascading(ret, true)
return ret
@ -145,23 +145,23 @@ end
-- LayerTestCascadingOpacityC
local function LayerTestCascadingOpacityC()
local ret = createLayerDemoLayer("CCLayerColor: non-cascading opacity")
local s = CCDirector:sharedDirector():getWinSize()
local layer1 = CCLayerColor:create(ccc4(192, 0, 0, 255), s.width, s.height/2)
layer1:setCascadeColorEnabled(false)
layer1:setCascadeOpacityEnabled(false)
layer1:setPosition( ccp(0, s.height/2))
local sister1 = CCSprite:create("Images/grossinis_sister1.png")
local sister2 = CCSprite:create("Images/grossinis_sister2.png")
local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt")
layer1:addChild(sister1)
layer1:addChild(sister2)
layer1:addChild(label)
ret:addChild( layer1, 0, kTagLayer)
sister1:setPosition( ccp( s.width*1/3, 0))
sister2:setPosition( ccp( s.width*2/3, 0))
label:setPosition( ccp( s.width/2, 0))
@ -170,7 +170,7 @@ local function LayerTestCascadingOpacityC()
arr:addObject(CCFadeTo:create(4, 0))
arr:addObject(CCFadeTo:create(4, 255))
arr:addObject(CCDelayTime:create(1))
layer1:runAction(
CCRepeatForever:create(
CCSequence:create(arr
@ -182,7 +182,7 @@ local function LayerTestCascadingOpacityC()
arr:addObject(CCFadeTo:create(2, 0))
arr:addObject(CCFadeTo:create(2, 255))
arr:addObject(CCDelayTime:create(1))
sister1:runAction(
CCRepeatForever:create(
CCSequence:create(arr)))
@ -194,23 +194,23 @@ end
-- LayerTestCascadingColorA
local function LayerTestCascadingColorA()
local ret = createLayerDemoLayer("LayerRGBA: cascading color")
local s = CCDirector:sharedDirector():getWinSize()
local layer1 = CCLayerRGBA:create()
local sister1 = CCSprite:create("Images/grossinis_sister1.png")
local sister2 = CCSprite:create("Images/grossinis_sister2.png")
local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt")
layer1:addChild(sister1)
layer1:addChild(sister2)
layer1:addChild(label)
ret:addChild( layer1, 0, kTagLayer)
sister1:setPosition( ccp( s.width*1/3, s.height/2))
sister2:setPosition( ccp( s.width*2/3, s.height/2))
label:setPosition( ccp( s.width/2, s.height/2))
local arr = CCArray:create()
arr:addObject(CCTintTo:create(6, 255, 0, 255))
arr:addObject(CCTintTo:create(6, 255, 255, 255))
@ -229,15 +229,15 @@ local function LayerTestCascadingColorA()
arr:addObject(CCTintTo:create(2, 255, 0, 255))
arr:addObject(CCTintTo:create(2, 255, 255, 255))
arr:addObject(CCDelayTime:create(1))
sister1:runAction(
CCRepeatForever:create(
CCSequence:create(
arr)))
-- Enable cascading in scene
setEnableRecursiveCascading(ret, true)
return ret
return ret
end
-- LayerTestCascadingColorB
@ -246,18 +246,18 @@ local function LayerTestCascadingColorB()
local s = CCDirector:sharedDirector():getWinSize()
local layer1 = CCLayerColor:create(ccc4(255, 255, 255, 255), s.width, s.height/2)
layer1:setPosition( ccp(0, s.height/2))
local sister1 = CCSprite:create("Images/grossinis_sister1.png")
local sister2 = CCSprite:create("Images/grossinis_sister2.png")
local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt")
layer1:addChild(sister1)
layer1:addChild(sister2)
layer1:addChild(label)
ret:addChild( layer1, 0, kTagLayer)
sister1:setPosition( ccp( s.width*1/3, 0))
sister2:setPosition( ccp( s.width*2/3, 0))
label:setPosition( ccp( s.width/2, 0))
@ -280,12 +280,12 @@ local function LayerTestCascadingColorB()
arr:addObject(CCTintTo:create(2, 255, 0, 255))
arr:addObject(CCTintTo:create(2, 255, 255, 255))
arr:addObject(CCDelayTime:create(1))
sister1:runAction(
CCRepeatForever:create(
CCSequence:create(
arr)))
-- Enable cascading in scene
setEnableRecursiveCascading(ret, true)
return ret
@ -299,16 +299,16 @@ local function LayerTestCascadingColorC()
local layer1 = CCLayerColor:create(ccc4(255, 255, 255, 255), s.width, s.height/2)
layer1:setCascadeColorEnabled(false)
layer1:setPosition( ccp(0, s.height/2))
local sister1 = CCSprite:create("Images/grossinis_sister1.png")
local sister2 = CCSprite:create("Images/grossinis_sister2.png")
local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt")
layer1:addChild(sister1)
layer1:addChild(sister2)
layer1:addChild(label)
ret:addChild( layer1, 0, kTagLayer)
sister1:setPosition( ccp( s.width*1/3, 0))
sister2:setPosition( ccp( s.width*2/3, 0))
label:setPosition( ccp( s.width/2, 0))
@ -331,7 +331,7 @@ local function LayerTestCascadingColorC()
arr:addObject(CCTintTo:create(2, 255, 0, 255))
arr:addObject(CCTintTo:create(2, 255, 255, 255))
arr:addObject(CCDelayTime:create(1))
sister1:runAction(
CCRepeatForever:create(
CCSequence:create(
@ -348,19 +348,19 @@ local function LayerTest1()
local ret = createLayerDemoLayer("ColorLayer resize (tap & move)")
ret:setTouchEnabled(true)
local s = CCDirector:sharedDirector():getWinSize()
local layer = CCLayerColor:create( ccc4(0xFF, 0x00, 0x00, 0x80), 200, 200)
local layer = CCLayerColor:create( ccc4(0xFF, 0x00, 0x00, 0x80), 200, 200)
layer:ignoreAnchorPointForPosition(false)
layer:setPosition( ccp(s.width/2, s.height/2) )
ret:addChild(layer, 1, kTagLayer)
local function updateSize(x, y)
local s = CCDirector:sharedDirector():getWinSize()
local newSize = CCSizeMake( math.abs(x - s.width/2)*2, math.abs(y - s.height/2)*2)
local l = tolua.cast(ret:getChildByTag(kTagLayer), "CCLayerColor")
l:setContentSize( newSize )
@ -391,12 +391,12 @@ local function LayerTest2()
layer1:setPosition(ccp(s.width/3, s.height/2))
layer1:ignoreAnchorPointForPosition(false)
ret:addChild(layer1, 1)
local layer2 = CCLayerColor:create( ccc4(0, 0, 255, 255), 100, 300)
layer2:setPosition(ccp((s.width/3)*2, s.height/2))
layer2:ignoreAnchorPointForPosition(false)
ret:addChild(layer2, 1)
local actionTint = CCTintBy:create(2, -255, -127, 0)
local actionTintBack = actionTint:reverse()
local arr = CCArray:create()
@ -426,14 +426,14 @@ local function LayerTestBlend()
local ret = createLayerDemoLayer("ColorLayer: blend")
local s = CCDirector:sharedDirector():getWinSize()
local layer1 = CCLayerColor:create( ccc4(255, 255, 255, 80) )
local sister1 = CCSprite:create(s_pPathSister1)
local sister2 = CCSprite:create(s_pPathSister2)
ret:addChild(sister1)
ret:addChild(sister2)
ret:addChild(layer1, 100, kTagLayer)
sister1:setPosition( ccp( s.width*1/3, s.height/2) )
sister2:setPosition( ccp( s.width*2/3, s.height/2) )
@ -510,7 +510,7 @@ local function LayerGradient()
local s = CCDirector:sharedDirector():getWinSize()
local start = ccp(x, y)
local diff = ccpSub( ccp(s.width/2,s.height/2), start)
local diff = ccpSub( ccp(s.width/2,s.height/2), start)
diff = ccpNormalize(diff)
local gradient = tolua.cast(ret:getChildByTag(1), "CCLayerGradient")
@ -657,12 +657,12 @@ local function LayerExtendedBlendOpacityTest()
layer1:setContentSize(CCSizeMake(80, 80))
layer1:setPosition(ccp(50,50))
ret:addChild(layer1)
local layer2 = CCLayerGradient:create(ccc4(0, 0, 0, 127), ccc4(255, 255, 255, 127))
layer2:setContentSize(CCSizeMake(80, 80))
layer2:setPosition(ccp(100,90))
ret:addChild(layer2)
local layer3 = CCLayerGradient:create()
layer3:setContentSize(CCSizeMake(80, 80))
layer3:setPosition(ccp(150,140))

View File

@ -26,7 +26,7 @@ local function MenuLayerMainMenu()
ret:setTouchPriority(kCCMenuHandlerPriority + 1)
ret:setTouchMode(kCCTouchesOneByOne)
-- Font Item
-- Font Item
local spriteNormal = CCSprite:create(s_MenuItem, CCRectMake(0,23*2,115,23))
local spriteSelected = CCSprite:create(s_MenuItem, CCRectMake(0,23*1,115,23))
local spriteDisabled = CCSprite:create(s_MenuItem, CCRectMake(0,23*0,115,23))
@ -47,7 +47,7 @@ local function MenuLayerMainMenu()
local item2 = CCMenuItemImage:create(s_SendScore, s_PressSendScore)
item2:registerScriptTapHandler(menuCallback2)
local schedulerEntry = nil
local function allowTouches(dt)
@ -58,7 +58,7 @@ local function MenuLayerMainMenu()
end
local function menuCallbackDisabled(sender)
local function menuCallbackDisabled(sender)
-- hijack all touch events for 5 seconds
local pDirector = CCDirector:sharedDirector()
pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority-1, ret)
@ -73,10 +73,10 @@ local function MenuLayerMainMenu()
item3:setDisabledColor( ccc3(32,32,64) )
item3:setColor( ccc3(200,200,255) )
local function menuCallbackEnable(sender)
local function menuCallbackEnable(sender)
m_disabledItem:setEnabled(not m_disabledItem:isEnabled() )
end
-- Font Item
local item4 = CCMenuItemFont:create("I toggle enable items")
item4:registerScriptTapHandler(menuCallbackEnable)
@ -87,7 +87,7 @@ local function MenuLayerMainMenu()
local function menuCallbackConfig(sender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(3)
end
-- Label Item (CCLabelBMFont)
local label = CCLabelBMFont:create("configuration", "fonts/bitmapFontTest3.fnt")
local item5 = CCMenuItemLabel:create(label)
@ -127,7 +127,7 @@ local function MenuLayerMainMenu()
local item9 = CCMenuItemFont:create("Remove menu item when moving")
item9:registerScriptTapHandler(menuMovingCallback)
local color_action = CCTintBy:create(0.5, 0, -255, -255)
local color_back = color_action:reverse()
local arr = CCArray:create()
@ -137,7 +137,7 @@ local function MenuLayerMainMenu()
item8:runAction(CCRepeatForever:create(seq))
local menu = CCMenu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
@ -149,10 +149,10 @@ local function MenuLayerMainMenu()
menu:addChild(item9)
menu:alignItemsVertically()
-- elastic effect
local s = CCDirector:sharedDirector():getWinSize()
local i = 0
local child = nil
local pArray = menu:getChildren()
@ -186,7 +186,7 @@ local function MenuLayerMainMenu()
local function onNodeEvent(event)
if event == "exit" then
if (schedulerEntry ~= nil) then
scheduler:unscheduleScriptEntry(schedulerEntry)
scheduler:unscheduleScriptEntry(schedulerEntry)
end
if m_disabledItem ~= nil then
m_disabledItem:release()
@ -219,12 +219,12 @@ local function MenuLayer2()
menu:alignItemsHorizontally()
local x, y = menu:getPosition()
menu:setPosition( ccpAdd(ccp(x, y), ccp(0,30)) )
else
else
-- TIP: but padding is configurable
menu:alignItemsHorizontallyWithPadding(40)
local x, y = menu:getPosition()
menu:setPosition( ccpSub(ccp(x, y), ccp(0,30)) )
end
end
end
end
@ -235,15 +235,15 @@ local function MenuLayer2()
menu:setPosition( m_centeredMenu )
if i==0 then
-- TIP: if no padding, padding = 5
menu:alignItemsVertically()
menu:alignItemsVertically()
local x, y = menu:getPosition()
menu:setPosition( ccpAdd(ccp(x, y), ccp(100,0)) )
else
menu:setPosition( ccpAdd(ccp(x, y), ccp(100,0)) )
else
-- TIP: but padding is configurable
menu:alignItemsVerticallyWithPadding(40)
menu:alignItemsVerticallyWithPadding(40)
local x, y = menu:getPosition()
menu:setPosition( ccpSub(ccp(x, y), ccp(100,0)) )
end
end
end
end
@ -257,17 +257,17 @@ local function MenuLayer2()
if opacity == 128 then
menu:setOpacity(255)
else
menu:setOpacity(128)
menu:setOpacity(128)
end
end
local function menuCallbackAlign(sender)
m_alignedH = not m_alignedH
if m_alignedH then
alignMenusH()
else
alignMenusV()
alignMenusV()
end
end
@ -285,18 +285,18 @@ local function MenuLayer2()
item1:setScaleX( 1.5 )
item2:setScaleX( 0.5 )
item3:setScaleX( 0.5 )
local menu = CCMenu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
local s = CCDirector:sharedDirector():getWinSize()
menu:setPosition(ccp(s.width/2, s.height/2))
menu:setTag( kTagMenu )
ret:addChild(menu, 0, 100+i)
local x, y = menu:getPosition()
@ -340,20 +340,20 @@ local function MenuLayer3()
local item2 = CCMenuItemFont:create("--- Go Back ---")
item2:registerScriptTapHandler(menuCallback)
local spriteNormal = CCSprite:create(s_MenuItem, CCRectMake(0,23*2,115,23))
local spriteSelected = CCSprite:create(s_MenuItem, CCRectMake(0,23*1,115,23))
local spriteDisabled = CCSprite:create(s_MenuItem, CCRectMake(0,23*0,115,23))
local item3 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled)
item3:registerScriptTapHandler(menuCallback3)
m_disabledItem = item3
item3:retain()
m_disabledItem:setEnabled( false )
local menu = CCMenu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
@ -361,11 +361,11 @@ local function MenuLayer3()
menu:setPosition( ccp(0,0) )
local s = CCDirector:sharedDirector():getWinSize()
item1:setPosition( ccp(s.width/2 - 150, s.height/2) )
item2:setPosition( ccp(s.width/2 - 200, s.height/2) )
item3:setPosition( ccp(s.width/2, s.height/2 - 100) )
local jump = CCJumpBy:create(3, ccp(400,0), 50, 4)
local arr = CCArray:create()
arr:addObject(jump)
@ -375,12 +375,12 @@ local function MenuLayer3()
local spin1 = CCRotateBy:create(3, 360)
local spin2 = tolua.cast(spin1:copy():autorelease(), "CCActionInterval")
local spin3 = tolua.cast(spin1:copy():autorelease(), "CCActionInterval")
item1:runAction( CCRepeatForever:create(spin1) )
item2:runAction( CCRepeatForever:create(spin2) )
item3:runAction( CCRepeatForever:create(spin3) )
ret:addChild( menu )
ret:addChild( menu )
menu:setPosition(ccp(0,0))
@ -414,7 +414,7 @@ local function MenuLayer4()
local item1 = CCMenuItemToggle:create(CCMenuItemFont: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, "CCMenuItemToggle"):getSelectedIndex() )
end
local function backCallback(tag, sender)
@ -423,7 +423,7 @@ local function MenuLayer4()
item1:registerScriptTapHandler(menuCallback)
item1:addSubItem(CCMenuItemFont:create( "Off"))
CCMenuItemFont:setFontName( "American Typewriter" )
CCMenuItemFont:setFontSize(18)
local title2 = CCMenuItemFont:create( "Music" )
@ -432,8 +432,8 @@ local function MenuLayer4()
CCMenuItemFont:setFontSize(34)
local item2 = CCMenuItemToggle:create(CCMenuItemFont:create( "On" ))
item2:registerScriptTapHandler(menuCallback)
item2:addSubItem(CCMenuItemFont:create( "Off"))
item2:addSubItem(CCMenuItemFont:create( "Off"))
CCMenuItemFont:setFontName( "American Typewriter" )
CCMenuItemFont:setFontSize(18)
local title3 = CCMenuItemFont:create( "Quality" )
@ -443,7 +443,7 @@ local function MenuLayer4()
local item3 = CCMenuItemToggle:create(CCMenuItemFont:create( "High" ))
item3:registerScriptTapHandler(menuCallback)
item3:addSubItem(CCMenuItemFont:create( "Low" ))
CCMenuItemFont:setFontName( "American Typewriter" )
CCMenuItemFont:setFontSize(18)
local title4 = CCMenuItemFont:create( "Orientation" )
@ -453,20 +453,20 @@ local function MenuLayer4()
local item4 = CCMenuItemToggle:create(CCMenuItemFont:create( "Off" ))
item4:registerScriptTapHandler(menuCallback)
item4:getSubItems():addObject( CCMenuItemFont:create( "33%" ) )
item4:getSubItems():addObject( CCMenuItemFont:create( "66%" ) )
item4:getSubItems():addObject( CCMenuItemFont:create( "100%" ) )
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 )
local label = CCLabelBMFont:create( "go back", "fonts/bitmapFontTest3.fnt" )
local back = CCMenuItemLabel:create(label)
back:registerScriptTapHandler(backCallback)
local menu = CCMenu:create()
menu:addChild(title1)
@ -481,7 +481,7 @@ local function MenuLayer4()
-- FIXME:tolua++ doesn't support valist argument.
-- menu:alignItemsInColumns(2, 2, 2, 2, 1, NULL)
ret:addChild( menu )
local s = CCDirector:sharedDirector():getWinSize()
@ -519,7 +519,7 @@ local function MenuLayerPriorityTest()
if m_bPriority then
m_pMenu2:setHandlerPriority(kCCMenuHandlerPriority + 20)
m_bPriority = false
else
else
m_pMenu2:setHandlerPriority(kCCMenuHandlerPriority - 20)
m_bPriority = true
end
@ -580,14 +580,14 @@ local function BugsTest()
issue1410_2:registerScriptTapHandler(issue1410v2MenuCallback)
local back = CCMenuItemFont:create("Back")
back:registerScriptTapHandler(backMenuCallback)
local menu = CCMenu:create()
menu:addChild(issue1410)
menu:addChild(issue1410_2)
menu:addChild(back)
ret:addChild(menu)
menu:alignItemsVertically()
local s = CCDirector:sharedDirector():getWinSize()
menu:setPosition(ccp(s.width/2, s.height/2))
return ret
@ -597,30 +597,30 @@ end
local function RemoveMenuItemWhenMove()
local ret = CCLayer:create()
local s = CCDirector:sharedDirector():getWinSize()
local label = CCLabelTTF:create("click item and move, should not crash", "Arial", 20)
label:setPosition(ccp(s.width/2, s.height - 30))
ret:addChild(label)
local item = CCMenuItemFont:create("item 1")
item:retain()
local back = CCMenuItemFont:create("go back")
local function goBack(tag, pSender)
tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0)
end
back:registerScriptTapHandler(goBack)
local menu = CCMenu:create()
menu:addChild(item)
menu:addChild(back)
ret:addChild(menu)
menu:alignItemsVertically()
menu:setPosition(ccp(s.width/2, s.height/2))
ret:setTouchEnabled(true)
local function onNodeEvent(event)
@ -674,7 +674,7 @@ function MenuTestMain()
local layer = CCLayerMultiplex:createWithArray(arr)
scene:addChild(layer, 0)
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
return scene
end

View File

@ -25,18 +25,18 @@ local function Parallax1()
cocosImage:setScale( 2.5 )
-- change the transform anchor point to 0,0 (optional)
cocosImage:setAnchorPoint( ccp(0,0) )
-- Middle layer: a Tile map atlas
local tilemap = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16)
tilemap:releaseMap()
-- change the transform anchor to 0,0 (optional)
tilemap:setAnchorPoint( ccp(0, 0) )
-- Anti Aliased images
tilemap:getTexture():setAntiAliasTexParameters()
-- background layer: another image
local background = CCSprite:create(s_back)
@ -45,22 +45,22 @@ local function Parallax1()
-- change the transform anchor point (optional)
background:setAnchorPoint( ccp(0,0) )
-- create a void node, a parent node
local voidNode = CCParallaxNode: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, ccp(0.4,0.5), ccp(0,0))
-- tiles are moved at a ratio of 2.2x, 1.0y
voidNode:addChild(tilemap, 1, ccp(2.2,1.0), ccp(0,-200) )
-- top image is moved at a ratio of 3.0x, 2.5y
voidNode:addChild(cocosImage, 2, ccp(3.0,2.5), ccp(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
@ -75,7 +75,7 @@ local function Parallax1()
arr:addObject(goBack)
local seq = CCSequence:create(arr)
voidNode:runAction( (CCRepeatForever:create(seq) ))
ret:addChild( voidNode )
return ret
end
@ -89,45 +89,45 @@ end
local function Parallax2()
local ret = createParallaxLayer("Parallax: drag screen")
ret:setTouchEnabled( true )
-- Top Layer, a simple image
local cocosImage = CCSprite:create(s_Power)
-- scale the image (optional)
cocosImage:setScale( 2.5 )
-- change the transform anchor point to 0,0 (optional)
cocosImage:setAnchorPoint( ccp(0,0) )
-- Middle layer: a Tile map atlas
local tilemap = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16)
tilemap:releaseMap()
-- change the transform anchor to 0,0 (optional)
tilemap:setAnchorPoint( ccp(0, 0) )
-- Anti Aliased images
tilemap:getTexture():setAntiAliasTexParameters()
-- background layer: another image
local background = CCSprite:create(s_back)
-- scale the image (optional)
background:setScale( 1.5 )
-- change the transform anchor point (optional)
background:setAnchorPoint( ccp(0,0) )
-- create a void node, a parent node
local voidNode = CCParallaxNode: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, ccp(0.4,0.5), ccp(0, 0))
-- tiles are moved at a ratio of 1.0, 1.0y
voidNode:addChild(tilemap, 1, ccp(1.0,1.0), ccp(0,-200) )
-- top image is moved at a ratio of 3.0x, 2.5y
voidNode:addChild( cocosImage, 2, ccp(3.0,2.5), ccp(200,1000) )
ret:addChild(voidNode, 0, kTagNode)
@ -168,4 +168,3 @@ function ParallaxTestMain()
scene:addChild(CreateBackMenuItem())
return scene
end

View File

@ -1,4 +1,3 @@
local MID_PUSHSCENE = 100
local MID_PUSHSCENETRAN = 101
local MID_QUIT = 102
@ -22,7 +21,7 @@ SceneTestLayer1 = function()
local function onPushScene(tag, pSender)
local scene = CCScene:create()
local layer = SceneTestLayer2()
scene:addChild(layer, 0)
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():pushScene( scene )
end
@ -30,7 +29,7 @@ SceneTestLayer1 = function()
local function onPushSceneTran(tag, pSender)
local scene = CCScene:create()
local layer = SceneTestLayer2()
scene:addChild(layer, 0)
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():pushScene( CCTransitionSlideInT:create(1, scene) )
end
@ -53,9 +52,9 @@ SceneTestLayer1 = function()
arr:addObject(item3)
local menu = CCMenu:createWithArray(arr)
menu:alignItemsVertically()
ret:addChild( menu )
local s = CCDirector:sharedDirector():getWinSize()
local sprite = CCSprite:create(s_pPathGrossini)
ret:addChild(sprite)
@ -93,7 +92,7 @@ SceneTestLayer2 = function()
local function onReplaceScene(tag, pSender)
local scene = CCScene:create()
local layer = SceneTestLayer3()
scene:addChild(layer, 0)
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():replaceScene( scene )
end
@ -102,7 +101,7 @@ SceneTestLayer2 = function()
local function onReplaceSceneTran(tag, pSender)
local scene = CCScene:create()
local layer = SceneTestLayer3()
scene:addChild(layer, 0)
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():replaceScene( CCTransitionFlipX:create(2, scene) )
end
@ -119,7 +118,7 @@ SceneTestLayer2 = function()
arr:addObject(item3)
local menu = CCMenu:createWithArray(arr)
menu:alignItemsVertically()
ret:addChild( menu )
local s = CCDirector:sharedDirector():getWinSize()
@ -163,12 +162,12 @@ SceneTestLayer3 = function()
item1:registerScriptTapHandler(item1Clicked)
local item2 = CCMenuItemFont: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)
ret:addChild(menu)
menu:alignItemsVertically()
@ -188,7 +187,7 @@ function SceneTestMain()
cclog("SceneTestMain")
local scene = CCScene:create()
local layer = SceneTestLayer1()
scene:addChild(layer, 0)
scene:addChild(layer, 0)
scene:addChild(CreateBackMenuItem())
return scene
end

File diff suppressed because it is too large Load Diff

View File

@ -45,16 +45,16 @@ local function TileMapTest()
local map = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16)
-- Convert it to "alias" (GL_LINEAR filtering)
map:getTexture():setAntiAliasTexParameters()
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
-- If you are not going to use the Map, you can free it now
-- NEW since v0.7
map:releaseMap()
layer:addChild(map, 0, kTagTileMap)
map:setAnchorPoint( ccp(0, 0.5) )
local scale = CCScaleBy:create(4, 0.8)
@ -80,10 +80,10 @@ local function TileMapEditTest()
local map = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16)
-- Create an Aliased Atlas
map:getTexture():setAliasTexParameters()
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
-- If you are not going to use the Map, you can free it now
-- [tilemap releaseMap)
-- And if you are going to use, it you can access the data with:
@ -94,22 +94,22 @@ local function TileMapEditTest()
-- The value 0 not rendered so don't assign or change a tile with value 0
local tilemap = tolua.cast(layer:getChildByTag(kTagTileMap), "CCTileMapAtlas")
--
-- For example you can iterate over all the tiles
-- using this code, but try to avoid the iteration
-- over all your tiles in every frame. It's very expensive
-- for(int x=0 x < tilemap.tgaInfo:width x++)
-- for(int y=0 y < tilemap.tgaInfo:height y++)
-- for(int x=0 x < tilemap.tgaInfo:width x++)
-- for(int y=0 y < tilemap.tgaInfo:height y++)
-- ccColor3B c =[tilemap tileAt:local Make(x,y))
-- if( c.r != 0 )
-- if( c.r != 0 )
-- --------cclog("%d,%d = %d", x,y,c.r)
-- end
-- end
-- end
-- NEW since v0.7
local c = tilemap:tileAt(ccp(13,21))
local c = tilemap:tileAt(ccp(13,21))
c.r = c.r + 1
c.r = c.r % 50
@ -117,7 +117,7 @@ local function TileMapEditTest()
c.r=1
end
-- NEW since v0.7
tilemap:setTile(c, ccp(13,21) )
tilemap:setTile(c, ccp(13,21) )
end
local schedulerEntry = nil
@ -130,9 +130,9 @@ local function TileMapEditTest()
end
layer:registerScriptHandler(onNodeEvent)
layer:addChild(map, 0, kTagTileMap)
map:setAnchorPoint( ccp(0, 0) )
map:setPosition( ccp(-20,-200) )
@ -157,16 +157,16 @@ local function TMXOrthoTest()
local map = CCTMXTiledMap:create("TileMaps/orthogonal-test2.tmx")
layer:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
local pChildrenArray = map:getChildren()
local child = nil
local pObject = nil
local i = 0
local len = pChildrenArray:count()
for i = 0, len-1, 1 do
for i = 0, len-1, 1 do
pObject = pChildrenArray:objectAtIndex(i)
child = tolua.cast(pObject, "CCSpriteBatchNode")
@ -243,7 +243,7 @@ local function TMXOrthoTest3()
local layer = createTileDemoLayer("TMX anchorPoint test")
local map = CCTMXTiledMap:create("TileMaps/orthogonal-test3.tmx")
layer:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
@ -261,7 +261,7 @@ local function TMXOrthoTest3()
end
child:getTexture():setAntiAliasTexParameters()
end
map:setScale(0.2)
map:setAnchorPoint( ccp(0.5, 0.5) )
return layer
@ -277,10 +277,10 @@ local function TMXOrthoTest4()
local ret = createTileDemoLayer("TMX width/height test")
local map = CCTMXTiledMap:create("TileMaps/orthogonal-test4.tmx")
ret:addChild(map, 0, kTagTileMap)
local s1 = map:getContentSize()
cclog("ContentSize: %f, %f", s1.width,s1.height)
local pChildrenArray = map:getChildren()
local child = nil
local pObject = nil
@ -295,12 +295,12 @@ local function TMXOrthoTest4()
end
child:getTexture():setAntiAliasTexParameters()
end
map:setAnchorPoint(ccp(0, 0))
local layer = map:layerNamed("Layer 0")
local s = layer:getLayerSize()
local sprite = layer:tileAt(ccp(0,0))
sprite:setScale(2)
sprite = layer:tileAt(ccp(s.width-1,0))
@ -322,7 +322,7 @@ local function TMXOrthoTest4()
local sprite = layer0:tileAt( ccp(s.width-1,0) )
layer0:removeChild(sprite, true)
end
local function onNodeEvent(event)
if event == "enter" then
@ -351,11 +351,11 @@ local function TMXReadWriteTest()
local m_gid2 = 0
local map = CCTMXTiledMap:create("TileMaps/orthogonal-test2.tmx")
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
local layer = map:layerNamed("Layer 0")
layer:getTexture():setAntiAliasTexParameters()
@ -384,7 +384,7 @@ local function TMXReadWriteTest()
if p ~= nil then
p:removeChild(node, true)
end
end
----------cclog("atlas quantity: %d", p:textureAtlas():totalQuads())
end
@ -402,13 +402,13 @@ local function TMXReadWriteTest()
local seq1 = tolua.cast(seq0:copy():autorelease(), "CCAction")
local seq2 = tolua.cast(seq0:copy():autorelease(), "CCAction")
local seq3 = tolua.cast(seq0:copy():autorelease(), "CCAction")
tile0:runAction(seq0)
tile1:runAction(seq1)
tile2:runAction(seq2)
tile3:runAction(seq3)
m_gid = layer:tileGIDAt(ccp(0,63))
--------cclog("Tile GID at:(0,63) is: %d", m_gid)
local updateColScheduler = nil
@ -416,7 +416,7 @@ local function TMXReadWriteTest()
local removeTilesScheduler = nil
local function updateCol(dt)
local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap")
local layer = tolua.cast(map:getChildByTag(0), "CCTMXLayer")
@ -426,10 +426,10 @@ local function TMXReadWriteTest()
local s = layer:getLayerSize()
local y = 0
for y=0, s.height-1, 1 do
for y=0, s.height-1, 1 do
layer:setTileGID(m_gid2, ccp(3, y))
end
m_gid2 = (m_gid2 + 1) % 80
end
@ -437,10 +437,10 @@ local function TMXReadWriteTest()
-- unschedule:_cmd)
local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap")
local layer = tolua.cast(map:getChildByTag(0), "CCTMXLayer")
local s = layer:getLayerSize()
local x = 0
for x=0, s.width-1, 1 do
for x=0, s.width-1, 1 do
local y = s.height-1
local tmpgid = layer:tileGIDAt( ccp(x, y) )
layer:setTileGID(tmpgid+1, ccp(x, y))
@ -483,7 +483,7 @@ local function TMXReadWriteTest()
ret:registerScriptHandler(onNodeEvent)
--------cclog("++++atlas quantity: %d", layer:textureAtlas():getTotalQuads())
--------cclog("++++children: %d", layer:getChildren():count() )
m_gid2 = 0
return ret
end
@ -498,10 +498,10 @@ local function TMXHexTest()
local ret = createTileDemoLayer("TMX Hex tes")
local color = CCLayerColor:create( ccc4(64,64,64,255) )
ret:addChild(color, -1)
local map = CCTMXTiledMap:create("TileMaps/hexa-test.tmx")
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
return ret
@ -516,14 +516,14 @@ local function TMXIsoTest()
local ret = createTileDemoLayer("TMX Isometric test 0")
local color = CCLayerColor:create( ccc4(64,64,64,255) )
ret:addChild(color, -1)
local map = CCTMXTiledMap:create("TileMaps/iso-test.tmx")
ret:addChild(map, 0, kTagTileMap)
ret:addChild(map, 0, kTagTileMap)
-- move map to the center of the screen
local ms = map:getMapSize()
local ts = map:getTileSize()
map:runAction( CCMoveTo:create(1.0, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 )) )
map:runAction( CCMoveTo:create(1.0, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 )) )
return ret
end
@ -536,13 +536,13 @@ local function TMXIsoTest1()
local ret = createTileDemoLayer("TMX Isometric test + anchorPoint")
local color = CCLayerColor:create( ccc4(64,64,64,255) )
ret:addChild(color, -1)
local map = CCTMXTiledMap:create("TileMaps/iso-test1.tmx")
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
map:setAnchorPoint(ccp(0.5, 0.5))
return ret
end
@ -556,13 +556,13 @@ local function TMXIsoTest2()
local ret = createTileDemoLayer("TMX Isometric test 2")
local color = CCLayerColor:create( ccc4(64,64,64,255) )
ret:addChild(color, -1)
local map = CCTMXTiledMap:create("TileMaps/iso-test2.tmx")
ret:addChild(map, 0, kTagTileMap)
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
-- move map to the center of the screen
local ms = map:getMapSize()
local ts = map:getTileSize()
@ -579,18 +579,18 @@ local function TMXUncompressedTest()
local ret = createTileDemoLayer("TMX Uncompressed test")
local color = CCLayerColor:create( ccc4(64,64,64,255) )
ret:addChild(color, -1)
local map = CCTMXTiledMap:create("TileMaps/iso-test2-uncompressed.tmx")
ret:addChild(map, 0, kTagTileMap)
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
-- move map to the center of the screen
local ms = map:getMapSize()
local ts = map:getTileSize()
map:runAction(CCMoveTo:create(1.0, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 ) ))
-- testing release map
local pChildrenArray = map:getChildren()
local layer = nil
@ -615,13 +615,13 @@ local function TMXTilesetTest()
local ret = createTileDemoLayer("TMX Tileset test")
local map = CCTMXTiledMap:create("TileMaps/orthogonal-test5.tmx")
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
local layer = map:layerNamed("Layer 0")
layer:getTexture():setAntiAliasTexParameters()
layer = map:layerNamed("Layer 1")
layer:getTexture():setAntiAliasTexParameters()
@ -639,10 +639,10 @@ local function TMXOrthoObjectsTest()
local ret = createTileDemoLayer("TMX Ortho object test", "You should see a white box around the 3 platforms")
local map = CCTMXTiledMap:create("TileMaps/ortho-objects.tmx")
ret:addChild(map, -1, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
--------cclog("---: Iterating over all the group objets")
local group = map:objectGroupNamed("Object Group 1")
local objects = group:getObjects()
@ -650,7 +650,7 @@ local function TMXOrthoObjectsTest()
local dict = nil
local i = 0
local len = objects:count()
for i = 0, len-1, 1 do
dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary")
@ -659,7 +659,7 @@ local function TMXOrthoObjectsTest()
end
--------cclog("object: %x", dict)
end
--------cclog("---: Fetching 1 object by name")
-- local platform = group:objectNamed("platform")
--------cclog("platform: %x", platform)
@ -690,14 +690,14 @@ local function draw()
local width = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast<NSNumber*>(dict:objectForKey("width")):getNumber()
key = "height"
local height = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast<NSNumber*>(dict:objectForKey("height")):getNumber()
glLineWidth(3)
ccDrawLine( ccp(x, y), ccp((x+width), y) )
ccDrawLine( ccp((x+width), y), ccp((x+width), (y+height)) )
ccDrawLine( ccp((x+width), (y+height)), ccp(x, (y+height)) )
ccDrawLine( ccp(x, (y+height)), ccp(x, y) )
glLineWidth(1)
end
end
@ -712,7 +712,7 @@ local function TMXIsoObjectsTest()
local ret = createTileDemoLayer("TMX Iso object test", "You need to parse them manually. See bug #810")
local map = CCTMXTiledMap:create("TileMaps/iso-test-objectgroup.tmx")
ret:addChild(map, -1, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
@ -759,14 +759,14 @@ local function draw()
local width = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast<NSNumber*>(dict:objectForKey("width")):getNumber()
key = "height"
local height = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast<NSNumber*>(dict:objectForKey("height")):getNumber()
glLineWidth(3)
ccDrawLine( ccp(x,y), ccp(x+width,y) )
ccDrawLine( ccp(x+width,y), ccp(x+width,y+height) )
ccDrawLine( ccp(x+width,y+height), ccp(x,y+height) )
ccDrawLine( ccp(x,y+height), ccp(x,y) )
glLineWidth(1)
end
end
@ -781,7 +781,7 @@ local function TMXResizeTest()
local ret = createTileDemoLayer("TMX resize test", "Should not crash. Testing issue #740")
local map = CCTMXTiledMap:create("TileMaps/orthogonal-test5.tmx")
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
@ -811,14 +811,14 @@ local function TMXIsoZorder()
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
map:setPosition(ccp(-s.width/2,0))
m_tamara = CCSprite:create(s_pPathSister1)
map:addChild(m_tamara, map:getChildren():count() )
m_tamara:retain()
local mapWidth = map:getMapSize().width * map:getTileSize().width
m_tamara:setPosition(CC_POINT_PIXELS_TO_POINTS(ccp( mapWidth/2,0)))
m_tamara:setAnchorPoint(ccp(0.5,0))
local move = CCMoveBy:create(10, ccp(300,250))
local back = move:reverse()
local arr = CCArray:create()
@ -832,16 +832,16 @@ local function TMXIsoZorder()
local p = ccp(x, y)
p = CC_POINT_POINTS_TO_PIXELS(p)
local map = ret:getChildByTag(kTagTileMap)
-- there are only 4 layers. (grass and 3 trees layers)
-- if tamara < 48, z=4
-- if tamara < 96, z=3
-- if tamara < 144,z=2
local newZ = 4 - (p.y / 48)
newZ = math.max(newZ,0)
map:reorderChild(m_tamara, newZ)
map:reorderChild(m_tamara, newZ)
end
local schedulerEntry = nil
@ -857,7 +857,7 @@ local function TMXIsoZorder()
end
ret:registerScriptHandler(onNodeEvent)
return ret
end
@ -871,16 +871,16 @@ local function TMXOrthoZorder()
local ret = createTileDemoLayer("TMX Ortho Zorder", "Sprite should hide behind the trees")
local map = CCTMXTiledMap:create("TileMaps/orthogonal-test-zorder.tmx")
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
m_tamara = CCSprite:create(s_pPathSister1)
map:addChild(m_tamara, map:getChildren():count())
m_tamara:retain()
m_tamara:setAnchorPoint(ccp(0.5,0))
local move = CCMoveBy:create(10, ccp(400,450))
local back = move:reverse()
local arr = CCArray:create()
@ -894,7 +894,7 @@ local function TMXOrthoZorder()
local p = ccp(x, y)
p = CC_POINT_POINTS_TO_PIXELS(p)
local map = ret:getChildByTag(kTagTileMap)
-- there are only 4 layers. (grass and 3 trees layers)
-- if tamara < 81, z=4
-- if tamara < 162, z=3
@ -919,7 +919,7 @@ local function TMXOrthoZorder()
end
ret:registerScriptHandler(onNodeEvent)
return ret
end
@ -933,17 +933,17 @@ local function TMXIsoVertexZ()
local ret = createTileDemoLayer("TMX Iso VertexZ", "Sprite should hide behind the trees")
local map = CCTMXTiledMap:create("TileMaps/iso-test-vertexz.tmx")
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
map:setPosition( ccp(-s.width/2,0) )
cclog("ContentSize: %f, %f", s.width,s.height)
-- because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
-- can use any CCSprite and it will work OK.
local layer = map:layerNamed("Trees")
m_tamara = layer:tileAt( ccp(29,29) )
m_tamara:retain()
local move = CCMoveBy:create(10, ccpMult( ccp(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) )
local back = move:reverse()
local arr = CCArray:create()
@ -969,9 +969,9 @@ local function TMXIsoVertexZ()
CCDirector:sharedDirector():setProjection(kCCDirectorProjection2D)
schedulerEntry = scheduler:scheduleScriptFunc(repositionSprite, 0, false)
elseif event == "exit" then
-- At exit use any other projection.
-- At exit use any other projection.
-- CCDirector:sharedDirector():setProjection:kCCDirectorProjection3D)
if m_tamara ~= nil then
m_tamara:release()
end
@ -993,10 +993,10 @@ local function TMXOrthoVertexZ()
local ret = createTileDemoLayer("TMX Ortho vertexZ", "Sprite should hide behind the trees")
local map = CCTMXTiledMap:create("TileMaps/orthogonal-test-vertexz.tmx")
ret:addChild(map, 0, kTagTileMap)
local s = map:getContentSize()
cclog("ContentSize: %f, %f", s.width,s.height)
-- because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
-- can use any CCSprite and it will work OK.
local layer = map:layerNamed("trees")
@ -1028,7 +1028,7 @@ local function TMXOrthoVertexZ()
CCDirector:sharedDirector():setProjection(kCCDirectorProjection2D)
schedulerEntry = scheduler:scheduleScriptFunc(repositionSprite, 0, false)
elseif event == "exit" then
-- At exit use any other projection.
-- At exit use any other projection.
-- CCDirector:sharedDirector():setProjection:kCCDirectorProjection3D)
if m_tamara ~= nil then
m_tamara:release()
@ -1036,7 +1036,7 @@ local function TMXOrthoVertexZ()
scheduler:unscheduleScriptEntry(schedulerEntry)
end
end
return ret
end
@ -1049,7 +1049,7 @@ local function TMXIsoMoveLayer()
local ret = createTileDemoLayer("TMX Iso Move Layer", "Trees should be horizontally aligned")
local map = CCTMXTiledMap:create("TileMaps/iso-test-movelayer.tmx")
ret:addChild(map, 0, kTagTileMap)
map:setPosition(ccp(-700,-50))
local s = map:getContentSize()
@ -1139,10 +1139,10 @@ local function TMXOrthoFlipRunTimeTest()
map:runAction(action)
local function flipIt(dt)
-- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap")
-- local layer = map:layerNamed("Layer 0")
-- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap")
-- local layer = map:layerNamed("Layer 0")
-- --blue diamond
-- --blue diamond
-- local tileCoord = ccp(1,10)
-- local flags = 0
-- local GID = layer:tileGIDAt(tileCoord, (ccTMXTileFlags*)&flags)
@ -1154,13 +1154,13 @@ local function TMXOrthoFlipRunTimeTest()
-- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags)
-- tileCoord = ccp(1,8)
-- tileCoord = ccp(1,8)
-- GID = layer:tileGIDAt(tileCoord, (ccTMXTileFlags*)&flags)
-- -- Vertical
-- if( flags & kCCTMXTileVerticalFlag )
-- flags &= ~kCCTMXTileVerticalFlag
-- else
-- flags |= kCCTMXTileVerticalFlag
-- flags |= kCCTMXTileVerticalFlag
-- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags)
@ -1170,8 +1170,8 @@ local function TMXOrthoFlipRunTimeTest()
-- if( flags & kCCTMXTileHorizontalFlag )
-- flags &= ~kCCTMXTileHorizontalFlag
-- else
-- flags |= kCCTMXTileHorizontalFlag
-- layer:setTileGID(GID, tileCoord, (ccTMXTileFlags)flags)
-- flags |= kCCTMXTileHorizontalFlag
-- layer:setTileGID(GID, tileCoord, (ccTMXTileFlags)flags)
end
local schedulerEntry = nil
local function onNodeEvent(event)
@ -1197,7 +1197,7 @@ local function TMXOrthoFromXMLTest()
local file = resources.."/orthogonal-test1.tmx"
local str = CCString:createWithContentsOfFile(CCFileUtils:sharedFileUtils():fullPathForFilename(file)):getCString()
-- CCAssert(str != NULL, "Unable to open file")
-- CCAssert(str != NULL, "Unable to open file")
if (str == nil) then
cclog("Unable to open file")
end
@ -1234,7 +1234,7 @@ local function TMXBug987()
cclog("ContentSize: %f, %f", s1.width,s1.height)
local childs = map:getChildren()
local i = 0
local len = childs:count()
local pNode = nil
@ -1305,6 +1305,3 @@ function TileMapTestMain()
scene:addChild(CreateBackMenuItem())
return scene
end

View File

@ -7,29 +7,29 @@ local TRANSITION_DURATION = 1.2
local s = CCDirector:sharedDirector():getWinSize()
local function switchSceneTypeNo()
if CurSceneNo == 1 then
CurSceneNo = 2
else
CurSceneNo = 1
end
if CurSceneNo == 1 then
CurSceneNo = 2
else
CurSceneNo = 1
end
end
local function backAction()
SceneIdx = SceneIdx - 1
SceneIdx = SceneIdx - 1
if SceneIdx < 0 then
SceneIdx = SceneIdx + Transition_Table.MAX_LAYER
end
switchSceneTypeNo()
switchSceneTypeNo()
return generateTranScene()
end
local function restartAction()
return generateTranScene()
return generateTranScene()
end
local function nextAction()
SceneIdx = SceneIdx + 1
SceneIdx = SceneIdx + 1
SceneIdx = math.mod(SceneIdx, Transition_Table.MAX_LAYER)
switchSceneTypeNo()
@ -37,33 +37,33 @@ local function nextAction()
end
local function backCallback(sender)
local scene = backAction()
CCDirector:sharedDirector():replaceScene(scene)
local scene = backAction()
CCDirector:sharedDirector():replaceScene(scene)
end
local function restartCallback(sender)
local scene = restartAction()
CCDirector:sharedDirector():replaceScene(scene)
local scene = restartAction()
CCDirector:sharedDirector():replaceScene(scene)
end
local function nextCallback(sender)
local scene = nextAction()
CCDirector:sharedDirector():replaceScene(scene)
local scene = nextAction()
CCDirector:sharedDirector():replaceScene(scene)
end
-----------------------------
-- TestLayer1
-----------------------------
local function createLayer1()
local layer = CCLayer:create()
local x, y = s.width, s.height
local layer = CCLayer:create()
local x, y = s.width, s.height
local bg1 = CCSprite:create(s_back1)
bg1:setPosition(CCPointMake(s.width / 2, s.height / 2))
layer:addChild(bg1, -1)
local bg1 = CCSprite:create(s_back1)
bg1:setPosition(CCPointMake(s.width / 2, s.height / 2))
layer:addChild(bg1, -1)
local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32)
layer:addChild(titleLabel)
local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32)
layer:addChild(titleLabel)
titleLabel:setColor(ccc3(255,32,32))
titleLabel:setPosition(x / 2, y - 100)
@ -76,36 +76,36 @@ local function createLayer1()
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
local menu = CCMenu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:setPosition(CCPointMake(0, 0))
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:setPosition(CCPointMake(0, 0))
item1:setPosition(CCPointMake(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item2:setPosition(CCPointMake(s.width / 2, item2:getContentSize().height / 2))
item3:setPosition(CCPointMake(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
layer:addChild(menu, 1)
return layer
return layer
end
-----------------------------
-- TestLayer2
-----------------------------
local function createLayer2()
local layer = CCLayer:create()
local x, y = s.width, s.height
local layer = CCLayer:create()
local x, y = s.width, s.height
local bg1 = CCSprite:create(s_back2)
bg1:setPosition(CCPointMake(s.width / 2, s.height / 2))
layer:addChild(bg1, -1)
local bg1 = CCSprite:create(s_back2)
bg1:setPosition(CCPointMake(s.width / 2, s.height / 2))
layer:addChild(bg1, -1)
local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 )
local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 )
layer:addChild(titleLabel)
titleLabel:setColor(ccc3(255,32,32))
titleLabel:setPosition(x / 2, y - 100)
@ -119,147 +119,147 @@ local function createLayer2()
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
item1:registerScriptTapHandler(backCallback)
item2:registerScriptTapHandler(restartCallback)
item3:registerScriptTapHandler(nextCallback)
local menu = CCMenu:create()
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:setPosition(CCPointMake(0, 0))
menu:addChild(item1)
menu:addChild(item2)
menu:addChild(item3)
menu:setPosition(CCPointMake(0, 0))
item1:setPosition(CCPointMake(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
item2:setPosition(CCPointMake(s.width / 2, item2:getContentSize().height / 2))
item3:setPosition(CCPointMake(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
layer:addChild(menu, 1)
return layer
return layer
end
-----------------------------
-- Create Transition Test
-----------------------------
local function createTransition(index, t, scene)
CCDirector:sharedDirector():setDepthTest(false)
CCDirector:sharedDirector():setDepthTest(false)
if firstEnter == true then
firstEnter = false
return scene
end
if firstEnter == true then
firstEnter = false
return scene
end
if index == Transition_Table.CCTransitionJumpZoom then
scene = CCTransitionJumpZoom:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressRadialCCW then
scene = CCTransitionProgressRadialCCW:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressRadialCW then
scene = CCTransitionProgressRadialCW:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressHorizontal then
scene = CCTransitionProgressHorizontal:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressVertical then
scene = CCTransitionProgressVertical:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressInOut then
scene = CCTransitionProgressInOut:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressOutIn then
scene = CCTransitionProgressOutIn:create(t, scene)
elseif index == Transition_Table.CCTransitionCrossFade then
scene = CCTransitionCrossFade:create(t, scene)
if index == Transition_Table.CCTransitionJumpZoom then
scene = CCTransitionJumpZoom:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressRadialCCW then
scene = CCTransitionProgressRadialCCW:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressRadialCW then
scene = CCTransitionProgressRadialCW:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressHorizontal then
scene = CCTransitionProgressHorizontal:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressVertical then
scene = CCTransitionProgressVertical:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressInOut then
scene = CCTransitionProgressInOut:create(t, scene)
elseif index == Transition_Table.CCTransitionProgressOutIn then
scene = CCTransitionProgressOutIn:create(t, scene)
elseif index == Transition_Table.CCTransitionCrossFade then
scene = CCTransitionCrossFade:create(t, scene)
elseif index == Transition_Table.TransitionPageForward then
CCDirector:sharedDirector():setDepthTest(true)
scene = CCTransitionPageTurn:create(t, scene, false)
elseif index == Transition_Table.TransitionPageBackward then
CCDirector:sharedDirector():setDepthTest(true)
scene = CCTransitionPageTurn:create(t, scene, true)
elseif index == Transition_Table.CCTransitionFadeTR then
scene = CCTransitionFadeTR:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeBL then
scene = CCTransitionFadeBL:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeUp then
scene = CCTransitionFadeUp:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeDown then
scene = CCTransitionFadeDown:create(t, scene)
elseif index == Transition_Table.CCTransitionTurnOffTiles then
scene = CCTransitionTurnOffTiles:create(t, scene)
elseif index == Transition_Table.CCTransitionSplitRows then
scene = CCTransitionSplitRows:create(t, scene)
elseif index == Transition_Table.CCTransitionSplitCols then
scene = CCTransitionSplitCols:create(t, scene)
elseif index == Transition_Table.CCTransitionFade then
scene = CCTransitionFade:create(t, scene)
elseif index == Transition_Table.FadeWhiteTransition then
scene = CCTransitionFade:create(t, scene, ccc3(255, 255, 255))
elseif index == Transition_Table.FlipXLeftOver then
scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationLeftOver)
elseif index == Transition_Table.FlipXRightOver then
scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationRightOver)
CCDirector:sharedDirector():setDepthTest(true)
scene = CCTransitionPageTurn:create(t, scene, false)
elseif index == Transition_Table.TransitionPageBackward then
CCDirector:sharedDirector():setDepthTest(true)
scene = CCTransitionPageTurn:create(t, scene, true)
elseif index == Transition_Table.CCTransitionFadeTR then
scene = CCTransitionFadeTR:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeBL then
scene = CCTransitionFadeBL:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeUp then
scene = CCTransitionFadeUp:create(t, scene)
elseif index == Transition_Table.CCTransitionFadeDown then
scene = CCTransitionFadeDown:create(t, scene)
elseif index == Transition_Table.CCTransitionTurnOffTiles then
scene = CCTransitionTurnOffTiles:create(t, scene)
elseif index == Transition_Table.CCTransitionSplitRows then
scene = CCTransitionSplitRows:create(t, scene)
elseif index == Transition_Table.CCTransitionSplitCols then
scene = CCTransitionSplitCols:create(t, scene)
elseif index == Transition_Table.CCTransitionFade then
scene = CCTransitionFade:create(t, scene)
elseif index == Transition_Table.FadeWhiteTransition then
scene = CCTransitionFade:create(t, scene, ccc3(255, 255, 255))
elseif index == Transition_Table.FlipXLeftOver then
scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationLeftOver)
elseif index == Transition_Table.FlipXRightOver then
scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationRightOver)
elseif index == Transition_Table.FlipYUpOver then
scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationUpOver)
scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationUpOver)
elseif index == Transition_Table.FlipYDownOver then
scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationDownOver)
scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationDownOver)
elseif index == Transition_Table.FlipAngularLeftOver then
scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver)
scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver)
elseif index == Transition_Table.FlipAngularRightOver then
scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationRightOver)
scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationRightOver)
elseif index == Transition_Table.ZoomFlipXLeftOver then
scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationLeftOver)
scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationLeftOver)
elseif index == Transition_Table.ZoomFlipXRightOver then
scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationRightOver)
scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationRightOver)
elseif index == Transition_Table.ZoomFlipYUpOver then
scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationUpOver)
scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationUpOver)
elseif index == Transition_Table.ZoomFlipYDownOver then
scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationDownOver)
scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationDownOver)
elseif index == Transition_Table.ZoomFlipAngularLeftOver then
scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver)
elseif index == Transition_Table.ZoomFlipAngularRightOver then
scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationRightOver)
scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver)
elseif index == Transition_Table.ZoomFlipAngularRightOver then
scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationRightOver)
elseif index == Transition_Table.CCTransitionShrinkGrow then
scene = CCTransitionShrinkGrow:create(t, scene)
scene = CCTransitionShrinkGrow:create(t, scene)
elseif index == Transition_Table.CCTransitionRotoZoom then
scene = CCTransitionRotoZoom:create(t, scene)
scene = CCTransitionRotoZoom:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInL then
scene = CCTransitionMoveInL:create(t, scene)
scene = CCTransitionMoveInL:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInR then
scene = CCTransitionMoveInR:create(t, scene)
scene = CCTransitionMoveInR:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInT then
scene = CCTransitionMoveInT:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInB then
scene = CCTransitionMoveInB:create(t, scene)
scene = CCTransitionMoveInT:create(t, scene)
elseif index == Transition_Table.CCTransitionMoveInB then
scene = CCTransitionMoveInB:create(t, scene)
elseif index == Transition_Table.CCTransitionSlideInL then
scene = CCTransitionSlideInL:create(t, scene)
scene = CCTransitionSlideInL:create(t, scene)
elseif index == Transition_Table.CCTransitionSlideInR then
scene = CCTransitionSlideInR:create(t, scene)
scene = CCTransitionSlideInR:create(t, scene)
elseif index == Transition_Table.CCTransitionSlideInT then
scene = CCTransitionSlideInT:create(t, scene)
scene = CCTransitionSlideInT:create(t, scene)
elseif index == Transition_Table.CCTransitionSlideInB then
scene = CCTransitionSlideInB:create(t, scene)
end
scene = CCTransitionSlideInB:create(t, scene)
end
return scene
return scene
end
function generateTranScene()
local scene = CCScene:create()
local scene = CCScene:create()
local layer = nil
if CurSceneNo == 1 then
layer = createLayer1()
elseif CurSceneNo == 2 then
layer = createLayer2()
end
if CurSceneNo == 1 then
layer = createLayer1()
elseif CurSceneNo == 2 then
layer = createLayer2()
end
scene:addChild(layer)
scene:addChild(CreateBackMenuItem())
scene:addChild(CreateBackMenuItem())
return createTransition(SceneIdx, TRANSITION_DURATION, scene)
end
function TransitionsTest()
cclog("TransitionsTest")
local scene = CCScene:create()
cclog("TransitionsTest")
local scene = CCScene:create()
SceneIdx = -1
CurSceneNo = 2
firstEnter = true
SceneIdx = -1
CurSceneNo = 2
firstEnter = true
return nextAction()
return nextAction()
end

View File

@ -1,7 +1,8 @@
-- avoid memory leak
collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000)
-- avoid memory leak
collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000)
require "luaScript/mainMenu"
----------------

View File

@ -19,79 +19,79 @@ end
-- change table to enum type
function CreateEnumTable(tbl, index)
local enumTable = {}
local enumIndex = index or -1
for i, v in ipairs(tbl) do
enumTable[v] = enumIndex + i
end
return enumTable
local enumTable = {}
local enumIndex = index or -1
for i, v in ipairs(tbl) do
enumTable[v] = enumIndex + i
end
return enumTable
end
-- back menu callback
local function MainMenuCallback()
local scene = CCScene:create()
scene:addChild(CreateTestMenu())
local scene = CCScene:create()
scene:addChild(CreateTestMenu())
CCDirector:sharedDirector():replaceScene(scene)
CCDirector:sharedDirector():replaceScene(scene)
end
-- add the menu item for back to main menu
function CreateBackMenuItem()
local label = CCLabelTTF:create("MainMenu", "Arial", 20)
local MenuItem = CCMenuItemLabel:create(label)
MenuItem:registerScriptTapHandler(MainMenuCallback)
local MenuItem = CCMenuItemLabel:create(label)
MenuItem:registerScriptTapHandler(MainMenuCallback)
local s = CCDirector:sharedDirector():getWinSize()
local Menu = CCMenu:create()
local Menu = CCMenu:create()
Menu:addChild(MenuItem)
Menu:setPosition(0, 0)
MenuItem:setPosition(s.width - 50, 25)
return Menu
return Menu
end
Helper = {
index = 1,
createFunctioinTable = nil,
currentLayer = nil,
titleLabel = nil,
subtitleLabel = nil
index = 1,
createFunctioinTable = nil,
currentLayer = nil,
titleLabel = nil,
subtitleLabel = nil
}
function Helper.nextAction()
Helper.index = Helper.index + 1
if Helper.index > table.getn(Helper.createFunctionTable) then
Helper.index = 1
end
Helper.index = Helper.index + 1
if Helper.index > table.getn(Helper.createFunctionTable) then
Helper.index = 1
end
return Helper.newScene()
return Helper.newScene()
end
function Helper.backAction()
Helper.index = Helper.index - 1
if Helper.index == 0 then
Helper.index = table.getn(Helper.createFunctionTable)
end
Helper.index = Helper.index - 1
if Helper.index == 0 then
Helper.index = table.getn(Helper.createFunctionTable)
end
return Helper.newScene()
return Helper.newScene()
end
function Helper.restartAction()
return Helper.newScene()
return Helper.newScene()
end
function Helper.newScene()
local scene = CCScene:create()
Helper.currentLayer = Helper.createFunctionTable[Helper.index]()
scene:addChild(Helper.currentLayer)
local scene = CCScene:create()
Helper.currentLayer = Helper.createFunctionTable[Helper.index]()
scene:addChild(Helper.currentLayer)
scene:addChild(CreateBackMenuItem())
CCDirector:sharedDirector():replaceScene(scene)
CCDirector:sharedDirector():replaceScene(scene)
end
function Helper.initWithLayer(layer)
Helper.currentLayer = layer
Helper.currentLayer = layer
local size = CCDirector:sharedDirector():getWinSize()
local size = CCDirector:sharedDirector():getWinSize()
Helper.titleLabel = CCLabelTTF:create("", "Arial", 28)
layer:addChild(Helper.titleLabel, 1)
Helper.titleLabel:setPosition(size.width / 2, size.height - 50)
@ -131,5 +131,3 @@ function createTestLayer(title, subtitle)
Helper.subtitleLabel:setString(subTitleStr)
return layer
end

View File

@ -11,58 +11,58 @@ local BeginPos = {x = 0, y = 0}
-- create scene
local function CreateTestScene(nIdx)
CCDirector:sharedDirector():purgeCachedData()
CCDirector:sharedDirector():purgeCachedData()
local scene = nil
if nIdx == Test_Table.TEST_ACTIONS then
scene = ActionsTest()
elseif nIdx == Test_Table.TEST_TRANSITIONS then
scene = TransitionsTest()
elseif nIdx == Test_Table.TEST_PROGRESS_ACTIONS then
scene = ProgressActionsTest()
local scene = nil
if nIdx == Test_Table.TEST_ACTIONS then
scene = ActionsTest()
elseif nIdx == Test_Table.TEST_TRANSITIONS then
scene = TransitionsTest()
elseif nIdx == Test_Table.TEST_PROGRESS_ACTIONS then
scene = ProgressActionsTest()
elseif nIdx == Test_Table.TEST_EFFECTS then
scene = EffectsTest()
scene = EffectsTest()
elseif nIdx == Test_Table.TEST_CLICK_AND_MOVE then
scene = ClickAndMoveTest()
scene = ClickAndMoveTest()
elseif nIdx == Test_Table.TEST_ROTATE_WORLD then
scene = RotateWorldTest()
scene = RotateWorldTest()
elseif nIdx == Test_Table.TEST_PARTICLE then
scene = ParticleTest()
scene = ParticleTest()
elseif nIdx == Test_Table.TEST_EASE_ACTIONS then
scene = EaseActionsTest()
scene = EaseActionsTest()
elseif nIdx == Test_Table.TEST_MOTION_STREAK then
scene = MotionStreakTest()
scene = MotionStreakTest()
elseif nIdx == Test_Table.TEST_DRAW_PRIMITIVES then
scene = DrawPrimitivesTest()
scene = DrawPrimitivesTest()
elseif nIdx == Test_Table.TEST_COCOSNODE then
scene = CocosNodeTest()
scene = CocosNodeTest()
elseif nIdx == Test_Table.TEST_TOUCHES then
scene = TouchesTest()
scene = TouchesTest()
elseif nIdx == Test_Table.TEST_MENU then
scene = MenuTestMain()
scene = MenuTestMain()
elseif nIdx == Test_Table.TEST_ACTION_MANAGER then
scene = ActionManagerTestMain()
scene = ActionManagerTestMain()
elseif nIdx == Test_Table.TEST_LAYER then
scene = LayerTestMain()
scene = LayerTestMain()
elseif nIdx == Test_Table.TEST_SCENE then
scene = SceneTestMain()
scene = SceneTestMain()
elseif nIdx == Test_Table.TEST_PARALLAX then
scene = ParallaxTestMain()
scene = ParallaxTestMain()
elseif nIdx == Test_Table.TEST_TILE_MAP then
scene = TileMapTestMain()
scene = TileMapTestMain()
elseif nIdx == Test_Table.TEST_INTERVAL then
scene = IntervalTestMain()
scene = IntervalTestMain()
elseif nIdx == Test_Table.TEST_CHIPMUNKACCELTOUCH then
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- pScene = new ChipmunkAccelTouchTestScene()
--#else
--#ifdef MARMALADEUSECHIPMUNK
--#if (MARMALADEUSECHIPMUNK == 1)
-- pScene = new ChipmunkAccelTouchTestScene();
--#endif
-- break;
--#endif
--#endif
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- pScene = new ChipmunkAccelTouchTestScene()
--#else
--#ifdef MARMALADEUSECHIPMUNK
--#if (MARMALADEUSECHIPMUNK == 1)
-- pScene = new ChipmunkAccelTouchTestScene();
--#endif
-- break;
--#endif
--#endif
elseif nIdx == Test_Table.TEST_LABEL then
scene = LabelTest()
elseif nIdx == Test_Table.TEST_TEXT_INPUT then
@ -75,7 +75,7 @@ local function CreateTestScene(nIdx)
elseif nIdx == Test_Table.TEST_RENDERTEXTURE then
elseif nIdx == Test_Table.TEST_TEXTURE2D then
scene = Texture2dTestMain()
elseif nIdx == Test_Table.TEST_BOX2D then
elseif nIdx == Test_Table.TEST_BOX2DBED then
@ -84,23 +84,23 @@ local function CreateTestScene(nIdx)
elseif nIdx == Test_Table.TEST_ACCELEROMRTER then
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
-- elseif nIdx == Test_Table.TEST_KEYPAD then
-- pScene = new KeypadTestScene()
--#endif
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
-- elseif nIdx == Test_Table.TEST_KEYPAD then
-- pScene = new KeypadTestScene()
--#endif
elseif nIdx == Test_Table.TEST_COCOSDENSHION then
elseif nIdx == Test_Table.TEST_PERFORMANCE then
scene = PerformanceTest()
scene = PerformanceTest()
elseif nIdx == Test_Table.TEST_ZWOPTEX then
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- bada don't support libcurl
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
-- elseif nIdx == Test_Table.TEST_CURL then
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- bada don't support libcurl
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
-- elseif nIdx == Test_Table.TEXT_CURL then
--#endif
--#endif
--#endif
--#endif
elseif nIdx == Test_Table.TEST_USERDEFAULT then
elseif nIdx == Test_Table.TEST_BUGS then
@ -109,88 +109,88 @@ local function CreateTestScene(nIdx)
elseif nIdx == Test_Table.TEST_CURRENT_LANGUAGE then
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- elseif nIdx == Test_Table.TEST_TEXTURECACHE then pScene = new TextureCacheTestScene()
--#endif
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- elseif nIdx == Test_Table.TEST_TEXTURECACHE then pScene = new TextureCacheTestScene()
--#endif
elseif nIdx == Test_Table.TEST_EXTENSIONS then
elseif nIdx == Test_Table.TEST_SHADER then
elseif nIdx == Test_Table.TEST_MUTITOUCH then
end
end
return scene
return scene
end
-- create menu
function CreateTestMenu()
local menuLayer = CCLayer:create()
local menuLayer = CCLayer:create()
local function closeCallback()
CCDirector:sharedDirector():endToLua()
end
local function closeCallback()
CCDirector:sharedDirector():endToLua()
end
local function menuCallback(tag)
local function menuCallback(tag)
print(tag)
local Idx = tag - 10000
local testScene = CreateTestScene(Idx)
if testScene then
CCDirector:sharedDirector():replaceScene(testScene)
end
end
local Idx = tag - 10000
local testScene = CreateTestScene(Idx)
if testScene then
CCDirector:sharedDirector():replaceScene(testScene)
end
end
-- add close menu
local s = CCDirector:sharedDirector():getWinSize()
local CloseItem = CCMenuItemImage:create(s_pPathClose, s_pPathClose)
CloseItem:registerScriptTapHandler(closeCallback)
CloseItem:setPosition(ccp(s.width - 30, s.height - 30))
-- add close menu
local s = CCDirector:sharedDirector():getWinSize()
local CloseItem = CCMenuItemImage:create(s_pPathClose, s_pPathClose)
CloseItem:registerScriptTapHandler(closeCallback)
CloseItem:setPosition(ccp(s.width - 30, s.height - 30))
local CloseMenu = CCMenu:create()
CloseMenu:setPosition(0, 0)
CloseMenu:addChild(CloseItem)
menuLayer:addChild(CloseMenu)
CloseMenu:addChild(CloseItem)
menuLayer:addChild(CloseMenu)
-- add menu items for tests
-- add menu items for tests
local MainMenu = CCMenu:create()
for index, labelName in pairs(Test_Name) do
local testLabel = CCLabelTTF:create(labelName, "Arial", 24)
local testLabel = CCLabelTTF:create(labelName, "Arial", 24)
local testMenuItem = CCMenuItemLabel:create(testLabel)
testMenuItem:registerScriptTapHandler(menuCallback)
testMenuItem:setPosition(ccp(s.width / 2, (s.height - (index + 1) * LINE_SPACE)))
testMenuItem:registerScriptTapHandler(menuCallback)
testMenuItem:setPosition(ccp(s.width / 2, (s.height - (index + 1) * LINE_SPACE)))
MainMenu:addChild(testMenuItem, index + 10000, index + 10000)
end
MainMenu:setContentSize(CCSizeMake(s.width, (Test_Table.TESTS_COUNT + 1) * (LINE_SPACE)))
MainMenu:setPosition(CurPos.x, CurPos.y)
menuLayer:addChild(MainMenu)
MainMenu:setPosition(CurPos.x, CurPos.y)
menuLayer:addChild(MainMenu)
-- handling touch events
-- handling touch events
local function onTouchBegan(x, y)
BeginPos = {x = x, y = y}
BeginPos = {x = x, y = y}
-- CCTOUCHBEGAN event must return true
return true
end
local function onTouchMoved(x, y)
local nMoveY = y - BeginPos.y
local curPosx, curPosy = MainMenu:getPosition()
local nextPosy = curPosy + nMoveY
local winSize = CCDirector:sharedDirector():getWinSize()
if nextPosy < 0 then
MainMenu:setPosition(0, 0)
return
end
local curPosx, curPosy = MainMenu:getPosition()
local nextPosy = curPosy + nMoveY
local winSize = CCDirector:sharedDirector():getWinSize()
if nextPosy < 0 then
MainMenu:setPosition(0, 0)
return
end
if nextPosy > ((Test_Table.TESTS_COUNT + 1) * LINE_SPACE - winSize.height) then
MainMenu:setPosition(0, ((Test_Table.TESTS_COUNT + 1) * LINE_SPACE - winSize.height))
return
end
if nextPosy > ((Test_Table.TESTS_COUNT + 1) * LINE_SPACE - winSize.height) then
MainMenu:setPosition(0, ((Test_Table.TESTS_COUNT + 1) * LINE_SPACE - winSize.height))
return
end
MainMenu:setPosition(curPosx, nextPosy)
BeginPos = {x = x, y = y}
CurPos = {x = curPosx, y = nextPosy}
MainMenu:setPosition(curPosx, nextPosy)
BeginPos = {x = x, y = y}
CurPos = {x = curPosx, y = nextPosy}
end
local function onTouch(eventType, x, y)
@ -201,7 +201,7 @@ function CreateTestMenu()
end
end
menuLayer:setTouchEnabled(true)
menuLayer:setTouchEnabled(true)
menuLayer:registerScriptTouchHandler(onTouch)
return menuLayer

View File

@ -22,6 +22,7 @@ require "luaScript/ActionManagerTest/ActionManagerTest"
require "luaScript/MenuTest/MenuTest"
require "luaScript/IntervalTest/IntervalTest"
require "luaScript/SceneTest/SceneTest"
require "luaScript/Texture2dTest/Texture2dTest"
----------------------------------------------------
-- tests scene
@ -52,7 +53,7 @@ Test_Table =
"TEST_SPRITE",
-- "TEST_SCHEDULER",
-- "TEST_RENDERTEXTURE",
-- "TEST_TEXTURE2D",
"TEST_TEXTURE2D",
-- "TEST_BOX2D",
-- "TEST_BOX2DBED",
-- "TEST_EFFECT_ADVANCE",
@ -102,7 +103,7 @@ Test_Name =
"SpriteTest",
-- "SchdulerTest",
-- "RenderTextureTest",
-- "Texture2DTest",
"Texture2DTest",
-- "Box2dTest",
-- "Box2dTestBed",
-- "EffectAdvancedTest",

View File

@ -1 +1 @@
256b5df66d15bca73f7d298f6879cef231d54ba8
7e014e0a330f7a2b8db9413abf8cabe173dd5cfe

View File

@ -1,3 +1,432 @@
/* OpenGL ES core versions */
#define GL_ES_VERSION_2_0 1
/* ClearBufferMask */
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
/* Boolean */
#define GL_FALSE 0
#define GL_TRUE 1
/* BeginMode */
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
#define GL_LINE_STRIP 0x0003
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
/* AlphaFunction (not supported in ES20) */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* BlendingFactorDest */
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
/* BlendingFactorSrc */
/* GL_ZERO */
/* GL_ONE */
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
/* GL_SRC_ALPHA */
/* GL_ONE_MINUS_SRC_ALPHA */
/* GL_DST_ALPHA */
/* GL_ONE_MINUS_DST_ALPHA */
/* BlendEquationSeparate */
#define GL_FUNC_ADD 0x8006
#define GL_BLEND_EQUATION 0x8009
#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
#define GL_BLEND_EQUATION_ALPHA 0x883D
/* BlendSubtract */
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
/* Separate Blend Functions */
#define GL_BLEND_DST_RGB 0x80C8
#define GL_BLEND_SRC_RGB 0x80C9
#define GL_BLEND_DST_ALPHA 0x80CA
#define GL_BLEND_SRC_ALPHA 0x80CB
#define GL_CONSTANT_COLOR 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
/* CullFaceMode */
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_FRONT_AND_BACK 0x0408
/* DepthFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* EnableCap */
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_BLEND 0x0BE2
#define GL_DITHER 0x0BD0
#define GL_STENCIL_TEST 0x0B90
#define GL_DEPTH_TEST 0x0B71
#define GL_SCISSOR_TEST 0x0C11
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_COVERAGE 0x80A0
/* ErrorCode */
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_OUT_OF_MEMORY 0x0505
/* FrontFaceDirection */
#define GL_CW 0x0900
#define GL_CCW 0x0901
/* GetPName */
#define GL_LINE_WIDTH 0x0B21
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_STENCIL_BACK_FUNC 0x8800
#define GL_STENCIL_BACK_FAIL 0x8801
#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
#define GL_STENCIL_BACK_REF 0x8CA3
#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
#define GL_VIEWPORT 0x0BA2
#define GL_SCISSOR_BOX 0x0C10
/* GL_SCISSOR_TEST */
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#define GL_SUBPIXEL_BITS 0x0D50
#define GL_RED_BITS 0x0D52
#define GL_GREEN_BITS 0x0D53
#define GL_BLUE_BITS 0x0D54
#define GL_ALPHA_BITS 0x0D55
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
/* GL_POLYGON_OFFSET_FILL */
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
/* HintMode */
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
/* HintTarget */
#define GL_GENERATE_MIPMAP_HINT 0x8192
/* DataType */
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
/* PixelFormat */
#define GL_DEPTH_COMPONENT 0x1902
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
/* PixelType */
/* GL_UNSIGNED_BYTE */
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
/* Shaders */
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_MAX_VERTEX_ATTRIBS 0x8869
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GL_SHADER_TYPE 0x8B4F
#define GL_DELETE_STATUS 0x8B80
#define GL_LINK_STATUS 0x8B82
#define GL_VALIDATE_STATUS 0x8B83
#define GL_ATTACHED_SHADERS 0x8B85
#define GL_ACTIVE_UNIFORMS 0x8B86
#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GL_ACTIVE_ATTRIBUTES 0x8B89
#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_CURRENT_PROGRAM 0x8B8D
/* StencilFunction */
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
#define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
/* StencilOp */
/* GL_ZERO */
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
#define GL_INVERT 0x150A
#define GL_INCR_WRAP 0x8507
#define GL_DECR_WRAP 0x8508
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
/* TextureMagFilter */
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
/* TextureMinFilter */
/* GL_NEAREST */
/* GL_LINEAR */
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
/* TextureParameterName */
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
/* TextureTarget */
/* GL_TEXTURE_2D */
#define GL_TEXTURE 0x1702
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
/* TextureUnit */
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
#define GL_TEXTURE3 0x84C3
#define GL_TEXTURE4 0x84C4
#define GL_TEXTURE5 0x84C5
#define GL_TEXTURE6 0x84C6
#define GL_TEXTURE7 0x84C7
#define GL_TEXTURE8 0x84C8
#define GL_TEXTURE9 0x84C9
#define GL_TEXTURE10 0x84CA
#define GL_TEXTURE11 0x84CB
#define GL_TEXTURE12 0x84CC
#define GL_TEXTURE13 0x84CD
#define GL_TEXTURE14 0x84CE
#define GL_TEXTURE15 0x84CF
#define GL_TEXTURE16 0x84D0
#define GL_TEXTURE17 0x84D1
#define GL_TEXTURE18 0x84D2
#define GL_TEXTURE19 0x84D3
#define GL_TEXTURE20 0x84D4
#define GL_TEXTURE21 0x84D5
#define GL_TEXTURE22 0x84D6
#define GL_TEXTURE23 0x84D7
#define GL_TEXTURE24 0x84D8
#define GL_TEXTURE25 0x84D9
#define GL_TEXTURE26 0x84DA
#define GL_TEXTURE27 0x84DB
#define GL_TEXTURE28 0x84DC
#define GL_TEXTURE29 0x84DD
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
/* Uniform Types */
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
#define GL_INT_VEC2 0x8B53
#define GL_INT_VEC3 0x8B54
#define GL_INT_VEC4 0x8B55
#define GL_BOOL 0x8B56
#define GL_BOOL_VEC2 0x8B57
#define GL_BOOL_VEC3 0x8B58
#define GL_BOOL_VEC4 0x8B59
#define GL_FLOAT_MAT2 0x8B5A
#define GL_FLOAT_MAT3 0x8B5B
#define GL_FLOAT_MAT4 0x8B5C
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_CUBE 0x8B60
/* Vertex Arrays */
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
/* Read Format */
#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
/* Shader Source */
#define GL_COMPILE_STATUS 0x8B81
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
#define GL_SHADER_COMPILER 0x8DFA
/* Shader Binary */
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
/* Shader Precision-Specified Types */
#define GL_LOW_FLOAT 0x8DF0
#define GL_MEDIUM_FLOAT 0x8DF1
#define GL_HIGH_FLOAT 0x8DF2
#define GL_LOW_INT 0x8DF3
#define GL_MEDIUM_INT 0x8DF4
#define GL_HIGH_INT 0x8DF5
/* Framebuffer Object. */
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
#define GL_RGBA4 0x8056
#define GL_RGB5_A1 0x8057
#define GL_RGB565 0x8D62
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_STENCIL_INDEX 0x1901
#define GL_STENCIL_INDEX8 0x8D48
#define GL_RENDERBUFFER_WIDTH 0x8D42
#define GL_RENDERBUFFER_HEIGHT 0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_STENCIL_ATTACHMENT 0x8D20
#define GL_NONE 0
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_FRAMEBUFFER_BINDING 0x8CA6
#define GL_RENDERBUFFER_BINDING 0x8CA7
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
typedef enum {
// kCCTexture2DPixelFormat_Automatic = 0,