axmol/samples/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua

89 lines
2.6 KiB
Lua
Raw Normal View History

require "luaScript/EffectsTest/EffectsName"
2012-08-23 16:10:50 +08:00
local ActionIdx = 0
2012-08-27 11:43:47 +08:00
local s = CCDirector:sharedDirector():getWinSize()
2012-08-23 16:10:50 +08:00
local kTagTextLayer = 1
local kTagBackground = 1
local kTagLabel = 2
2012-08-27 11:43:47 +08:00
local titleLabel = nil
2012-08-23 16:10:50 +08:00
2012-08-27 11:43:47 +08:00
local function checkAnim(dt)
end
local function getAction()
return CreateEffect(ActionIdx, 3)
end
local function initWithLayer(layer)
x, y = s.width, s.height
local node = CCNode:create()
local effect = getAction()
node:runAction(effect)
addChild(node, 0, kTagBackground)
local bg = CCSprite:create(s_back3)
node:addChild(bg, 0)
bg:setPosition(CCPointMake(s.width / 2, s.height / 2))
local grossini = CCSprite:create(s_pPathSister2)
node:addChild(grossini, 1)
grossini:setPosition( CCPointMake(x / 3, y / 2) )
local sc = CCScaleBy:create(2, 5)
local sc_back = sc:reverse()
grossini:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc, sc_back)))
local tamara = CCSprite:create(s_pPathSister1)
node:addChild(tamara, 1)
tamara:setPosition(CCPointMake(2 * x / 3, y / 2))
local sc2 = CCScaleBy:create(2, 5)
local sc2_back = sc2:reverse()
tamara:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc2, sc2_back)))
titleLabel = CCLabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32)
titleLabel:setPosition(CCPointMake(x / 2, y - 80))
addChild(titleLabel)
titleLabel:setTag(kTagLabel)
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
item1:registerScriptHandler(backCallback)
item2:registerScriptHandler(restartCallback)
item3:registerScriptHandler(nextCallback)
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)
--schedule( schedule_selector(TextLayer:checkAnim) )
2012-08-23 16:10:50 +08:00
end
--------------------------------------
-- Entrance
--------------------------------------
function EffectsTest()
cclog("EffectsTest")
local scene = CCScene:create()
local layer = CCLayerColor:create(ccc4(32,128,32,255))
initWithLayer(layer)
scene:addChild(layer)
2012-08-27 11:43:47 +08:00
scene:addChild(CreateBackMenuItem())
2012-08-23 16:10:50 +08:00
return scene
end