Skip to content

Commit

Permalink
improving sprite base checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Apr 15, 2024
1 parent 7f989ca commit 060f0cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion base/ControllableChar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,9 @@ export abstract class ControllableChar {
}
const animation_key = this.sprite_info.getAnimationKey(action, animation);
if (!this.sprite.animations.getAnimation(animation_key)) {
this.sprite_info.setAnimation(this.sprite, action);
if (!this.sprite_info.setAnimation(this.sprite, action)) {
return null;
}
}
const animation_obj = this.sprite.animations.getAnimation(animation_key);
if (!animation_obj) {
Expand Down
10 changes: 9 additions & 1 deletion base/SpriteBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class SpriteBase {
const action_key = this.getSpriteKey(action);
if (game.cache.checkImageKey(action_key)) {
this.data.logger.log_message(
`Sprite key '<key_name>/<action>' '${action_key} is already registered in the engine. Please consider renaming it.'`,
`Sprite key '<key_name>/<action>' '${action_key}' is already registered in the engine. Please consider renaming it.`,
msg_types.ERROR
);
}
Expand Down Expand Up @@ -162,10 +162,18 @@ export class SpriteBase {
Array.isArray(loop) ? loop[i] : loop,
false
);
if (!sprite.animations.frameData.getFrameByName(`${anim_key}${SpriteBase.ACTION_ANIM_SEPARATOR}00`)) {
this.data.logger.log_message(
`Animation '${anim_key}' is not valid for action '${action}' for sprite '${this.key_name}'.`,
msg_types.ERROR
);
return false;
}
}
} else {
this.data.logger.log_message(`Action '${action}' not available for '${this.key_name}'.`);
}
return true;
}

generateAllFrames() {
Expand Down
2 changes: 1 addition & 1 deletion static/phaser.js
Original file line number Diff line number Diff line change
Expand Up @@ -73458,7 +73458,7 @@ Phaser.FrameData.prototype = {
*/
checkFrameName: function (name)
{
if (this._frameNames[name] == null)
if (this._frameNames[name] == null || this._frameNames[name] === undefined)
{
return false;
}
Expand Down

0 comments on commit 060f0cc

Please sign in to comment.