| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import {_decorator, Component, Node, UITransform} from 'cc';
- const {ccclass, property} = _decorator;
- @ccclass('TimeProgress')
- export class TimeProgress extends Component {
- public maxTime: number = 15
- private orignWidth: number = 1200
- private step: number = 0
- onLoad() {
- this.orignWidth = this.node.getChildByName("PMask").getComponent(UITransform).width
- // console.log("0000000000= "+this.orignWidth);
- }
- start() {
- }
- update(deltaTime: number) {
- }
- public prepair(maxTime: number = 15) {
- this.node.getChildByName("PMask").getComponent(UITransform).width = this.orignWidth
- this.maxTime = maxTime
- }
- public startProgress() {
- this.step = this.node.getChildByName("PMask").getComponent(UITransform).width / this.maxTime
- this.schedule(this.goProgress, 1, this.maxTime, 0);
- }
- private goProgress() {
- let w = this.node.getChildByName("PMask").getComponent(UITransform).width
- w -= this.step
- this.node.getChildByName("PMask").getComponent(UITransform).width = w
- if (w <= 0) {
- }
- }
- public stopProgress() {
- this.unschedule(this.goProgress)
- this.node.active = false
- }
- }
|