update
This commit is contained in:
@@ -1,31 +1,27 @@
|
||||
import { _decorator, Component, Label, tween, Tween, Vec2, Vec3 } from 'cc'
|
||||
import { Component, Label, Tween, Vec2, Vec3, _decorator, tween } from 'cc'
|
||||
|
||||
const { ccclass, property } = _decorator
|
||||
|
||||
@ccclass('ScorePrefab')
|
||||
export default class ScorePrefab extends Component {
|
||||
@property({ type: Label })
|
||||
private txtScore: Label | null = null
|
||||
public init(score: number) {
|
||||
if (score <= 0) {
|
||||
this.txtScore.string = 'Miss'
|
||||
} else {
|
||||
this.txtScore.string = score + ''
|
||||
}
|
||||
}
|
||||
@property({ type: Label })
|
||||
private txtScore: Label | null = null
|
||||
|
||||
public playMoveEffect(p: Vec2, callback: Function = null) {
|
||||
tween(this.node)
|
||||
.to(0.5, { scale: new Vec3(3, 3, 3), position: new Vec3(p.x, p.y, 0) })
|
||||
.call(() => {
|
||||
if (callback) {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
.start()
|
||||
}
|
||||
public init(score: number) {
|
||||
if (score <= 0) this.txtScore.string = 'Miss'
|
||||
else this.txtScore.string = `${score}`
|
||||
}
|
||||
|
||||
onDisable() {
|
||||
Tween.stopAllByTarget(this.node)
|
||||
}
|
||||
public playMoveEffect(p: Vec2, callback: Function = null) {
|
||||
tween(this.node)
|
||||
.to(0.5, { scale: new Vec3(3, 3, 3), position: new Vec3(p.x, p.y, 0) })
|
||||
.call(() => {
|
||||
if (callback) callback()
|
||||
})
|
||||
.start()
|
||||
}
|
||||
|
||||
onDisable() {
|
||||
Tween.stopAllByTarget(this.node)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user