SDK control the game from outside the document.

0 favourites
  • 6 posts
From the Asset Store
Easily integrate Telegram Mini Apps SDK into your Construct 3 projects for building interactive apps and games.
  • Hi guys,

    I'm new to construct but I'm already amazed by it's simplicity and I feel like I'm going to enjoy it.

    I created my first game and I displayed it inside an iframe on my website.

    I would like to know if it's possible to use the SDK to reload the game from my website.

    So I want to access the content of the iframe and then call a function that will reload the game.

    Thanks in advance for your time and patience.

    Best,

    J.

  • Bit unsure what you're trying to accomplish but I'll take a crack:

    If you want to refresh your game from within your iFrame, that's as simple as restart layout event, you can map this from everything from a collision to a key press.

    Refreshing your game from outside the iFrame, via a text or image link is pretty simple: Your best bet is to simply refresh the whole page, which will reset the iFrame.

    If you want to refresh the game without refreshing your web-page, in theory you could get creative with mouse overlapping collisions; with your game refreshing the layout whenever the mouse isn't within your iFrame: The practicality of this questionable though.

    Finally, if your familiar with JS, you can use that refresh your frame, simply use this on a button on your parent page:

    <IFRAME id="frame1" src="http://www.example.com/"  runat="server">
    
        <script type="text/javascript">
        function refreshiframe()
        {
            parent.frame1.location.href="http://www.example.com/"
        }
        </script>
    
    <asp:Button ... OnClientClick="refreshiframe();" />

    As always StackOverflow is your friend: stackoverflow.com/questions/2064850/how-to-refresh-an-iframe-using-javascript

    I'm pretty sure you can refresh an iFrame simply in HTML, though I've never tried, doubtless someone knows!

  • E Bear : thank you for your kind answer.

    Is it possible for an external button (not in the iframe) to call an action inside the game (canvas).

    Like changing of layout for example.

    Thanks again for both your time and patience.

    J.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For the reference, reloading the iframe with jquery :

    $( '#iframe' ).attr( 'src', function ( i, val ) { return val; });
  • This type of thing is suitable for the Javascript SDK, since you have to code the parent page Javascript anyway.

  • Hi I have the same need, I am building a serie of games and all the games have the same GUI, the problem today is if i like to make a change in the GUI i need to enter each game, make the change and export it.

    so i would like to make the GUI in HTML with its own logic, and with it control the game states like pause, help, congratulation message and points.

    for this i need to do a plugin with the Javascript SDK or is there a wahy to controling and accesig somo variables and states of the game from an external javascript?

    thanks

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