Skip to content

Commit

Permalink
fixing small bug for foo npcs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Jun 25, 2023
1 parent 8f17993 commit fb8a156
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions base/ControllableChar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,12 @@ export abstract class ControllableChar {
anchor_x = anchor_x ?? ControllableChar.default_anchor.x;
anchor_y = anchor_y ?? ControllableChar.default_anchor.y;
this._sprite_info = sprite_info;
const sprite_key = this.sprite_info.getSpriteKey(this.current_action);
this.sprite = group.create(0, 0, sprite_key);
if (this.current_action) {
const sprite_key = this.sprite_info.getSpriteKey(this.current_action);
this.sprite = group.create(0, 0, sprite_key);
} else {
this.sprite = group.create(0, 0);
}
if (!this.active) {
this.sprite.visible = false;
}
Expand Down Expand Up @@ -653,6 +657,9 @@ export abstract class ControllableChar {
loop?: boolean
) {
action = action ?? this.current_action;
if (!action) {
return null;
}
if (animation === null || animation === undefined) {
if (this.current_direction in reverse_directions) {
animation = reverse_directions[this.current_direction];
Expand Down Expand Up @@ -1320,7 +1327,7 @@ export abstract class ControllableChar {
if (this.sprite.body) {
this.sprite.body.velocity.y = this.sprite.body.velocity.x = 0;
}
if (change_sprite) {
if (change_sprite && this.sprite_info) {
if (this.climbing) {
this.data.hero.idle_climbing = true;
this.data.hero.play(base_actions.CLIMB, climb_actions.IDLE);
Expand Down
5 changes: 4 additions & 1 deletion base/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,10 @@ export class Map {
? initial_action
: npc_db.action_aliases[initial_action];
initial_action = snapshot_info?.action ?? initial_action;
let initial_animation = property_info.animation ?? npc_db.actions[actual_action].initial_animation;
let initial_animation = property_info.animation;
if (npc_db.actions && actual_action in npc_db.actions) {
initial_animation = npc_db.actions[actual_action].initial_animation;
}
initial_animation = snapshot_info?.animation ?? initial_animation;
const interaction_pattern = property_info.interaction_pattern ?? npc_db.interaction_pattern;
const ignore_physics = property_info.ignore_physics ?? npc_db.ignore_physics;
Expand Down

0 comments on commit fb8a156

Please sign in to comment.