|
-
- local touchEcFile = "res/effect/CommonEffect/ef_shubiaodianji/ef_shubiaodianji_02.effect"
-
- local bIgnore = false;
-
- local touchBeforeListener = nil;
- local touchAfterListener = nil;
-
- local touchEffectNode = nil;
- function showClickEffect(pos)
- --创建前把之前的移除
- ignoreCurTouchEffect();
-
- -- 创建一个光效
- local touchEffect = createEffect(touchEcFile);
- -- 默认要播放
- touchEffect:play();
- -- 播放完毕自动删除
- touchEffect:setOnStoped(ignoreCurTouchEffect);
-
- touchEffectNode = cc.GroupNodeIn2D:create();
- touchEffectNode:setTranslation({x=pos.x,y=pos.y,z=0});
- touchEffectNode:addChild(touchEffect);
-
- app.mainScene:addChild(touchEffectNode , UIZOrder.TipsOrder);
- --showTooltip("show");
- end
-
- function addGlobalTouchEffectListener()
-
- touchBeforeListener = cc.EventListenerTouchOneByOne:create()
- touchBeforeListener:setSwallowTouches(false);
- local function onBeforeBegan(touch , event)
- bIgnore = false;
- local pos = touch:getLocation();
- showClickEffect(pos)
- return false;
- end
- touchBeforeListener:registerScriptHandler(onBeforeBegan, cc.Handler.EVENT_TOUCH_BEGAN)
- cc.Director:getInstance():getEventDispatcher():addEventListenerWithFixedPriority(touchBeforeListener , -1)
-
- end
-
- --忽略此次点击光效
- function ignoreCurTouchEffect()
- if(touchEffectNode)then
- touchEffectNode:removeFromParent()
- touchEffectNode = nil;
- --showTooltip("remove");
- end
- end
|