How do I make an else if statement?

Just started using Construct 2? Post your questions here

Post » Mon Jan 05, 2015 7:40 pm

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:
Image
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.
B
2
Posts: 3
Reputation: 156

Post » Mon Jan 05, 2015 9:33 pm

Why does this look so similar to viewtopic.php?f=178&t=121867

:lol:

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? :D Also I would make the 'TopBlock, etc.' smaller and remove the need for the inverted 'is overlapping' checks.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Jan 05, 2015 10:21 pm

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 :)
B
2
Posts: 3
Reputation: 156

Post » Mon Jan 05, 2015 10:34 pm

oh ok :D

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).
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Jan 05, 2015 11:29 pm

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
B
2
Posts: 3
Reputation: 156


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest