How do I export variable data to javascript

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello. I'm not new to C2, having used it for 3 years and made many simple games with it, however I'm not a coder and I've been tasked with something that may seem very simple to many, but is utterly alien to me.

    My employers want to take information from my game. Mainly numbers from global variables such as Player Scores or Timers, and then feature them on other parts of the web pages were my games are embedded (in iFrames). They also want to communicate to the page that a game has been completed, or that the game window has been closed.

    I've consulted the Manual and forums and find most information I've come across on the Browser's Javascript Execution and Ajax functions a bit bewildering. Does anyone have any information or links to simple example capx's or tutorials that might help me? Bare in mind the minute anyone starts talking code I get brain-freeze.

    Thanks in advance

  • Hey Christmas,

    You'll probably use the Browser>Execute Javascript action, as you guessed. The thing is, if you don't know Javascript, someone will have to write some code for you. Anyway, talk to your employer. Chances are they already have javascript functions to deal with those actions, so, you'd just have to call those functions using the Browser>Execute Javascript action.

    hope this helps. Cheers!

  • Thank you brunopalermo

    Yeah that's the idea. I export the data from C2, and then our talented web dev handles the rest through her magic codey-ness.

    I built a game a year or two back. One of our guys went in and added this simple line so we could export to a high score web page, and it worked fine.

    On Touch 'Submit Score': Browser - Execute javascript "submitScore("& Score &");"

    Sadly he's moved on elsewere, and the balls in my court now, and I can only bullsh**t that I know what I'm doing so far right?

    hopefuly I can show her this and she can take it from there, so I won't get fired and have to go back to my old job of selling pencils

  • "submitScore" must be a custom JS function that guy created. You can't possibly do anything without the help from your company's web developer. (unless you are the web developer, in which case you are in trouble )

  • I'm an Animator/graphic designer primarily, but I'm more logical and good at Maths (and humble, and more handsome) than the average arty type, so I took to Construct well. Up until now I've got by because I make very simple educational games embedded inside the pages of e-learning courses. So for the most part they're simple drag and drops, puzzles etc, with one possible outcome... boom, move onto the next page.

    Basically I just make them, export them as HTML5, and they get sent to web devs and I never hear about it again. Occasionally some guy in a suit who drives a flash car with his name on the number plate tells me I'm "doing great stuff" and tries to high five me (I miss 90% of the time or barely smack a pinky).

    I think after 3 years of this going well, they've started to think I'm smarter than I actually am and are asking a wee bit more... MAN ARE THEY IN FOR A SHOCK!

    Seriously though I will get support off Web, they just don't have time to get an understanding of Construct2 so are leaving the ball in my court. All advice is greatly appreciated

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm an Animator/graphic designer primarily, but I'm more logical and good at Maths (and humble, and more handsome)

    Hey, we have so much in common! Only I'm not an animator/designer and not very good at logic or math.

    The good thing is - if you fail as a game developer, you can always build a career in stand up comedy! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Here is a comprehensive tutorial on how to make online leaderboards:

    https://www.scirra.com/tutorials/346/on ... -php-mysql

    You can use the same approach to export any data.

    Also, check the AJAX section in the FAQ:

    viewtopic.php?t=63692&start=0

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