Jump to content


Photo

browser_input_capture


  • Please log in to reply
3 replies to this topic

#1 coNNecTT01

coNNecTT01

    GMC Member

  • GMC Member
  • 297 posts
  • Version:GM:Studio

Posted 19 February 2015 - 04:52 PM

Hi, so the browser_input_capture was added and I'm trying to fix my previous problem with comment section in the same page with the game, but I'm having some troubles setting up this new function. I've tried several codes:

if(os_is_paused()){
    browser_input_capture(false);
}

if(window_has_focus()){
    browser_input_capture(true);
}

This code is one of them (it always captures input), but i mainly used "os_is_paused", "window_has_focus" or mouse checking stuff.

Could someone make an example for "browser_input_capture" or point towards what am I doing wrong? Thanks in advance!


  • 0

#2 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 22 February 2015 - 01:52 AM

Alright so the if (window_has_focus()) will always return true, as the window that contains the comment box is the same window that contains the game.

I think the best & simplest solution to your problem would be to place your game in an iframe.


  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#3 coNNecTT01

coNNecTT01

    GMC Member

  • GMC Member
  • 297 posts
  • Version:GM:Studio

Posted 22 February 2015 - 09:44 AM

Thanks for the response. I haven't used an iframe before so I'm not sure what's wrong here. Here's what I'm trying to do:

<!-- Create the canvas element the game draws to -->
<iframe>
    <canvas id="canvas" width="256" height="144">
        <p>Your browser doesn't support HTML5 canvas.</p>
    </canvas>
</iframe>

But the game doesn't load then. I don't use HTML language especially iframes a lot, so excuse me for my lack of knowledge. I couldn't find any help by searching. :(

 

EDIT: Ok, I understand why it doesn't work now, but I'm still not sure how to add my game into an iframe. :S Do I need a separate index.html for my game?

 

EDIT: Nevermind, I'll just put the comments in an iframe.


Edited by coNNecTT01, 22 February 2015 - 12:47 PM.

  • 0

#4 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 23 February 2015 - 01:00 AM

So I thought I better post a quick guide for anyone else that is having issues.

Step 1: Rename the "index.html" file GameMaker spits out to something like "gmhtml.html"
Step 2: Create a new html file called "index.html" and put the following code in it:
 

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>The iframe</title>
</head>

<body>
	<iframe src="gmhtml.html" width = "640" height = "480" scrolling = "no"></iframe>
	
	<!-- Code for your comment box could go here -->
</body>
</html>

(Remember some variables like width/height may need adjusting depending on your setup)

Step 3: Upload everything to your server and navigate to the "index.html"

Step 4: Open up the Popcorn and Ice-Cream and celebrate


  • 1
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png