Skip to content

Commit 66b3c06

Browse files
fix(gameobject): pass props to Video
1 parent e254312 commit 66b3c06

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/components/GameObjects.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,10 @@ export const UpdateList = GameObjects.UpdateList as unknown as FC<
781781
* This Game Object is capable of handling playback of a previously loaded video from the Phaser Video Cache, or playing a video based on a given URL. Videos can be either local, or streamed.
782782
*/
783783
export const Video = GameObjects.Video as unknown as FC<
784-
Props<GameObjects.Video>
784+
Props<GameObjects.Video> & {
785+
x: GameObjects.Video['x'];
786+
y: GameObjects.Video['y'];
787+
}
785788
>;
786789

787790
/**

src/render/gameobject.test.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,3 +551,21 @@ describe('TileSprite', () => {
551551
expect(setProps).toHaveBeenCalledWith(expect.anything(), props, scene);
552552
});
553553
});
554+
555+
describe('Video', () => {
556+
it('adds game object', () => {
557+
const props = {
558+
x: 1,
559+
y: 2,
560+
cacheKey: 'cacheKey',
561+
};
562+
addGameObject(<GameObjects.Video {...props} />, scene);
563+
expect(Phaser.GameObjects.Video).toHaveBeenCalledWith(
564+
scene,
565+
props.x,
566+
props.y,
567+
props.cacheKey,
568+
);
569+
expect(setProps).toHaveBeenCalledWith(expect.anything(), props, scene);
570+
});
571+
});

src/render/gameobject.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ export function addGameObject(
169169
);
170170
break;
171171

172+
case element.type === Phaser.GameObjects.Video:
173+
gameObject = new element.type(scene, props.x, props.y, props.cacheKey);
174+
break;
175+
172176
// Phaser component
173177
case gameObjects.indexOf(element.type) !== -1:
174178
gameObject = new element.type(scene);

0 commit comments

Comments
 (0)