0plus1's Forum Posts

  • Another question, the same capx file applies.

    In the cardsDeal group. If I wanted to avoid the "dealing" of face cards, how should I do it?

    I tried adding these conditions:

    (RandomArray.At(cardsCounter) % 13)+1 != 11

    (RandomArray.At(cardsCounter) % 13)+1 != 12

    (RandomArray.At(cardsCounter) % 13)+1 != 13

    On top of the loop but it doesn't work at all, it just stops as soon as the system finds a face value.

    Also.. is it possible to test variable with || (OR) or %% (AND)?

    Also, is possible to set/unset specific values at a specific index of the array?

    For example I have a random array of 52, I already used the number 10 and I unset it, resulting in an array of 51 elements.

    Thanks

  • Thanks to everybody I learned a lot from each of you.

    I ended up using Yann "code".

  • Please somebody help.. I'm about to cry.

    Here's the capx dl.dropbox.com/u/1606950/test.capx

    (Requires random array plugin)

    Why, why can't I delete the picked card instance... <img src="smileys/smiley19.gif" border="0" align="middle" />

  • Put your html here:

    <div id="no-chrome" style="display:none">

              YOUR BROWSER IS NOT CHROME

         </div>

  • This si the index.html that construct generates, open it and change everything to this:

    <!DOCTYPE html>

    <html manifest="offline.appcache">

    <head>

        <meta charset="UTF-8" />

         

         <!-- This ensures the canvas works on IE9+. Don't remove it! -->

         <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8" />

         

         <title>Test</title>

         <!-- Note: running this exported project from disk may not work exactly like preview, since browsers block some features on the file:// protocol. Once you've uploaded it to a server, it should work OK. -->

         

        <!-- This outlines the canvas with a black border. -->

         <style type="text/css">

              canvas { border: 1px solid black; }

         </style>

    </head>

    <body>

         <div id="fb-root"></div>

         <div style="text-align: center;" id="canvas-container">

            <!-- The canvas the project will render to. If you change its ID, don't forget to change the

            ID the runtime looks for in the jQuery ready event (above). -->

              <canvas id="c2canvas" width="640" height="480" oncontextmenu="return false;" onselectstart="return false;">

                <!-- This text is displayed if the visitor's browser does not support HTML5.

                You can change it, but it is a good idea to link to a description of a browser

                and provide some links to download some popular HTML5-compatible browsers. -->

                   Your browser does not appear to support HTML5. Try upgrading your browser to the latest version. <a href="http://www.whatbrowser.org">What is a browser?</a>

                   <br/><br/><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Microsoft Internet Explorer</a><br/>

                   <a href="http://www.mozilla.com/firefox/">Mozilla Firefox</a><br/>

                   <a href="http://www.google.com/chrome/">Google Chrome</a><br/>

                   <a href="http://www.apple.com/safari/download/">Apple Safari</a><br/>

                   <a href="http://www.google.com/chromeframe">Google Chrome Frame for Internet Explorer</a><br/>

              </canvas>

        </div>

         

         <div id="no-chrome" style="display:none">

              YOUR BROWSER IS NOT CHROME

         </div>

         <!-- Pages load faster with scripts at the bottom -->

         

         <!-- Construct 2 exported games require jQuery. To save bandwidth, by default

         this is set to grab it off the Google content delivery network (CDN). Fall back to local if not available. -->

         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>

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

         

        <!-- The runtime script. You can rename it, but don't forget to rename the reference here as well.

        This file will have been minified and obfuscated if you enabled "Minify script" during export. -->

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

        <script>

            // Start the Construct 2 project running on window load.

            jQuery(document).ready(function ()

            {

                   var userAgent = navigator.userAgent.toLowerCase();

                   $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());

                if($.browser.chrome){

                        // Create new runtime using the c2canvas

                        cr.createRuntime("c2canvas");

                      //INITIALIZE CONSTRUCT

                   } else {

                      $("#no-chrome").show();

                      $("#canvas-container").hide();

                   }

            });

        </script>

    </body>

    </html>

  • I would do it with a bit of javascript and css.

    This is the javascript part, then you could make a not chrome div in the html and show it.

    var userAgent = navigator.userAgent.toLowerCase();

    $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());

    // Is this a version of Chrome?

    if($.browser.chrome){

       //INITIALIZE CONSTRUCT

    } else {

       $("#div-nochrome").show();

    }

  • drpool, I tried what you said, it wouldn't work and upon inspectin the problem it looks like the sub-event checks if the mouse is over the instance picked with UID while I need to pick ANOTHER instance, completely different from the one where my button has been released

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have several spawned object.

    On mouse over OBJECT_1 && Left button Clicked -> set global_var to OBJECT_1.UID

    On mouse cursor over OBJECT_1 && Left button Released -> ???How do I do this: destroy UID???

    I hope I was able to explain myself

    EDIT: to be more clear. I stored the first object UID in a global variable, when I'm over the other object I want to destroy the first object, the one which UID I stored in the global var.

  • Maxum Thanks, I understand now, I didn't knew construct kept track of the instanced object, it's incredible how easy it is, I'm a programmer (applications, not games) so I'm accustomed to another way of thinking, incredible.. as soon as I finish my game I'll be sure to show it you.

    Yann I'm re-doing the classic solitaire (the one included in windows) to learn construct

  • Thanks Yann, you answer confirm that this is not the way to go for me.

    What I want is to be able to click on a card, retrieve it's value/suit, then destroy it or drag it across the screen.

    The array method gives me the value with a mathematical "trick" but doesn't get me the spawned object id.

    Now I just started in construct, so I'm not really sure if it's even possible to have an event like:

    onclick spawned_object_10 do something..

    As I see it he only way would be to load each card as a different object and then using a randomized array spawning them on the screen, keeping each of them indipendent.

  • Hi, I'm making a solitaire game, I followed all the advices here and I understand what are you all saying, but there's a problem.

    The formula that Yann posted gets you the current card, and I understand the principle BUT what if I want to get the card value and suit LATER?

    I lay down my rows, then I want to click on a card and retrieve the value and suit, how can one do that?

    Thanks

    EDIT: I could keep track of the position of each card, but it looks "hackish" is there a way to set a variable to each of the spawned card object?

  • (even down to the 10mb limit! for now at least, some games are 90mb)

    Sorry for the OT but Kroll has been made in HTML5?

    My jaw has dropped!!!

  • I see.. then what is the route to take?

  • You can use the Chrome trace tool to do a step-by-step progression inside your JS code to spot where is your problem.

    Not a bad idea, still a little complex since you will be tracing all of the construct javascript and not only your "code" a debugger would be very nice, meanwhile I'll follow your advice.

    Thanks

  • Is there a debugger somewhere? Like something that dumps everything (variables, objects instances, etc..) somewhere? Something like the firebug console.log('something');.

    If not it should be implemented someway, it's a pain to create text objects to check the variables..