Testing for the window border

Get help using Construct 2

Post » Fri Mar 01, 2013 10:23 pm

.CAPX: https://www.sugarsync.com/pf/D6025908_4317202_6545687

When the .capx loads, left-hold the mouse button anywhere on the browser screen (eventually, I may try to limit it to just within the game window. Mr Stick will hold out his hand with a C-shaped object attached (it's supposed to be a staple, like for a stapler).

Release the mouse button and the staple sprite should fly off to the...er, big BLACK yonder. When the staple is in motion, the GrappleFire variable text should read "Fire". Presently, I have the condition set that it will return to "NoFire" once the sprite is destroyed upon leaving the screen or collides with a solid object (this does not include the DrBox sprite). I have also tested it to set to "NoFire" upon leaving the layout. ...I get the same problem, which I'll detail next.

Rapidly click the left mouse button so that the staple sprite fires off into space (NOT coliding with any of the boxes in the area). Before long, Mr Stick should get locked into his aiming stance. The GrappleFire variable will say "Fire" and will not reset. Somehow, there is a brief point in the event logic flow that I cannot account for that allows Mr Stick to resume a pre-fire stance even while the staple sprite is still in motion.

Mr Stick should NOT be able to resume is pre-fire stance UNTIL the Sprite has (1) been destroyed by leaving the window parameters OR (2) collides with a solid object (that part is working fine).

Possible solutions that I cannot figure out:
- Testing when the sprite leaves the game's WINDOW parameters
- Allowing the GrappleFire to reset to "NoFire" only when the Staple sprite has been destroyed

Can anyone see that "gaping hole" in my event flow that's allowing Mr Stick to get locked into his pre-fire stance (due to the GrappleFire variable)? Thanks!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Fri Mar 01, 2013 11:17 pm

The problem is when you click down while GrappleFire = "Fire" and then release the button after the staple has been destroyed and GrappleFire = "NoFire". Then event 18 sets GrappleFire to "Fire" but no staple has been created so you're stuck.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sat Mar 02, 2013 5:43 am

@ramones - Thank you, sir! You confirmed what @ArcadEd discovered for me earlier (he's part of a Facebook group I admin).
I'll work on it, myself, but do you have any suggestions for a fix (in case I can't see the solution...)?
Thank you, again!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Sat Mar 02, 2013 11:45 am

Checking if GrappleStaple.Count > 0 in event 18 should do it.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sat Mar 02, 2013 7:59 pm

@ramones - I'll test that and let you know. Your help is greatly appreciated!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Sat Mar 02, 2013 8:10 pm

@ramones - Wouldn't it be better to set it to GrappleStale.Count < 1, since there is already such a sprite just outside layout edge? And because I only want it to fire if there are no other sprites of that kind on the layout?Rhindon2013-03-02 20:19:05
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Sat Mar 02, 2013 8:50 pm

Well the one outside the layout gets destroyed because it's not on-screen.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sat Mar 02, 2013 9:03 pm

@ramones - OH! Yeah, I JUST discovered that a second ago...
I thought C2 might count it because it IS on the OUTSIDE of the layout so I can create new instances of it (see line 14), but I didn't realize that it's not counted AS an instance for the reason you noted. I thinks I gots it now! (Testing...testing...)
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Sat Mar 02, 2013 9:05 pm

@ramones - Thought: Would it be perhaps better to set it to GrappleStaple.Count = 1 So not to accidentally have it misfire should there somehow be TWO instances? Or rather to PREVENT two instances?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Sat Mar 02, 2013 9:41 pm

You would actually want event 18 to run if you had more than instance or they wouldn't move. You only want to prevent it running if you have 0 instances.

I was just looking at it again and I see you're not destroying the staples that hit boxes. Then next time you click you create a new staple and then the 2 of them are positioned at the stick man's hand and fired together. If you keep shooting at a box you're firing more and more staples every time.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests