Make C2 canvas fit liquid div

Get help using Construct 2

Post » Mon Jul 30, 2012 12:15 am

I need to embed my exported project into an HTML, more specifically inside a div tag with "Width=100%" and "Height=100%", in a way that C2 canvas behave like in crop mode, showing more layout as the div gets larger.

I tried editing the exported HTML and adding some custom javascript with no success. I'm not entirely sure of how C2 setup the project to resize it's canvas.

How can I achieve this without breaking my project?
Scirra Employee
B
143
S
51
G
17
Posts: 709
Reputation: 17,371

Post » Mon Jul 30, 2012 2:02 pm

It's difficult to achieve without messing with the runtime. I think the easiest way would be to use an iframe in the div with a liquid size that shows another page with the fullscreen game on it. As the iframe resizes it should (I think) correctly resize the game on the iframe page.
Scirra Founder
B
382
S
223
G
86
Posts: 23,991
Reputation: 189,739

Post » Tue Jul 31, 2012 3:20 am

It works, but I need communication between the runtime and the webpage through query strings, and with an iframe this doesn't seems possible.

I think I could workaround if C2 had actions to set the width and height of the canvas at runtime. Any chance this could be added someday in an upcoming release?
Scirra Employee
B
143
S
51
G
17
Posts: 709
Reputation: 17,371

Post » Tue Jul 31, 2012 8:28 am

@Animmaniac : in the HTML5 draft, it's possible to set a communication channel between an iframe and it's parent via .postMessage() queues.
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Tue Jul 31, 2012 1:14 pm

Can't you just put the query string in the iframe src as well?
Scirra Founder
B
382
S
223
G
86
Posts: 23,991
Reputation: 189,739

Post » Wed Aug 08, 2012 12:02 am

I think I could parse the query strings when the page loads and then post them to the iframe, or maybe append the strings to the iframe url and create it dynamically.

Now I noticed that the iframe workaround brings a new problem, I can't request fullscreen anymore. Any ideas about how to solve this?
Scirra Employee
B
143
S
51
G
17
Posts: 709
Reputation: 17,371


Return to How do I....?

Who is online

Users browsing this forum: mekonbekon and 1 guest