Commit e3444d18 authored by asdf's avatar asdf

后面page隐藏

parent 65bfed2a
......@@ -860,6 +860,9 @@
"nodMask": {
"__id__": 20
},
"nodGroup": {
"__id__": 2
},
"layoutText": {
"__id__": 14
},
......
/**
* 事件模块
* onfire.js
*
*/
interface Listener {
cb: Function;
once: boolean;
target: object;
}
interface EventsType {
[eventName: string]: Listener[];
}
class EventMgr {
// 所有事件的监听器
es: EventsType = {};
on(eventName: string, cb: Function, target: object) {
if (!this.es[eventName]) {
this.es[eventName] = [];
}
this.es[eventName].push({
cb,
once: false,
target,
});
}
once(eventName: string, cb: Function, target: object) {
if (!this.es[eventName]) {
this.es[eventName] = [];
}
this.es[eventName].push({
cb,
once: true,
target,
});
}
emit(eventName: string, params?: any) {
const listeners = this.es[eventName] || [];
let l = listeners.length;
for (let i = 0; i < l; i++) {
const { cb, once, target } = listeners[i];
let args = [eventName, params];
cb.apply(target, args);
if (once) {
listeners.splice(i, 1);
i--;
l--;
}
}
}
off(eventName?: string, cb?: Function, target?: object) {
// clean all
if (eventName === undefined) {
this.es = {};
} else {
if (cb === undefined) {
// clean the eventName's listeners
delete this.es[eventName];
} else if (cb === null) {
if (!target) {
return;
}
const listeners = this.es[eventName] || [];
// clean the event and listener
let l = listeners.length;
for (let i = 0; i < l; i++) {
if (listeners[i].target === target) {
listeners.splice(i, 1);
i--;
l--;
}
}
} else {
const listeners = this.es[eventName] || [];
// clean the event and listener
let l = listeners.length;
for (let i = 0; i < l; i++) {
if (listeners[i].cb === cb && listeners[i].target === target) {
listeners.splice(i, 1);
i--;
l--;
}
}
}
}
}
}
export default new EventMgr();
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "abecd9d7-e7a7-41a8-9ee7-54079d07c873",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
const Color_texts = ['#BE1AC1', '#24C11A', '#1A1DC1', '#9F5307'];
import EventMgr from './EventMgr';
cc.Class({
extends: cc.Component,
......@@ -13,10 +14,20 @@ cc.Class({
onEnable() {
this.node.on('touchend', this.onTouchEnd, this);
EventMgr.on('refreshMask', this.onRefreshMask, this)
},
onDisable() {
this.node.off('touchend', this.onTouchEnd, this);
EventMgr.off('refreshMask', this.onRefreshMask, this)
},
onRefreshMask() {
if (GameData._currPageIndex + 1 >= this.index) {
this.node.opacity = 255;
} else {
this.node.opacity = 0;
}
},
onTouchEnd(event) {
......@@ -223,7 +234,7 @@ cc.Class({
this.dragonBone.dragonAtlasAsset = null;
this.dragonBone.dragonAsset = null;
this.dragonBone.armatureName = '';
this.scheduleOnce(()=>{
this.scheduleOnce(() => {
this.loadSpine();
})
},
......
const { exchangeNodePos2 } = require("./utils");
import EventMgr from './EventMgr';
const saveKey = "DataKey_Cocos_Test";
cc.Class({
......@@ -279,6 +279,7 @@ cc.Class({
}
this._indicatorList.push(comp);
}
},
/**
......@@ -298,6 +299,9 @@ cc.Class({
comp.showMask();
}
}
this.scheduleOnce(()=>{
EventMgr.emit('refreshMask')
})
},
// 下一页
......@@ -382,11 +386,13 @@ cc.Class({
onPageDownDone() {
GameData._isPageTurning = false;
this.refreshIndicator(true);
EventMgr.emit('refreshMask')
},
onPageUpDone() {
GameData._isPageTurning = false;
this.refreshIndicator();
EventMgr.emit('refreshMask')
},
refreshIndicator(isPageDown) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment