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
43
S
9
G
7
Posts: 58
Reputation: 7,540

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
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Tue Apr 03, 2012 6:54 am

B
109
S
27
G
276
Posts: 4,479
Reputation: 154,418

Post » Tue Apr 03, 2012 7:02 am

Ah! i didn't know there a video plugin.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421



Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 10 guests