Skip to content

Commit

Permalink
fix up - add test
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital committed May 22, 2024
1 parent 4da6c1e commit 0fe1247
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/scene/sprite/Sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class Sprite extends Container implements View

if (this._height)
{
this._setHeight(this._width, this._texture.orig.width);
this._setHeight(this._height, this._texture.orig.height);
}

this.onViewUpdate();
Expand Down
30 changes: 30 additions & 0 deletions tests/visual/scenes/sprite/sprite-sizing.scene.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Assets } from '../../../../src/assets/Assets';
import { Texture } from '../../../../src/rendering/renderers/shared/texture/Texture';
import { Sprite } from '../../../../src/scene/sprite/Sprite';

import type { Container } from '../../../../src/scene/container/Container';
import type { TestScene } from '../../types';

export const scene: TestScene = {
it: 'should render sprite',
pixelMatch: 200,
only: true,
create: async (scene: Container) =>
{
const textures = await Assets.load([
`bunny.png`,
]);

const texture = textures[`bunny.png`];

const sprite = new Sprite({
texture: Texture.WHITE,
width: 128,
height: 128,
});

sprite.texture = texture;

scene.addChild(sprite);
},
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0fe1247

Please sign in to comment.