Site calls an action within the game

0 favourites
  • 12 posts
From the Asset Store
A set of vector game assets contains ground tiles and several objects, used for creating platformer games
  • Hi,

    I have a website with my game in an iframe.

    I need that when you click a button on my site (outside the game), perform an action within the game, which is in an iframe. Is this possible?

  • What's the action?

  • Include the function object in your c2 project, then you can call functions with

    iframe.contentWindow.c2_callFunction("Func",[]);

    Edit: Where "Func" is the name of the function to call and [] is an array of arguments.

  • Include the function object in your c2 project, then you can call functions with

    iframe.contentWindow.c2_callFunction("Func",[]);

    Edit: Where "Func" is the name of the function to call and [] is an array of arguments.

    Thanks for this. Is it possible on client side to have the C2 iframe call the parent container's js?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • IndieKiwi window.parent to control the parent window.

    Example : window.parent.document.body.style.background = "blue";

    But it's worth noting that c2_callFunction can return a value;

    It might save you the hassle of playing with JS inside your c2 project.

  • Cool, man!

    That was exactly what I was looking for.

    It worked perfectly.

    Thank you so much!

  • Sorry for reopen this old post

    I need to make the same action:

    -> call a function C2 on a button placed out the project

    I tried to call "c2_callFunction()" from js code placed in index.html C2 but i had always error 'c2_callFunction is not defined'

    Is it really possible to use this function from external code or it is only a function to develop C2 plugin ?

  • Me too! error 'c2_callFunction is not defined'

    Help please.

    Thanks

  • .

  • > Me too! error 'c2_callFunction is not defined'

    > Help please.

    > Thanks

    >

    I think we are left here to struggle, no answer what so ever, 404 error for every capx download file, and not enough examples and clear guidlines.

    AndrejSoldo

    Your original post was only a few hours ago ( https://www.scirra.com/forum/viewtopic.php?f=147&t=202690&p=1171131#p1171131 ) and this thread is nearly 4 years old, so posting here is pointless.

    A little patience is required before you start complaining as many of the users who help come from very different time zones.

  • >

    > > Me too! error 'c2_callFunction is not defined'

    > > Help please.

    > > Thanks

    > >

    >

    > I think we are left here to struggle, no answer what so ever, 404 error for every capx download file, and not enough examples and clear guidlines.

    >

    AndrejSoldo

    Your original post was only a few hours ago ( scirra.com/forum/viewtopic.php ) and this thread is nearly 4 years old, so posting here is pointless.

    A little patience is required before you start complaining as many of the users who help come from very different time zones.

    I agree, but that just proves my point that no one has an answer for this question and I find it very frustrating because that's the last thing I need to implement and I'm stuck here for weeks. It's not documented well and most important of all I don't have 4 years on my hand to wait for it. please understand that this is very important for me and the forum is not very helpful. Tnx for understanding

  • ....

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)