Skip to content

Commit

Permalink
fix tiling sprite anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital committed May 7, 2024
1 parent 6a1f23f commit 3b4c52f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/scene/sprite-tiling/TilingSprite.ts
Expand Up @@ -196,7 +196,14 @@ export class TilingSprite extends Container implements View, Instruction

this.allowChildren = false;

this._anchor = new ObservablePoint(this);
this._anchor = new ObservablePoint(
{
_onUpdate: () =>
{
this.onViewUpdate();
}
},
);

this._applyAnchorToTexture = applyAnchorToTexture;

Expand Down
17 changes: 17 additions & 0 deletions tests/renderering/sprite/TilingSprite.test.ts
Expand Up @@ -185,4 +185,21 @@ describe('TilingSprite', () =>
expect(tilingSprite.texture).toEqual(Texture.EMPTY);
});
});

describe('Anchor', () =>
{
it('should update anchor', () =>
{
const texture = new Texture();
const sprite = setup({ texture });

expect(sprite.texture).toEqual(texture);

const spy = jest.spyOn(sprite, 'onViewUpdate');

sprite.anchor.x = 0.5;

expect(spy).toHaveBeenCalledTimes(1);
});
});
});

0 comments on commit 3b4c52f

Please sign in to comment.