| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /*
- * @Author: mojunshou 1637302775@qq.com
- * @Date: 2025-03-12 11:17:12
- * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-12 14:39:32
- * @Description:
- */
- import { EventTouch } from "cc";
- import { _decorator } from "cc";
- import { oops } from "db://oops-framework/core/Oops";
- import { ecs } from "db://oops-framework/libs/ecs/ECS";
- import { CCVMParentComp } from "db://oops-framework/module/common/CCVMParentComp";
- import { UIID } from "../config/GameUIConfig";
- import { Slider } from "cc";
- const { ccclass, property } = _decorator;
- /** 视图层对象 - 支持 MVVM 框架的数据绑定 */
- @ccclass('SetViewComp')
- @ecs.register('SetView', false)
- export class SetViewComp extends CCVMParentComp {
- /** 脚本控制的界面 MVVM 框架绑定数据 */
- /** VM 组件绑定数据 */
- data: any = {
- /** 音乐音量进度 */
- finished: 0,
- /** 音乐音量 */
- total: 0,
- /** 加载资源进度比例值 */
- progress: "0",
- };
- private progress: number = 0;
- /** 视图层逻辑代码分离演示 */
- protected start() {
- this.data.progress = 0;
- this.setButton();
- //监听
- }
- private btn_close(event: EventTouch) {
- console.log("关闭页面");
- oops.gui.remove(UIID.Setting)
- }
- //VMEvent的改变回调
- private onTest(newNum: any, oldNum: any) {
- console.log(newNum, "==========", oldNum);
- }
- //滑动的回调
- private onSliderCallback(event: Slider) {
- console.log("slider回调===========", event);
- let progress = event.progress;
- //保留两位小数
- let num = Math.round(progress * 100) / 100;
- this.data.progress = num;
- }
- /** 加载进度事件 */
- // private onProgressCallback(finished: number, total: number, item: any) {
- // oops.log.logView(finished, ">>>>>>>>>>>>>>>")
- // this.data.finished = finished;
- // this.data.total = total;
- // var progress = finished / total;
- // if (progress > this.progress) {
- // this.progress = progress;
- // this.data.progress = (progress * 100).toFixed(2);
- // }
- // }
- /** 视图对象通过 ecs.Entity.remove(SetViewComp) 删除组件是触发组件处理自定义释放逻辑 */
- reset() {
- this.node.destroy();
- }
- }
|