Problem with global variable.

0 favourites
  • 6 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hi people, first of all i give thanks to the creator/s of this awesome program.

    Well i have a problem here... If someone can help me i will apreciate so much :P

    My problem:

    I create a game of math calculations, i have a web page and i want to get the "Score"(a global variable of my game) to my webpage, well when i see the code named c2runtime.js, i try get the value of the global variable...

    I can get the value with this code at the end of the script:

    function showScore()

    {

         $.post("score.php", {score: Score(*)}, function(data) {

         alert(data);});

    }

    (*) there i need to put the name of the global variable to pass the score to the php file.

    Someone knows if this is possible?

    Thanks. :)

  • No one knows anything about this problem? :/.

    When i open the source code c2runtime.js

    [-1,z.l.prototype.d.S,g,[

    [11,"Score"], how i can get this value... Is a kind of gigantic array with more big array's inside...

  • You have many possibilities for that:

    With the Id property

    or easier directly with ajax or ajaxpost plugin..

    There are some examples linked in the howto faqs<img src="smileys/smiley2.gif" border="0" align="middle"> and a tutorial for the ajaxplugin..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Men if i can make this... I will love u XDDD

    Then i need to get the name of my text box... Yes i use a text box to show my score in the game.

    How i can get the ID of the text box? :/ tyyyyyyy!

  • In the linked post is a screenshot of the javascript lines.. but sending score and.. is very easy with the built in ajaxplugin or if you want pass it per post with a custom ajaxpost plugin.. <img src="smileys/smiley2.gif" border="0" align="middle" />

  • In the linked post is a screenshot of the javascript lines.. but sending score and.. is very easy with the built in ajaxplugin or if you want pass it per post with a custom ajaxpost plugin.. <img src="smileys/smiley2.gif" border="0" align="middle" />

    Ty, i can't make this with a label...?

    Because my porpuse is... Get the score at the final of the game... :/

    c2runtime.js i add this:

    function showScore()

    {

         var myScore = document.getElementById('testScore');

         alert("ola");

         $.post("score.php", {score: myScore}, function(data) {

         alert(data);});

    }

    testScore is the ID of my text box.

    now my php code:

    <?

    $score = $_POST['score'];

    echo $score;

    ?>

    html code:

    <html>

    <head>

    <title>Untitled Document</title>

    <script src="c2runtime.js"></script>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    <script>window.jQuery || document.write("<script src='jquery-1.7.1.min.js'>\x3C/script>")</script>

    </head>

    <body>

    <button id="showID" onclick="showScore()">Show Score</button>

    </body>

    </html>

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