adrelles's Forum Posts

  • 5 posts
  • I'm trying to recreate the code below in Construct 2. I think I have most of it correct, but the stop loop doesn't seem to work.

    var array1 = new Array("a" , "g" , "e" , "j" , "a");

    var array2 = new Array("b" , "a" , "c");          

    for each (var letter in array2) {

    for (var i=0; i < array1.length ; i++) {

        if (letter == array1(i)){

            array1(i) = -1;

            break;

         }

    }

    trace(array1);

    // OUTPUT: is -1,g,e,j,a

    When the loop finds the first letter 'a' it changes it to '-1', but stops and doesn't change the last 'a'. In Construct the output is -1,g,e,j,-1. The only thing I can think of is that I'm not implementing the stop loop properly.

              <img src="http://assets.universityalliance.com/construct/screenCap.jpg" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Will do. Thanks for the help. I feel like a displaced refugee of the Apple and Adobe Flash wars. I hope Construct 2 can become my new home.

  • Thank you. I see how you set the value in the instance and then check that value against the function param. I assume that means that when the program gets to step 9, that it checks all the instances of LetterDisplay. I think that's the part I'm having trouble conceptualizing. In Flash you have to target an instance specifically with dot syntax.

  • Anyone.. please. <img src="smileys/smiley19.gif" border="0" align="middle" />

  • I'm sure this has already been answered somewhere in the forums, but I can't seem to find an answer that makes sense. I'm new to Construct 2 and coming from using Flash, so I might not be thinking about this the right way.

    The project is to build a simple Hangman game, so no enemies, or collision, just logic.

    I have a function that creates the letters of the word from XML data as invisible sprites and places them in a line an the stage. Easy enough. Then as the user selects letters if the letter exists in the string, it reveals that letter.

    If I were doing this in Flash I would create an array and put the letter sprites in that array. Then I loop through a find(string) and use the return to make that position in the array visible.

    It's that last step that I can't figure out. I don't know how to use the find return to target a specific sprite to reveal that letter.

    dl.dropboxusercontent.com/u/16604965/HangMan.capx

  • 5 posts