diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2011-07-06 11:15:56 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2011-07-06 11:15:56 +0400 |
commit | b9810ffdde07b81f0fa934ca45124413e15fa38b (patch) | |
tree | b863207d4fc7fd4de2ffcd5ae943b6705a62b453 /doc/python_api/examples | |
parent | 26d75618ef896b0ec125d0dbb5ad530a0b88dffe (diff) |
moving bge.texture example to an external file
Diffstat (limited to 'doc/python_api/examples')
-rw-r--r-- | doc/python_api/examples/bge.texture.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/python_api/examples/bge.texture.py b/doc/python_api/examples/bge.texture.py new file mode 100644 index 00000000000..b27c357b1ee --- /dev/null +++ b/doc/python_api/examples/bge.texture.py @@ -0,0 +1,32 @@ +""" +Basic Video Playback +++++++++++++++++++++++ +Example of how to replace a texture in game with a video. It needs to run everyframe +""" +import bge +from bge import texture +from bge import logic + +cont = logic.getCurrentController() +obj = cont.owner + +# the creation of the texture must be done once: save the +# texture object in an attribute of bge.logic module makes it persistent +if not hasattr(logic, 'video'): + + # identify a static texture by name + matID = texture.materialID(obj, 'IMvideo.png') + + # create a dynamic texture that will replace the static texture + logic.video = texture.Texture(obj, matID) + + # define a source of image for the texture, here a movie + movie = logic.expandPath('//trailer_400p.ogg') + logic.video.source = texture.VideoFFmpeg(movie) + logic.video.source.scale = True + + # quick off the movie, but it wont play in the background + logic.video.source.play() + +# you need to call this function every frame to ensure update of the texture. +logic.video.refresh(True)
\ No newline at end of file |