fix:调整默认状态调用点

This commit is contained in:
YipLee 2021-06-17 22:44:29 +08:00
parent 06aef65b2a
commit 7a1b589424
8 changed files with 8 additions and 8 deletions

View File

@ -121,6 +121,8 @@ export default class AnimatorBase extends cc.Component {
*/ */
protected initJson(json: any) { protected initJson(json: any) {
this._ac = new AnimatorController(this, json); this._ac = new AnimatorController(this, json);
// 执行默认状态
this._ac.changeState(json.defaultState);
} }
/** /**

View File

@ -41,13 +41,11 @@ export default class AnimatorController {
return; return;
} }
let defaultState: string = json.defaultState;
this._anyState = new AnimatorState(json.anyState, this); this._anyState = new AnimatorState(json.anyState, this);
for (let i = 0; i < json.states.length; i++) { for (let i = 0; i < json.states.length; i++) {
let state: AnimatorState = new AnimatorState(json.states[i], this); let state: AnimatorState = new AnimatorState(json.states[i], this);
this._states.set(state.name, state); this._states.set(state.name, state);
} }
this.changeState(defaultState);
} }
private updateState() { private updateState() {

View File

@ -122,6 +122,8 @@ export default class AnimatorBase extends Component {
*/ */
protected initJson(json: any) { protected initJson(json: any) {
this._ac = new AnimatorController(this, json); this._ac = new AnimatorController(this, json);
// 执行默认状态
this._ac.changeState(json.defaultState);
} }
/** /**

View File

@ -42,13 +42,11 @@ export default class AnimatorController {
return; return;
} }
let defaultState: string = json.defaultState;
this._anyState = new AnimatorState(json.anyState, this); this._anyState = new AnimatorState(json.anyState, this);
for (let i = 0; i < json.states.length; i++) { for (let i = 0; i < json.states.length; i++) {
let state: AnimatorState = new AnimatorState(json.states[i], this); let state: AnimatorState = new AnimatorState(json.states[i], this);
this._states.set(state.name, state); this._states.set(state.name, state);
} }
this.changeState(defaultState);
} }
private updateState() { private updateState() {

View File

@ -121,6 +121,8 @@ export default class AnimatorBase extends cc.Component {
*/ */
protected initJson(json: any) { protected initJson(json: any) {
this._ac = new AnimatorController(this, json); this._ac = new AnimatorController(this, json);
// 执行默认状态
this._ac.changeState(json.defaultState);
} }
/** /**

View File

@ -41,13 +41,11 @@ export default class AnimatorController {
return; return;
} }
let defaultState: string = json.defaultState;
this._anyState = new AnimatorState(json.anyState, this); this._anyState = new AnimatorState(json.anyState, this);
for (let i = 0; i < json.states.length; i++) { for (let i = 0; i < json.states.length; i++) {
let state: AnimatorState = new AnimatorState(json.states[i], this); let state: AnimatorState = new AnimatorState(json.states[i], this);
this._states.set(state.name, state); this._states.set(state.name, state);
} }
this.changeState(defaultState);
} }
private updateState() { private updateState() {

View File

@ -122,6 +122,8 @@ export default class AnimatorBase extends Component {
*/ */
protected initJson(json: any) { protected initJson(json: any) {
this._ac = new AnimatorController(this, json); this._ac = new AnimatorController(this, json);
// 执行默认状态
this._ac.changeState(json.defaultState);
} }
/** /**

View File

@ -42,13 +42,11 @@ export default class AnimatorController {
return; return;
} }
let defaultState: string = json.defaultState;
this._anyState = new AnimatorState(json.anyState, this); this._anyState = new AnimatorState(json.anyState, this);
for (let i = 0; i < json.states.length; i++) { for (let i = 0; i < json.states.length; i++) {
let state: AnimatorState = new AnimatorState(json.states[i], this); let state: AnimatorState = new AnimatorState(json.states[i], this);
this._states.set(state.name, state); this._states.set(state.name, state);
} }
this.changeState(defaultState);
} }
private updateState() { private updateState() {