How do I have multiple C2 canvases & communication

Get help using Construct 2

Post » Mon May 08, 2017 2:41 pm

Hello my friends :)

Does someone tried to put multiple Construct2 projects in a one page (NOT IN IFRAMES!)? With no conflicts between the globals...
And by experience, what is the best way to make a communication between JavaScript of the page with the Constract2 project? I guess plugin have to be made...

Thank you.
B
62
S
32
G
6
Posts: 125
Reputation: 7,975

Post » Mon May 08, 2017 6:53 pm

You could also have multiple Canvases using Rojohound's Canvas plugin,
That would work aswell
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,471

Post » Tue May 09, 2017 7:34 am

Whiteclaws wrote:You could also have multiple Canvases using Rojohound's Canvas plugin,
That would work aswell

No, that is not what I asked.
I want to have multiple Construct2 projects in a page, not multiple canvas-plugins in a project.
When I say canvas I mean html5 element that is generated by exporting to "HTML website".

My problem is that in order to insert the Construct2 project in my page I need to put it in iframe with the index.html with the canvas (html5 element) project.
The problem of having iFrame is that it is hard to make JavaScript to JavaScript communication (page JS to JS inside the iframe), browsers blocking that for security reasons, the communication is super limited with workarounds.
The other way is to put the canvas directly in the dom of the page, but then we have problems to have more than one Construct2 project because there will be conflicts between c2runtime.js globals of multiple projects.
B
62
S
32
G
6
Posts: 125
Reputation: 7,975

Post » Tue May 09, 2017 3:11 pm

Any help?
B
62
S
32
G
6
Posts: 125
Reputation: 7,975

Post » Wed May 10, 2017 3:04 am

Why would you want to do such thing, If you want to have connection, you can always host a basic javascript server that relays input from one frame to another depending on a randomly generated user id, or maybe look into shared local storage, which could be your solution
Edit: Have you tried putting two iframes and trying to set a key in one and get it in another with local storage
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,471

Post » Wed May 10, 2017 7:24 am

Whiteclaws wrote:Why would you want to do such thing, If you want to have connection, you can always host a basic javascript server that relays input from one frame to another depending on a randomly generated user id, or maybe look into shared local storage, which could be your solution
Edit: Have you tried putting two iframes and trying to set a key in one and get it in another with local storage


Now not all devices support flash and browsers much more security-strict.
I wanna have smart-ass popups on a page :) That can be loaded if needed.
Those popups can be a range of things, from notification with fancy animations up to minigames.

But I dont want to involve a server, it all should be on the client side.

Thank you for your help, but sounds like you cant help me.
B
62
S
32
G
6
Posts: 125
Reputation: 7,975


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests