import { _decorator, Component, EventTouch, Input, input, Label, math, Node, Sprite, spriteAssembler, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('sj1')
export class sj1 extends Component {
@property({group:{name:'m1'},type:SpriteFrame})
ff1:SpriteFrame=null
@property({group:{name:'m1'},type:SpriteFrame})
ff2:SpriteFrame=null
@property({group:{name:'y1'},type:SpriteFrame})
ff3:SpriteFrame=null
@property({group:{name:'y1'},type:SpriteFrame})
ff4:SpriteFrame=null
@property({group:{name:'z1'},type:SpriteFrame})
ff5:SpriteFrame=null
@property({group:{name:'z1'},type:SpriteFrame})
ff6:SpriteFrame=null
i:number = 0
start() {
input.on(Input.EventType.TOUCH_START,this.onTouchStart,this)
}
onTouchStart(event:EventTouch){
let gnd1 = this.node.getChildByName('ccb11').getChildByName('wb1')
let mei1 = this.node.getChildByName('ccb3')
let mei2 = this.node.getChildByName('ccb6')
let mei3 = this.node.getChildByName('ccb9')
let eve1:string[] = [
'我们去爬山吧',
"听说那边山上有个山洞,我们去看看吧,很刺激的",
'说不定,里面会有什么宝贝呢',
'要是有宝贝,我们就平分了,怎么样?'
]
if(this.i <= eve1.length){
if(this.i == eve1.length){this.i = 0}
gnd1.getComponent(Label).string = eve1[this.i++]
}
if(math.random() > 0.8){mei1.getComponent(Sprite).spriteFrame = this.ff1}
else{mei1.getComponent(Sprite).spriteFrame = this.ff2}
if(math.random() < 0.2){mei2.getComponent(Sprite).spriteFrame = this.ff3}
else{mei2.getComponent(Sprite).spriteFrame = this.ff4}
if(math.random() > 0.3){mei3.getComponent(Sprite).spriteFrame = this.ff5}
else{mei3.getComponent(Sprite).spriteFrame = this.ff6}
}
update(deltaTime: number) {
}
}