[mod] HoldButton
This commit is contained in:
@@ -10,13 +10,17 @@ export default class HoldButton extends cc.Component {
|
||||
@property()
|
||||
public MaxTime: number = 2;
|
||||
|
||||
@property({ type: cc.Node })
|
||||
/** 是否HoldLine */
|
||||
@property({ displayName: "是否有HoldLine", tooltip: "是否HoldLine" })
|
||||
public IsHaveHoldLine: boolean = false;
|
||||
|
||||
@property({ type: cc.Node, visible(): boolean { return this.IsHaveHoldLine; } })
|
||||
public HoldLine: cc.Node = null;
|
||||
|
||||
@property({ type: cc.Sprite })
|
||||
@property({ type: cc.Sprite, visible(): boolean { return this.IsHaveHoldLine; } })
|
||||
public ProgressBG: cc.Sprite = null;
|
||||
|
||||
@property({ type: cc.Sprite })
|
||||
@property({ type: cc.Sprite, visible(): boolean { return this.IsHaveHoldLine; } })
|
||||
public ProgressLine: cc.Sprite = null;
|
||||
|
||||
@property({ type: [cc.Component.EventHandler] })
|
||||
@@ -30,8 +34,6 @@ export default class HoldButton extends cc.Component {
|
||||
|
||||
private _m_pressDeltaTime: number = 0;
|
||||
|
||||
private _m_noLineUI: boolean = true;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Lifecycle
|
||||
@@ -46,7 +48,7 @@ export default class HoldButton extends cc.Component {
|
||||
if (this._m_isMouseDown) {
|
||||
this._checkHoldAutoStart(dt);
|
||||
} else {
|
||||
if (!this._m_noLineUI) {
|
||||
if (this.IsHaveHoldLine) {
|
||||
this.HoldLine.active = false;
|
||||
}
|
||||
}
|
||||
@@ -71,14 +73,14 @@ export default class HoldButton extends cc.Component {
|
||||
private _checkHoldAutoStart(deltaTime: number): void {
|
||||
this._m_pressDeltaTime += deltaTime;
|
||||
|
||||
if (!this._m_noLineUI) {
|
||||
if (this.IsHaveHoldLine) {
|
||||
// 蓄能條顯示特效
|
||||
this.ProgressLine.fillRange = this._m_pressDeltaTime;
|
||||
}
|
||||
|
||||
if (this._m_pressDeltaTime > this.MaxTime) {
|
||||
this._m_isMouseDown = false;
|
||||
if (!this._m_noLineUI) {
|
||||
if (this.IsHaveHoldLine) {
|
||||
this.HoldLine.active = false;
|
||||
}
|
||||
this._m_pressDeltaTime = 0;
|
||||
@@ -99,8 +101,7 @@ export default class HoldButton extends cc.Component {
|
||||
return;
|
||||
}
|
||||
this._m_isMouseDown = true;
|
||||
this._m_noLineUI = this.HoldLine == null || this.ProgressBG == null || this.ProgressLine == null;
|
||||
if (!this._m_noLineUI) {
|
||||
if (this.IsHaveHoldLine) {
|
||||
this.HoldLine.active = true;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +109,7 @@ export default class HoldButton extends cc.Component {
|
||||
private _onTouchEnd(event: cc.Event.EventTouch): void {
|
||||
this._m_isMouseDown = false;
|
||||
this._m_pressDeltaTime = 0;
|
||||
if (!this._m_noLineUI) {
|
||||
if (this.IsHaveHoldLine) {
|
||||
this.HoldLine.active = false;
|
||||
}
|
||||
this._checkHoldAutoStart(0);
|
||||
@@ -117,7 +118,7 @@ export default class HoldButton extends cc.Component {
|
||||
private _onTouchCancel(event: cc.Event.EventTouch): void {
|
||||
this._m_isMouseDown = false;
|
||||
this._m_pressDeltaTime = 0;
|
||||
if (!this._m_noLineUI) {
|
||||
if (this.IsHaveHoldLine) {
|
||||
this.HoldLine.active = false;
|
||||
}
|
||||
this._checkHoldAutoStart(0);
|
||||
|
||||
Reference in New Issue
Block a user