2012-08-30 15:35:04 +08:00
|
|
|
local kTagAction1 = 1
|
|
|
|
local kTagAction2 = 2
|
|
|
|
local kTagSlider = 1
|
|
|
|
|
|
|
|
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 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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.initWithLayer(layer)
|
2012-08-30 15:35:04 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("EaseIn - EaseOut - Stop")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("EaseInOut and rates")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("ExpIn - ExpOut actions")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("EaseExponentialInOut action")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("EaseSineIn - EaseSineOut")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("EaseSineInOut action")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("Elastic In - Out actions")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("EaseElasticInOut action")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("Bounce In - Out actions")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("EaseBounceInOut action")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("Back In - Out actions")
|
2012-08-30 15:35:04 +08:00
|
|
|
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))
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("EaseBackInOut action")
|
2012-08-30 15:35:04 +08:00
|
|
|
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-06-19 12:08:26 +08:00
|
|
|
local spawn2 = tolua.cast(spawn:clone(), "CCSpawn")
|
2012-08-30 15:35:04 +08:00
|
|
|
SpeedTest_action2 = CCSpeed:create(CCRepeatForever:create(spawn2), 1.0)
|
|
|
|
|
2013-06-19 12:08:26 +08:00
|
|
|
local spawn3 = tolua.cast(spawn:clone(), "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)
|
|
|
|
|
2013-03-13 17:45:09 +08:00
|
|
|
Helper.titleLabel:setString("Speed action")
|
2012-08-30 15:35:04 +08:00
|
|
|
return layer
|
|
|
|
end
|
|
|
|
|
|
|
|
function EaseActionsTest()
|
|
|
|
local scene = CCScene:create()
|
2013-03-13 17:45:09 +08:00
|
|
|
cclog("EaseActionsTest")
|
|
|
|
|
|
|
|
Helper.createFunctionTable = {
|
|
|
|
SpriteEase,
|
|
|
|
SpriteEaseInOut,
|
|
|
|
SpriteEaseExponential,
|
|
|
|
SpriteEaseExponentialInOut,
|
|
|
|
SpriteEaseSine,
|
|
|
|
SpriteEaseSineInOut,
|
|
|
|
SpriteEaseElastic,
|
|
|
|
SpriteEaseElasticInOut,
|
|
|
|
SpriteEaseBounce,
|
|
|
|
SpriteEaseBounceInOut,
|
|
|
|
SpriteEaseBack,
|
|
|
|
SpriteEaseBackInOut,
|
|
|
|
SpeedTest
|
|
|
|
}
|
|
|
|
|
|
|
|
scene:addChild(SpriteEase())
|
2012-08-30 15:35:04 +08:00
|
|
|
scene:addChild(CreateBackMenuItem())
|
|
|
|
|
|
|
|
return scene
|
|
|
|
end
|