dd
This commit is contained in:
19
assets/script/game/component/hero/HeroStateMachine.ts
Normal file
19
assets/script/game/component/hero/HeroStateMachine.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { HeroView } from "./HeroView";
|
||||
import { HeroAnimState } from "./HeroState";
|
||||
|
||||
/** 英雄动画状态机 */
|
||||
export class HeroStateMachine {
|
||||
private _currentState: HeroAnimState = HeroAnimState.IDLE;
|
||||
|
||||
/**
|
||||
* 切换状态
|
||||
* @param newState 新状态
|
||||
* @param view 视图组件
|
||||
*/
|
||||
changeState(newState: HeroAnimState, view: HeroView) {
|
||||
if (this._currentState !== newState) {
|
||||
view.playAnimation(newState);
|
||||
this._currentState = newState;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user