In game video?

Get help using Construct 2

Post » Tue Apr 03, 2012 6:27 am

Hi,

Is it possible to add a video in my C2 game?

Tks
B
42
S
9
G
7
Posts: 58
Reputation: 7,455

Post » Tue Apr 03, 2012 6:42 am

Quite possible.

You need to add a HTML5 video tag where it comes from the source and a little bit of hack c2runtime.js:

In HTML:
<video id="video" controls="controls" autoplay="autoplay" src="your_video_file.webm"></video>

In JS:
var canvas = document.getElementById('canvas');
var video = document.getElementById('video');
var drawvideo = canvas.getContext('2d');

video.addEventListener('play', function () {
    var $this = this;
    (function loop() {
        if (!$this.paused && !$this.ended) {
            drawvideo.drawImage($this, 0, 0);
            setTimeout(loop, 1000 / 30);
        }
    })();
}, 0);


I know it shows double video and not perfect, but you can hide another video using CSS display: none; for ID of video.Joannesalfa2012-04-03 06:51:51
B
104
S
29
G
22
Posts: 3,067
Reputation: 24,275

Post » Tue Apr 03, 2012 6:54 am

B
99
S
22
G
192
Posts: 4,177
Reputation: 111,217

Post » Tue Apr 03, 2012 7:02 am

Ah! i didn't know there a video plugin.
B
104
S
29
G
22
Posts: 3,067
Reputation: 24,275



Return to How do I....?

Who is online

Users browsing this forum: ErekT, MisterAqua, Zarocks and 28 guests