-
Notifications
You must be signed in to change notification settings - Fork 115
Format
$ fecs format [target...]
$ fecs format [target...] --type=js,css
使用 eslint与 esformatter 对 当前目录
下所有 JavaScript 代码进行格式化。
使用 csscomb 对 当前目录
下所有 CSS 代码进行格式化。
使用 HTMLCS 对 当前目录
下所有 HTML 代码进行格式化。
参见 FECS 命令参数
- 格式化后的代码默认保存在当前目录下的 output 内,如需替换,请使用 --replace 参数
- 默认格式并且仅使用 ESFormatter,如需使用 ESLint 的 fix,请使用 --fix 参数。
// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import AssetMgr from './framework/AssetMgr'; import AudioMgr from './framework/AudioMgr'; import EventMgr from './framework/EventMgr'; import ObjectPoolMgr from './framework/ObjectPoolMgr'; import TimerMgr from './framework/TimerMgr'; import UIMgr from './framework/UIMgr'; import Instance from './framework/utils/Instance'; import PropMgr from './logic/common/PropMgr'; import UserInfo from './logic/common/UserInfo'; import ArtDataMgr from './logic/data/ArtDataMgr'; import ConfigArtGroupMgr from './logic/data/ConfigArtGroupMgr'; import ConfigArtMgr from './logic/data/ConfigArtMgr'; import ConfigMgr from './logic/data/ConfigMgr'; import SaveDataMgr from './logic/data/SaveDataMgr'; import HttpLogicMgr from './logic/net/HttpLogicMgr'; import GridMgr from './logic/painting/GridMgr'; import PaintingGridDataMgr from './logic/painting/PaintingGridDataMgr'; import PaintingPaletteDataMgr from './logic/painting/PaintingPaletteDataMgr'; import StarBlinkEffectMgr from './logic/ui/effects/StarBlinkEffectMgr';
const { ccclass, property } = cc._decorator;
@ccclass export default class App extends cc.Component { static UIRoot: cc.Node = null; static timerMgr: TimerMgr = null; static eventMgr: EventMgr = null; static assetMgr: AssetMgr = null; static uiMgr: UIMgr = null; static poolMgr: ObjectPoolMgr = null; static httpMgr: HttpLogicMgr = null; static audioMgr: AudioMgr = null; static userInfo: UserInfo = null; static gridMgr: GridMgr = null; static paintingPaletteDataMgr: PaintingPaletteDataMgr = null; static saveDataMgr: SaveDataMgr = null; static paintingGridDataMgr: PaintingGridDataMgr = new PaintingGridDataMgr(); static propMgr: PropMgr = null; static artDataMgr: ArtDataMgr = null; private static configMgr: ConfigMgr = null; static configArtMgr: ConfigArtMgr = null; static configArtGroupMgr: ConfigArtGroupMgr = null;; /** * 测试网络开关 / static isOpenNetwork: boolean = true; /* * 是否是链接本地 / static isLocalNetwork: boolean = true; /* * 是否开启网络log */ static isOpenNetworkLog: boolean = true;
async onLoad() {
App.UIRoot = cc.find('Canvas/UIRoot');
// cc.debug.setDisplayStats(false);
// cc.game.setFrameRate(30)
// 注册单例
App.eventMgr = Instance.get(EventMgr);
App.timerMgr = Instance.get(TimerMgr);
App.assetMgr = Instance.get(AssetMgr);
App.poolMgr = Instance.get(ObjectPoolMgr);
App.httpMgr = Instance.get(HttpLogicMgr);
App.audioMgr = Instance.get(AudioMgr);
App.userInfo = Instance.get(UserInfo);
App.paintingGridDataMgr = Instance.get(PaintingGridDataMgr);
App.paintingPaletteDataMgr = Instance.get(PaintingPaletteDataMgr);
App.propMgr = Instance.get(PropMgr);
App.saveDataMgr = Instance.get(SaveDataMgr);
App.artDataMgr = Instance.get(ArtDataMgr);
App.gridMgr = Instance.get(GridMgr);
/** ----初始化数据库 */
const dbOk = await App.saveDataMgr.init(UserInfo.PaintingDataKey);// 增加新的数据表需要同时修改版本号
console.log('dbOk = ' + dbOk);
// App.userInfo.clearAllDatas()
/** ----加载数据 */
App.userInfo.loadData();
/** ----初始化ui管理 */
// 注册事件监听
App.eventMgr.registerOwner(UIMgr);
// 初始化ui管理类
App.uiMgr = Instance.get(UIMgr).init(App.UIRoot);
/** ----加载art数据 编辑器生成的 */
await App.artDataMgr.loadData();
await this.cacheViews(['PaintingView']);
/** ----初始化configs */
App.configMgr = Instance.get(ConfigMgr);
await App.configMgr.loadConfig('dataConfigs');
App.configArtGroupMgr = Instance.get(ConfigArtGroupMgr).init(App.configMgr.getTable('artGroup'));
App.configArtMgr = Instance.get(ConfigArtMgr).init(App.configMgr.getTable('art'));
/** ----初始化tile缓存 */
let prefab = await App.assetMgr.load('prefabs/TiledTile', cc.Prefab);
App.poolMgr.createObjectPool('TiledTile', (prefab as cc.Prefab), 110 * 110 * 4);
prefab = await App.assetMgr.loadPrefab('prefabs/StarArrayEffect');
App.poolMgr.createObjectPool('StarArrayEffect', (prefab as cc.Prefab), 110 * 110 * 4);
prefab = await App.assetMgr.loadPrefab('prefabs/StarBlinkEffect');
App.poolMgr.createObjectPool('StarBlinkEffect', (prefab as cc.Prefab), 300);
/** ----进入游戏 */
App.uiMgr.showView('HomeBottomView', 0);
cc.game.setFrameRate(30);
}
private async cacheViews(names: string[]) {
for (let index = 0; index < names.length; index++) {
const name = names[index];
const Prefab = await App.assetMgr.load(`ui/${name}`, cc.Prefab);
App.poolMgr.createObjectPool(name, (Prefab as cc.Prefab), 1);
}
}
update(dt) {
App.timerMgr.update(dt);
}
/**
* 显示绘制界面
* @param data
*/
static async GotoPainting(data: any) {
App.userInfo.paintingRecord(data.id);
App.userInfo.saveData();
await App.uiMgr.showView('PaintingView', data);
App.uiMgr.hideView('HomeBottomView');
App.uiMgr.hideView('CutImageView');
// cc.game.setFrameRate(60);
}
/**
* 回到主界面
*/
static async GotoHome() {
if (!App.uiMgr.isViewShow('HomeBottomView')) {
await App.uiMgr.showView('HomeBottomView');
}
}
}