How do I make an else if statement?

0 favourites
  • 5 posts
  • Hey everyone, I started using Construct 2 a few days ago following the match 3 game tutorial on tutsplus.

    The project I'm making is similar so it's a good base. However I'm having trouble figuring out how the else condition works, or I might possibly be passing my parameter wrong. Here is a screenshot of my event sheet:

    In my Stack() function I want to do different things if the color matches and if it doesn't:

    -If the dropped one matches the color of the one it overlaps, I want to destroy the one at the second position [(1,0), (1,1)] and move the dropped one to the second position and increment its level (stacking it).

    -If the color doesn't match, I want to put the dropped one back at position [(0,0), (0,1)] where it started (just as if it wasn't overlapping any valid position, top, bottom, left or right) , and do nothing else.

    Am I passing my function parameter wrong?

    Is there something wrong with the hierarchy of the Stack() function?

    Maybe I'm using the array wrong? It's 2x2

    Any help would be greatly appreciated, I feel like I must be missing something silly.

  • Why does this look so similar to

    BTW I fixed it for the other person and removed most of the code, including those Else blocks. The array is overkill really. So was I doing someone's homework? Also I would make the 'TopBlock, etc.' smaller and remove the need for the inverted 'is overlapping' checks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey thanks for the reply,

    The other thread is just a coincidence for me the project is just for fun.

    The inverted 'is overlapping' checks are just to make sure you are not overlapping with more than one position.

    Without them it triggers also if you're overlapping the bottom and the left one for example.

    What do you mean by the array is overkill? I figured this would be the proper way of storing positions temporarily, is there a simpler way?

    The tiles (up, down, left and right) are the same size as the circles, or do you mean make the code blocks smaller?

    Thanks again

  • oh ok

    Looks like yours is a little different. The other one is a grid of rectangular blocks. Anyway in event 14 you are setting the Circle position twice in succession. Also if you have the full license, use a Family and put the TopBlock, etc. in it. This will remove events 7, 8, 9 (6 will be changed to use the Family). When I say its overkill, I mean you just need to remember an x,y position (where to move the circle to). That's IF yours is similar to the other project (which is hard to tell from a screenshot).

  • Hi, I don't have the full licence, I'm planning on just prototyping with this tool actually. The project is pretty much the same I think, I use circles but just for the bitmap, the overlapping is actually a square. For the setting twice the position, I already changed that, the screenshot was a bit old. I'll try getting rid of the tiles then and just passing positions. Something still is weird when I check if the color matches though. I'll look into it with more detail soon.

    Thanks

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