简体   繁体   中英

How to change preloaded video HTML5 Phaser?

Hi i am using html5 Phaser game engine to make a video flipbook.

I load my videos in my preloader like this.

this.load.video('myVideo1', 'assets/video/video1.mp4');
this.load.video('myVideo2', 'assets/video/video2.mp4');

I add my video to my game like this:

this.video = this.add.video('myVideo1');

I want to use the change source like this;

this.video = this.add.video('myVideo' + curScene.toString);

I am using the last part wrong... But i wana use my preloaded video :(

Some video information here: http://phaser.io/examples/v2/video/change-source

You shouldn't use this.add.video to change the source; you should rather use something like this:

this.video.changeSource('assets/video/video' + curScene.toString() + '.mp4');

Note that it's not the cache key that is used - it's the full URL to the second video (assuming that curScene.toString() will indeed return "1" or "2").

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM