mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Reset playCalled on complete. Emit new texture ready event.
This commit is contained in:
parent
950fabe306
commit
3af1d9002c
1 changed files with 31 additions and 12 deletions
|
@ -843,6 +843,10 @@ var Video = new Class({
|
|||
|
||||
this.videoTexture = texture;
|
||||
this.videoTextureSource = texture.source[0];
|
||||
|
||||
this.videoTextureSource.setFlipY(this.flipY);
|
||||
|
||||
this.emit(Events.VIDEO_TEXTURE, this, texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1479,6 +1483,8 @@ var Video = new Class({
|
|||
*/
|
||||
completeHandler: function ()
|
||||
{
|
||||
this._playCalled = false;
|
||||
|
||||
this.emit(Events.VIDEO_COMPLETE, this);
|
||||
},
|
||||
|
||||
|
@ -2019,10 +2025,10 @@ var Video = new Class({
|
|||
|
||||
/**
|
||||
* Stores this Video in the Texture Manager using the given key as a dynamic texture,
|
||||
* which any texture-based Game Object, such as a Sprite, can use as its texture:
|
||||
* which any texture-based Game Object, such as a Sprite, can use as its source:
|
||||
*
|
||||
* ```javascript
|
||||
* var vid = this.add.video(0, 0, 'intro');
|
||||
* const vid = this.add.video(0, 0, 'intro');
|
||||
*
|
||||
* vid.play();
|
||||
*
|
||||
|
@ -2031,6 +2037,24 @@ var Video = new Class({
|
|||
* this.add.image(400, 300, 'doodle');
|
||||
* ```
|
||||
*
|
||||
* If the video is not yet playing then you need to listen for the `TEXTURE_READY` event before
|
||||
* you can use this texture on a Game Object:
|
||||
*
|
||||
* ```javascript
|
||||
* const vid = this.add.video(0, 0, 'intro');
|
||||
*
|
||||
* vid.play();
|
||||
*
|
||||
* if (!vid.saveTexture('doodle'))
|
||||
* {
|
||||
* vid.once('textureready', () => {
|
||||
*
|
||||
* this.add.image(400, 300, 'doodle');
|
||||
*
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The saved texture is automatically updated as the video plays. If you pause this video,
|
||||
* or change its source, then the saved texture updates instantly.
|
||||
*
|
||||
|
@ -2049,7 +2073,7 @@ var Video = new Class({
|
|||
* @param {string} key - The unique key to store the texture as within the global Texture Manager.
|
||||
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y` during upload?
|
||||
*
|
||||
* @return {Phaser.Textures.Texture} The Texture that was saved.
|
||||
* @return {boolean} Returns `true` if the texture is available immediately, otherwise returns `false` and you should listen for the `TEXTURE_READY` event.
|
||||
*/
|
||||
saveTexture: function (key, flipY)
|
||||
{
|
||||
|
@ -2058,18 +2082,13 @@ var Video = new Class({
|
|||
if (this.videoTexture)
|
||||
{
|
||||
this.scene.sys.textures.renameTexture(this._key, key);
|
||||
}
|
||||
|
||||
this._key = key;
|
||||
|
||||
this.flipY = flipY;
|
||||
|
||||
if (this.videoTextureSource)
|
||||
{
|
||||
this.videoTextureSource.setFlipY(flipY);
|
||||
}
|
||||
|
||||
return this.videoTexture;
|
||||
this._key = key;
|
||||
this.flipY = flipY;
|
||||
|
||||
return (this.videoTexture) ? true : false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue