EffectSelected.lua 1.79 KB
local EffectSelected = class("EffectSelected",function (rect,type)
    local selected_box;
    if type == EnumNodeType.POKER or type == EnumNodeType.DDZ_POKER then
        selected_box = ccui.Scale9Sprite:create("res/common/selected_box_common.png");
--        selected_box:setCapInsets(cc.rect(30,30,48,17));
--        selected_box:setContentSize(cc.size(rect.width+30,rect.height+30));
    elseif type == EnumNodeType.MAIL then
        selected_box = ccui.Scale9Sprite:create("res/common/selected_box_mail.png");
--        selected_box:setCapInsets(cc.rect(25,25,1122,52));
--        selected_box:setContentSize(cc.size(rect.width+20,rect.height+20));
    else
        selected_box = ccui.Scale9Sprite:create("res/common/selected_box_common.png");
--        selected_box:setCapInsets(cc.rect(30,30,48,17));
--        selected_box:setContentSize(cc.size(rect.width+35,rect.height+35));
    end
    return selected_box;
end)
    
function EffectSelected:ctor(rect,type)
    self:init(rect,type);
    self:resize(rect,type);
end

function EffectSelected:init(rect,type)
    local fadeIn = cc.FadeIn:create(0.7);
    local fadeOut = cc.FadeOut:create(0.7);

    local repeatAction = cc.RepeatForever:create(cc.Sequence:create(fadeIn,fadeOut));
    self:runAction(repeatAction);
end

function EffectSelected:resize(rect,type)
    if type == EnumNodeType.POKER or type == EnumNodeType.DDZ_POKER then
        self:setCapInsets(cc.rect(30,30,48,17));
        self:setContentSize(cc.size(rect.width+30,rect.height+30));
    elseif type == EnumNodeType.MAIL then
        self:setCapInsets(cc.rect(25,25,1122,52));
        self:setContentSize(cc.size(rect.width+20,rect.height+20));
    else
        self:setCapInsets(cc.rect(58,58,6,6));
        self:setContentSize(cc.size(rect.width+48,rect.height+48));
    end
end

return EffectSelected