mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
1 Commits
fix/npm-in
...
fix/hitbox
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5cd1581be1 |
@@ -95,10 +95,11 @@ namespace gdjs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateFontFamily(): void {
|
updateFontFamily(): void {
|
||||||
this._pixiObject.textStyles.default.fontFamily = this._object._runtimeScene
|
this._pixiObject.textStyles.default.fontFamily =
|
||||||
.getGame()
|
this._object._runtimeScene
|
||||||
.getFontManager()
|
.getGame()
|
||||||
.getFontFamily(this._object._fontFamily);
|
.getFontManager()
|
||||||
|
.getFontFamily(this._object._fontFamily);
|
||||||
this._pixiObject.dirty = true;
|
this._pixiObject.dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,9 +110,14 @@ namespace gdjs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updatePosition(): void {
|
updatePosition(): void {
|
||||||
this._pixiObject.position.x = this._object.x + this._pixiObject.width / 2;
|
const angle = gdjs.toRad(this._object.angle);
|
||||||
this._pixiObject.position.y =
|
const height = this.getHeight() / 2;
|
||||||
this._object.y + this._pixiObject.height / 2;
|
const width = this.getWidth() / 2;
|
||||||
|
const xDelta = width * Math.cos(angle) - height * Math.sin(angle);
|
||||||
|
const yDelta = width * Math.sin(angle) + height * Math.cos(angle);
|
||||||
|
|
||||||
|
this._pixiObject.position.x = this._object.x + xDelta;
|
||||||
|
this._pixiObject.position.y = this._object.y + yDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAngle(): void {
|
updateAngle(): void {
|
||||||
|
@@ -149,8 +149,14 @@ namespace gdjs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updatePosition(): void {
|
updatePosition(): void {
|
||||||
this._pixiObject.position.x = this._object.x + this.getWidth() / 2;
|
const angle = gdjs.toRad(this._object.angle);
|
||||||
this._pixiObject.position.y = this._object.y + this.getHeight() / 2;
|
const height = this.getHeight() / 2;
|
||||||
|
const width = this.getWidth() / 2;
|
||||||
|
const xDelta = width * Math.cos(angle) - height * Math.sin(angle);
|
||||||
|
const yDelta = width * Math.sin(angle) + height * Math.cos(angle);
|
||||||
|
|
||||||
|
this._pixiObject.position.x = this._object.x + xDelta;
|
||||||
|
this._pixiObject.position.y = this._object.y + yDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAngle(): void {
|
updateAngle(): void {
|
||||||
@@ -169,5 +175,6 @@ namespace gdjs {
|
|||||||
return this._pixiObject.textHeight * this.getScale();
|
return this._pixiObject.textHeight * this.getScale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const BitmapTextRuntimeObjectRenderer = BitmapTextRuntimeObjectPixiRenderer;
|
export const BitmapTextRuntimeObjectRenderer =
|
||||||
|
BitmapTextRuntimeObjectPixiRenderer;
|
||||||
}
|
}
|
||||||
|
@@ -94,8 +94,14 @@ namespace gdjs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updatePosition(): void {
|
updatePosition(): void {
|
||||||
this._text.position.x = this._object.x + this._text.width / 2;
|
const angle = gdjs.toRad(this._object.angle);
|
||||||
this._text.position.y = this._object.y + this._text.height / 2;
|
const width = this._text.width / 2;
|
||||||
|
const height = this._text.height / 2;
|
||||||
|
const xDelta = width * Math.cos(angle) - height * Math.sin(angle);
|
||||||
|
const yDelta = height * Math.cos(angle) + width * Math.sin(angle);
|
||||||
|
|
||||||
|
this._text.position.x = this._object.x + xDelta;
|
||||||
|
this._text.position.y = this._object.y + yDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAngle(): void {
|
updateAngle(): void {
|
||||||
|
@@ -1102,7 +1102,12 @@ namespace gdjs {
|
|||||||
* @return the X position of the object center, relative to `getDrawableX()`.
|
* @return the X position of the object center, relative to `getDrawableX()`.
|
||||||
*/
|
*/
|
||||||
getCenterX(): float {
|
getCenterX(): float {
|
||||||
return this.getWidth() / 2;
|
const halfWidth = this.getWidth() / 2;
|
||||||
|
const halfHeight = this.getHeight() / 2;
|
||||||
|
return (
|
||||||
|
Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight) *
|
||||||
|
Math.cos(gdjs.toRad(this.getAngle()))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1112,7 +1117,12 @@ namespace gdjs {
|
|||||||
* @return the Y position of the object center, relative to `getDrawableY()`.
|
* @return the Y position of the object center, relative to `getDrawableY()`.
|
||||||
*/
|
*/
|
||||||
getCenterY(): float {
|
getCenterY(): float {
|
||||||
return this.getHeight() / 2;
|
const halfWidth = this.getWidth() / 2;
|
||||||
|
const halfHeight = this.getHeight() / 2;
|
||||||
|
return (
|
||||||
|
Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight) *
|
||||||
|
Math.sin(gdjs.toRad(this.getAngle()))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1394,10 +1404,13 @@ namespace gdjs {
|
|||||||
this.hitBoxes[0].vertices[3][0] = 0 - centerX;
|
this.hitBoxes[0].vertices[3][0] = 0 - centerX;
|
||||||
this.hitBoxes[0].vertices[3][1] = height - centerY;
|
this.hitBoxes[0].vertices[3][1] = height - centerY;
|
||||||
}
|
}
|
||||||
this.hitBoxes[0].rotate(gdjs.toRad(this.getAngle()));
|
const angle = gdjs.toRad(this.getAngle());
|
||||||
|
this.hitBoxes[0].rotate(angle);
|
||||||
|
const xDelta = centerX * Math.cos(angle) - centerY * Math.sin(angle);
|
||||||
|
const yDelta = centerY * Math.cos(angle) + centerX * Math.sin(angle);
|
||||||
this.hitBoxes[0].move(
|
this.hitBoxes[0].move(
|
||||||
this.getDrawableX() + centerX,
|
this.getDrawableX() + xDelta,
|
||||||
this.getDrawableY() + centerY
|
this.getDrawableY() + yDelta
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user