2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local SceneIdx = -1
|
|
|
|
local MAX_LAYER = 13
|
|
|
|
|
|
|
|
local kTagAction1 = 1
|
|
|
|
local kTagAction2 = 2
|
|
|
|
local kTagSlider = 1
|
|
|
|
|
|
|
|
local titleLabel = nil
|
|
|
|
local s = CCDirector:sharedDirector():getWinSize()
|
|
|
|
local scheduler = CCDirector:sharedDirector():getScheduler()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local function createSimpleMoveBy()
|
|
|
|
return CCMoveBy:create(3, CCPointMake(s.width - 130, 0))
|
|
|
|
end
|
|
|
|
|
|
|
|
local function createSimpleDelayTime()
|
|
|
|
return CCDelayTime:create(0.25)
|
|
|
|
end
|
|
|
|
|
2012-08-30 15:35:04 +08:00
|
|
|
local function backAction()
|
|
|
|
SceneIdx = SceneIdx - 1
|
|
|
|
if SceneIdx < 0 then
|
|
|
|
SceneIdx = SceneIdx + MAX_LAYER
|
|
|
|
end
|
|
|
|
|
2012-08-31 18:25:28 +08:00
|
|
|
return CreateActionsEaseLayer()
|
2012-08-30 15:35:04 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function restartAction()
|
2012-08-31 18:25:28 +08:00
|
|
|
return CreateActionsEaseLayer()
|
2012-08-30 15:35:04 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function nextAction()
|
|
|
|
SceneIdx = SceneIdx + 1
|
|
|
|
SceneIdx = math.mod(SceneIdx, MAX_LAYER)
|
|
|
|
|
2012-08-31 18:25:28 +08:00
|
|
|
return CreateActionsEaseLayer()
|
2012-08-30 15:35:04 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function backCallback(sender)
|
|
|
|
local scene = CCScene:create()
|
|
|
|
|
|
|
|
scene:addChild(backAction())
|
|
|
|
scene:addChild(CreateBackMenuItem())
|
|
|
|
|
|
|
|
CCDirector:sharedDirector():replaceScene(scene)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function restartCallback(sender)
|
|
|
|
local scene = CCScene:create()
|
|
|
|
|
|
|
|
scene:addChild(restartAction())
|
|
|
|
scene:addChild(CreateBackMenuItem())
|
|
|
|
|
|
|
|
CCDirector:sharedDirector():replaceScene(scene)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function nextCallback(sender)
|
|
|
|
local scene = CCScene:create()
|
|
|
|
|
|
|
|
scene:addChild(nextAction())
|
|
|
|
scene:addChild(CreateBackMenuItem())
|
|
|
|
|
|
|
|
CCDirector:sharedDirector():replaceScene(scene)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function positionForTwo()
|
|
|
|
grossini:setPosition(CCPointMake(60, s.height * 1 / 5))
|
|
|
|
tamara:setPosition(CCPointMake(60, s.height * 4 / 5))
|
|
|
|
kathia:setVisible(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function getBaseLayer()
|
|
|
|
local layer = CCLayer:create()
|
|
|
|
|
|
|
|
grossini = CCSprite:create(s_pPathGrossini)
|
|
|
|
tamara = CCSprite:create(s_pPathSister1)
|
|
|
|
kathia = CCSprite:create(s_pPathSister2)
|
|
|
|
|
|
|
|
layer:addChild(grossini, 3)
|
|
|
|
layer:addChild(kathia, 2)
|
|
|
|
layer:addChild(tamara, 1)
|
|
|
|
|
|
|
|
grossini:setPosition(CCPointMake(60, s.height * 1 / 5))
|
|
|
|
kathia:setPosition(CCPointMake(60, s.height * 2.5 / 5))
|
|
|
|
tamara:setPosition(CCPointMake(60, s.height * 4 / 5))
|
|
|
|
|
|
|
|
titleLabel = CCLabelTTF:create("", "Arial", 32)
|
|
|
|
layer:addChild(titleLabel)
|
|
|
|
titleLabel:setPosition(s.width / 2, s.height - 50)
|
|
|
|
|
|
|
|
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
|
|
|
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
|
|
|
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
2012-09-11 17:13:20 +08:00
|
|
|
item1:registerScriptTapHandler(backCallback)
|
|
|
|
item2:registerScriptTapHandler(restartCallback)
|
|
|
|
item3:registerScriptTapHandler(nextCallback)
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local menu = CCMenu:create()
|
|
|
|
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
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEase
|
|
|
|
-----------------------------------
|
|
|
|
local SpriteEase_entry = nil
|
|
|
|
|
|
|
|
local function testStopAction(dt)
|
|
|
|
scheduler:unscheduleScriptEntry(SpriteEase_entry)
|
|
|
|
tamara:stopActionByTag(1)
|
|
|
|
kathia:stopActionByTag(1)
|
|
|
|
grossini:stopActionByTag(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function SpriteEase_onEnterOrExit(tag)
|
2013-03-05 14:46:18 +08:00
|
|
|
if tag == "enter" then
|
2012-08-30 15:35:04 +08:00
|
|
|
SpriteEase_entry = scheduler:scheduleScriptFunc(testStopAction, 6.25, false)
|
2013-03-05 14:46:18 +08:00
|
|
|
elseif tag == "exit" then
|
2012-08-30 15:35:04 +08:00
|
|
|
scheduler:unscheduleScriptEntry(SpriteEase_entry)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function SpriteEase()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_in = CCEaseIn:create(createSimpleMoveBy(), 2.5)
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_in_back = move_ease_in:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_out = CCEaseOut:create(createSimpleMoveBy(), 2.5)
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_out_back = move_ease_out:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease_in)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_in_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
local arr3 = CCArray:create()
|
|
|
|
arr3:addObject(move_ease_out)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr3:addObject(move_ease_out_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq3 = CCSequence:create(arr3)
|
|
|
|
|
|
|
|
local a2 = grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
a2:setTag(1)
|
|
|
|
local a1 = tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
a1:setTag(1)
|
|
|
|
local a = kathia:runAction(CCRepeatForever:create(seq3))
|
|
|
|
a:setTag(1)
|
|
|
|
|
|
|
|
layer:registerScriptHandler(SpriteEase_onEnterOrExit)
|
|
|
|
|
|
|
|
titleLabel:setString("EaseIn - EaseOut - Stop")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseInOut
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseInOut()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_inout1 = CCEaseInOut:create(createSimpleMoveBy(), 0.65)
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_inout_back1 = move_ease_inout1:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_inout2 = CCEaseInOut:create(createSimpleMoveBy(), 1.35)
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_inout_back2 = move_ease_inout2:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_inout3 = CCEaseInOut:create(createSimpleMoveBy(), 1.0)
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_inout_back3 = move_ease_inout3:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move_ease_inout1)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_ease_inout_back1)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease_inout2)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_inout_back2)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
local arr3 = CCArray:create()
|
|
|
|
arr3:addObject(move_ease_inout3)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr3:addObject(move_ease_inout_back3)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq3 = CCSequence:create(arr3)
|
|
|
|
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq1))
|
|
|
|
kathia:runAction(CCRepeatForever:create(seq2))
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq3))
|
|
|
|
|
|
|
|
titleLabel:setString("EaseInOut and rates")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseExponential
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseExponential()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_in = CCEaseExponentialIn:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_in_back = move_ease_in:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_out = CCEaseExponentialOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_out_back = move_ease_out:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
|
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease_in)
|
2013-03-01 17:09:42 +08:00
|
|
|
|
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_in_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
|
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
local arr3 = CCArray:create()
|
|
|
|
arr3:addObject(move_ease_out)
|
2013-03-01 17:09:42 +08:00
|
|
|
|
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr3:addObject(move_ease_out_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
|
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq3 = CCSequence:create(arr3)
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
kathia:runAction(CCRepeatForever:create(seq3))
|
|
|
|
|
|
|
|
titleLabel:setString("ExpIn - ExpOut actions")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseExponentialInOut
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseExponentialInOut()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease = CCEaseExponentialInOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_back = move_ease:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
|
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease)
|
2013-03-01 17:09:42 +08:00
|
|
|
|
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
|
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
positionForTwo()
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
|
|
|
|
titleLabel:setString("EaseExponentialInOut action")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseSine
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseSine()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_in = CCEaseSineIn:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_in_back = move_ease_in:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_out = CCEaseSineOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_out_back = move_ease_out:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease_in)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_in_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
local arr3 = CCArray:create()
|
|
|
|
arr3:addObject(move_ease_out)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr3:addObject(move_ease_out_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq3 = CCSequence:create(arr3)
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
kathia:runAction(CCRepeatForever:create(seq3))
|
|
|
|
|
|
|
|
titleLabel:setString("EaseSineIn - EaseSineOut")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseSineInOut
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseSineInOut()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease = CCEaseSineInOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_back = move_ease:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
positionForTwo()
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
|
|
|
|
titleLabel:setString("EaseSineInOut action")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseElastic
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseElastic()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_in = CCEaseElasticIn:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_in_back = move_ease_in:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_out = CCEaseElasticOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_out_back = move_ease_out:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease_in)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_in_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
local arr3 = CCArray:create()
|
|
|
|
arr3:addObject(move_ease_out)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr3:addObject(move_ease_out_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq3 = CCSequence:create(arr3)
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
kathia:runAction(CCRepeatForever:create(seq3))
|
|
|
|
|
|
|
|
titleLabel:setString("Elastic In - Out actions")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseElasticInOut
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseElasticInOut()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_inout1 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.3)
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_inout_back1 = move_ease_inout1:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_inout2 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.45)
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_inout_back2 = move_ease_inout2:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_inout3 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.6)
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_inout_back3 = move_ease_inout3:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move_ease_inout1)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_ease_inout_back1)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease_inout2)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_inout_back2)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
local arr3 = CCArray:create()
|
|
|
|
arr3:addObject(move_ease_inout3)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr3:addObject(move_ease_inout_back3)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq3 = CCSequence:create(arr3)
|
|
|
|
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq1))
|
|
|
|
kathia:runAction(CCRepeatForever:create(seq2))
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq3))
|
|
|
|
|
|
|
|
titleLabel:setString("EaseElasticInOut action")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseBounce
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseBounce()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_in = CCEaseBounceIn:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_in_back = move_ease_in:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_out = CCEaseBounceOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_out_back = move_ease_out:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease_in)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_in_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
local arr3 = CCArray:create()
|
|
|
|
arr3:addObject(move_ease_out)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr3:addObject(move_ease_out_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq3 = CCSequence:create(arr3)
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
kathia:runAction(CCRepeatForever:create(seq3))
|
|
|
|
|
|
|
|
titleLabel:setString("Bounce In - Out actions")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseBounceInOut
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseBounceInOut()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease = CCEaseBounceInOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_back = move_ease:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
positionForTwo()
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
|
|
|
|
titleLabel:setString("EaseBounceInOut action")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseBack
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseBack()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_in = CCEaseBackIn:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_in_back = move_ease_in:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease_out = CCEaseBackOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_out_back = move_ease_out:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease_in)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_in_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
local arr3 = CCArray:create()
|
|
|
|
arr3:addObject(move_ease_out)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr3:addObject(move_ease_out_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr3:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq3 = CCSequence:create(arr3)
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
kathia:runAction(CCRepeatForever:create(seq3))
|
|
|
|
|
|
|
|
titleLabel:setString("Back In - Out actions")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpriteEaseBackInOut
|
|
|
|
-----------------------------------
|
|
|
|
local function SpriteEaseBackInOut()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move = createSimpleMoveBy()
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_back = move:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local move_ease = CCEaseBackInOut:create(createSimpleMoveBy())
|
2012-08-30 15:35:04 +08:00
|
|
|
local move_ease_back = move_ease:reverse()
|
|
|
|
|
2013-03-01 17:09:42 +08:00
|
|
|
local delay = createSimpleDelayTime()
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
local arr1 = CCArray:create()
|
|
|
|
arr1:addObject(move)
|
|
|
|
arr1:addObject(delay)
|
|
|
|
arr1:addObject(move_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr1:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq1 = CCSequence:create(arr1)
|
|
|
|
|
|
|
|
local arr2 = CCArray:create()
|
|
|
|
arr2:addObject(move_ease)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
arr2:addObject(move_ease_back)
|
2013-03-01 17:09:42 +08:00
|
|
|
arr2:addObject(createSimpleDelayTime())
|
2012-08-30 15:35:04 +08:00
|
|
|
local seq2 = CCSequence:create(arr2)
|
|
|
|
|
|
|
|
positionForTwo()
|
|
|
|
|
|
|
|
grossini:runAction(CCRepeatForever:create(seq1))
|
|
|
|
tamara:runAction(CCRepeatForever:create(seq2))
|
|
|
|
|
|
|
|
titleLabel:setString("EaseBackInOut action")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- SpeedTest
|
|
|
|
-----------------------------------
|
|
|
|
local SpeedTest_entry = nil
|
|
|
|
local SpeedTest_action1 = nil
|
|
|
|
local SpeedTest_action2 = nil
|
|
|
|
local SpeedTest_action3 = nil
|
|
|
|
|
|
|
|
local function altertime(dt)
|
|
|
|
SpeedTest_action1:setSpeed(math.random() * 2)
|
|
|
|
SpeedTest_action2:setSpeed(math.random() * 2)
|
|
|
|
SpeedTest_action3:setSpeed(math.random() * 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function SpeedTest_onEnterOrExit(tag)
|
2013-03-01 17:09:42 +08:00
|
|
|
if tag == "enter" then
|
2012-08-30 15:35:04 +08:00
|
|
|
SpeedTest_entry = scheduler:scheduleScriptFunc(altertime, 1.0, false)
|
2013-03-01 17:09:42 +08:00
|
|
|
elseif tag == "exit" then
|
2012-08-30 15:35:04 +08:00
|
|
|
scheduler:unscheduleScriptEntry(SpeedTest_entry)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function SpeedTest()
|
|
|
|
local layer = getBaseLayer()
|
|
|
|
|
|
|
|
local jump1 = CCJumpBy:create(4, CCPointMake(- s.width + 80, 0), 100, 4)
|
|
|
|
local jump2 = jump1:reverse()
|
|
|
|
local rot1 = CCRotateBy:create(4, 360 * 2)
|
|
|
|
local rot2 = rot1:reverse()
|
|
|
|
|
|
|
|
local seq3_1 = CCSequence:createWithTwoActions(jump2, jump1)
|
|
|
|
local seq3_2 = CCSequence:createWithTwoActions(rot1, rot2)
|
|
|
|
|
|
|
|
local spawn = CCSpawn:createWithTwoActions(seq3_1, seq3_2)
|
|
|
|
SpeedTest_action1 = CCSpeed:create(CCRepeatForever:create(spawn), 1.0)
|
|
|
|
|
2013-03-05 14:46:18 +08:00
|
|
|
local spawn2 = tolua.cast(spawn:copy():autorelease(), "CCSpawn")
|
2012-08-30 15:35:04 +08:00
|
|
|
SpeedTest_action2 = CCSpeed:create(CCRepeatForever:create(spawn2), 1.0)
|
|
|
|
|
2013-03-05 14:46:18 +08:00
|
|
|
local spawn3 = tolua.cast(spawn:copy():autorelease(), "CCSpawn")
|
2012-08-30 15:35:04 +08:00
|
|
|
SpeedTest_action3 = CCSpeed:create(CCRepeatForever:create(spawn3), 1.0)
|
|
|
|
|
|
|
|
grossini:runAction(SpeedTest_action2)
|
|
|
|
tamara:runAction(SpeedTest_action3)
|
|
|
|
kathia:runAction(SpeedTest_action1)
|
|
|
|
|
|
|
|
layer:registerScriptHandler(SpeedTest_onEnterOrExit)
|
|
|
|
|
|
|
|
titleLabel:setString("Speed action")
|
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------
|
|
|
|
-- Actions Ease Test
|
|
|
|
-----------------------------------
|
2012-08-31 18:25:28 +08:00
|
|
|
function CreateActionsEaseLayer()
|
2012-08-30 15:35:04 +08:00
|
|
|
if SceneIdx == 0 then
|
|
|
|
return SpriteEase()
|
|
|
|
elseif SceneIdx == 1 then
|
|
|
|
return SpriteEaseInOut()
|
|
|
|
elseif SceneIdx == 2 then
|
|
|
|
return SpriteEaseExponential()
|
|
|
|
elseif SceneIdx == 3 then
|
|
|
|
return SpriteEaseExponentialInOut()
|
|
|
|
elseif SceneIdx == 4 then
|
|
|
|
return SpriteEaseSine()
|
|
|
|
elseif SceneIdx == 5 then
|
|
|
|
return SpriteEaseSineInOut()
|
|
|
|
elseif SceneIdx == 6 then
|
|
|
|
return SpriteEaseElastic()
|
|
|
|
elseif SceneIdx == 7 then
|
|
|
|
return SpriteEaseElasticInOut()
|
|
|
|
elseif SceneIdx == 8 then
|
|
|
|
return SpriteEaseBounce()
|
|
|
|
elseif SceneIdx == 9 then
|
|
|
|
return SpriteEaseBounceInOut()
|
|
|
|
elseif SceneIdx == 10 then
|
|
|
|
return SpriteEaseBack()
|
|
|
|
elseif SceneIdx == 11 then
|
|
|
|
return SpriteEaseBackInOut()
|
|
|
|
elseif SceneIdx == 12 then
|
|
|
|
return SpeedTest()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function EaseActionsTest()
|
|
|
|
local scene = CCScene:create()
|
|
|
|
|
|
|
|
SceneIdx = -1
|
|
|
|
scene:addChild(nextAction())
|
|
|
|
scene:addChild(CreateBackMenuItem())
|
|
|
|
|
|
|
|
return scene
|
|
|
|
end
|