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
41
S
8
G
6
Posts: 58
Reputation: 6,820

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
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Tue Apr 03, 2012 6:54 am

B
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

Post » Tue Apr 03, 2012 7:02 am

Ah! i didn't know there a video plugin.
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644



Return to How do I....?

Who is online

Users browsing this forum: claurent9, imothep85 and 28 guests