Skip to content

Commit ace57a3

Browse files
bugfixes
1 parent 6919241 commit ace57a3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

js/canvas.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export class canvas{
117117

118118
displayerHitbox = (currentHitbox, color, stroke = false) => {
119119
let hitboxData = currentHitbox.hitboxData;
120+
let frameData = currentHitbox.frameRef.frameData;
120121
if(stroke == false){
121122
this.context.fillStyle = color;
122123
this.context.fillRect(currentHitbox.getLeft(), currentHitbox.getTop(), hitboxData.width, hitboxData.height);

js/hitboxClass.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,28 @@ export class hitbox{
4444
setCoords = () => {
4545
let coords = this.hitboxData.coords;
4646
let hoffset = this.hitboxData.offset;
47-
let foffset = this.frameData.offset;
4847

49-
coords.left = hoffset.x + foffset.x - (this.hitboxData.width/2);
50-
coords.top = hoffset.y + foffset.y - (this.hitboxData.height/2);
51-
coords.right = hoffset.x + foffset.x + (this.hitboxData.width/2);
52-
coords.bottom = hoffset.y + foffset.y + (this.hitboxData.height/2);
48+
coords.left = hoffset.x - (this.hitboxData.width/2);
49+
coords.top = hoffset.y - (this.hitboxData.height/2);
50+
coords.right = hoffset.x + (this.hitboxData.width/2);
51+
coords.bottom = hoffset.y + (this.hitboxData.height/2);
5352
}
5453

5554
//#region getter
5655
getLeft = (scale = 1, pan = 0) => {
57-
return this.hitboxData.coords.left * scale + pan;
56+
return (this.hitboxData.coords.left + this.frameData.offset.x) * scale + pan;
5857
}
5958

6059
getTop = (scale = 1, pan = 0) => {
61-
return this.hitboxData.coords.top * scale + pan;
60+
return (this.hitboxData.coords.top + this.frameData.offset.y) * scale + pan;
6261
}
6362

6463
getRight = (scale = 1, pan = 0) => {
65-
return this.hitboxData.coords.right * scale + pan;
64+
return (this.hitboxData.coords.right + this.frameData.offset.x) * scale + pan;
6665
}
6766

6867
getBottom = (scale = 1, pan = 0) => {
69-
return this.hitboxData.coords.bottom * scale + pan;
68+
return (this.hitboxData.coords.bottom + this.frameData.offset.y) * scale + pan;
7069
}
7170
//#endregion
7271

0 commit comments

Comments
 (0)