Collision triggering one event at a time

Get help using Construct 2

Post » Thu Sep 27, 2012 3:04 am

Hi all

I have falling blocks. I want them to collide with the player character at the bottom of the screen.

When the falling block collides with the player character, I want the animation frame for another sprite on the right to change from default (in the example, it's zero) to whatever.

Once the first sprite's animation has been triggered by the falling block colliding with the player, I want the sprite next to it to change it's animation frame from zero to something else.

I have been at this for days, and I can get it to either change the first sprite ONLY or ALL the sprites at the same time. I can't figure out how to trigger the sprites changing just by colliding with the falling blocks in sequence (ex: the first falling block collision changes the first sprite, the second falling block collision changes the second sprites, the third falling block changes the third sprite etc).

I also want the falling blocks to stop falling once all the sprites animations have been changed (in this example, after three collisions).

I would really appreciate any help anyone could give. I'm going outta my mind!

http://dl.dropbox.com/u/93047429/fallingtest.capx
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Post » Thu Sep 27, 2012 3:24 am

I can't seem to open your capx. Anyone else getting a grey screen?

I'm sure others here will have better solutions, but you could do something like add an instance variable called "Order" to your number sprites, then give your first box "1", your second "2" and your last "3". You can then have a condition that says "Sprite instance variable is = to 1" or 2 or 3, giving you the box you are looking for (so it's like manually setting and picking an ID).

The actual number could be a global variable, so you can say "start global variable at 1", then do the the "where sprite instance variable is = 1", do your animation and then increment the global variable by 1 to 2, then the last number sprite after he has done his animation can set it back to 1.



In the screenshot above I'm setting the next number box ("CurrentNumberBox") in the same area you would have the animation run, but you could easily move the part where the block collides with the player.

I'm not sure if I'm making myself clear, but it might be enough to get you started :)
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Thu Sep 27, 2012 4:10 pm

Is there any chance you could upload a capx? What you're saying makes a lot of sense, I'm just having trouble fitting it all together.

I updated my capx. The grey screen was a problem, and I think it was a problem with the while loop.

My capx now correctly triggers the first sprite, but not the second or third :/

http://dl.dropbox.com/u/93047429/fallingtest.capx
Thanks so much!
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Post » Thu Sep 27, 2012 4:38 pm

Is this what you want?

CAPX
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Sep 28, 2012 1:07 am

This is what I want:

On the first collision, the first sprite goes from transparent to whatever (in this case 0)



On the second collision, the second sprite goes from transparent to whatever (in this case 1)



On the third collision, the third sprite goes from transparent to whatever (in this case 2)



That's what I would like. I can;t seem to figure it out :/

Thanks guys!
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Post » Fri Sep 28, 2012 1:19 am

Following exactly what you're asking in the post above here is a capx.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Fri Sep 28, 2012 3:30 am

Awesome, and you are correct, it will do exactly what I illustrated, but what I illiustrated wasn't entierly what I wanted to do.

The falling block is also supposed to be on of the green sprites, and also a random number each time it falls. When it collides with the player, it makes the corresponding sprite on the right match the number that was on the block. In this way the player can build numbers or words or whatever by colliding or avoiding the blocks.

I had already figured out how to make the animations of the falling block and the matching sprite match (ex: if the falling block spawned a 7, then on collision the sprite would also switch to a 7), I just can't get it to do so one at a time, and only on collision.

Think of it like tetris a bit with the falling blocks, only the player can choose to collide with them or not. On collision, the falling block's number or letter gets added to the sprites on the left to make a word or multi digit number.

So if the falling block spawned C A F T, the player could collide with the C A, avoid the F and collide with the T to spell CAT. Or the player could collide with certain numbers to make a larger number.

That's what I'm trying to do :/

It ain't workin :/

Thanks so much for the help thus far guys. Every little bit helps!
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Post » Sat Sep 29, 2012 1:01 am

Here's an updated capx, still not doing what I want, but I don't know why it isn't. Logically, I don't see why it wouldn't be doing exactly what I am asking it to, as I have described above :/

http://dl.dropbox.com/u/93047429/fallingTestWhileLoop.capx

I'm sure I'm doing the while loop incorrectly, but at least I'm not caught in an infinite loop and just getting the grey screen of death any more :/
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Post » Sat Sep 29, 2012 8:05 am

How do you like this?

CAPX
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Sat Sep 29, 2012 10:16 pm

Getting there!

Problem is, if I try to run the second event, they run at the same time.

I added a wait 3 second to the second event and now it waits to run, but it run automatically after three seconds, even if you move the player out from the collision with the falling block.

Here's an updated Capx, with movement for the player and the wait added in.

fallingTest3.capx
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Next

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 20 guests