12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import { EventType, ObserverManager } from '../Manager/core/EventManager';
- import PrefabManager from '../Manager/core/PrefabManager';
- import { UIID } from '../Manager/core/UIID';
- import CCUtils from '../Utiles/CCUtils';
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class MainHome extends cc.Component {
- /** 头部导航栏 */
- private headNode: cc.Node = null;
- /** 底部栏 */
- private bottomNode: cc.Node = null;
- /** selectPrefab */
- private selectPrefab: cc.Node = null;
- private storeBtn: cc.Node = null;
- start() {}
- protected onLoad(): void {}
- /**
- * 初始化
- *
- * @protected
- * @memberof Main
- */
- protected onEnable(): void {
- this.initComponent();
- // 加载选择歌曲界面
- PrefabManager.open(UIID.SongSelector, this.node, (node: cc.Node) => {
- this.selectPrefab = node;
- this.setZindex();
- });
- this.setAdaptation();
- }
- protected onDisable(): void {
- ObserverManager.removeObserver(EventType.OpenGame);
- }
- /**
- * 初始化组件
- *
- * @private
- * @memberof MainHome
- */
- private initComponent(): void {
- this.headNode = CCUtils.findChild(this.node, 'headLayer');
- this.bottomNode = CCUtils.findChild(this.node, 'bottomLayer');
- this.storeBtn = CCUtils.findChild(this.bottomNode, 'storeBtn');
- var seq = cc.repeatForever(
- cc.sequence(
- cc.scaleTo(1, 0.9),
- cc.scaleTo(1, 1.0),
- cc.jumpBy(1.0, cc.v2(0, 0), 20, 1)
- )
- );
- this.storeBtn.runAction(seq);
- }
- private setZindex(): void {
- this.headNode.zIndex = 1;
- this.bottomNode.zIndex = 1;
- this.selectPrefab.zIndex = 0;
- }
- /**
- * 适配
- *
- * @private
- * @memberof SongSelector
- */
- private setAdaptation(): void {
- // 设置适配
- const height: number = this.node.parent.height;
- console.log('===height===', height);
- this.headNode.y = height / 2;
- }
- }
|