123456789101112131415161718192021222324252627282930313233343536373839 |
- import { _decorator, Component, Node, SpriteFrame, tween, Vec3 ,Sprite,Prefab} from 'cc';
- const { ccclass, property } = _decorator;
- @ccclass('CountDown')
- export class CountDown extends Component {
- @property(Node)
- countdown_12:Node = null;
- @property([SpriteFrame])
- images:SpriteFrame[] = [];
-
- imageDisplay:Sprite = null;
- countdownDuration:number = 4;
- displayTime:number = 1;
- isOver:boolean = false;
- start() {
- this.imageDisplay = this.node.getChildByPath("countdown_11/countdown_01").getComponent(Sprite);
- this.showCountDown();
- }
- showCountDown(){
- tween(this.countdown_12)
- .to(this.countdownDuration,{eulerAngles : new Vec3 (0,0,360*4)})
- //.call(()=>{this.imageDisplay.enabled = false})
- .call(()=>{this.isOver = true ; this.node.destroy()})
- .start();
- for(let i = 0;i < 4;i++){
- this.scheduleOnce(()=>{
- this.showImage(i);
- },i * this.displayTime)
- }
- }
- showImage(index:number){
- this.imageDisplay.spriteFrame = this.images[index];
- this.imageDisplay.enabled = true;
- }
- update(dt: number) {
-
- }
- }
|