Testing for the window border

0 favourites
  • 11 posts
  • .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!

  • 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.

  • 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!

  • Checking if GrappleStaple.Count > 0 in event 18 should do it.

  • ramones - I'll test that and let you know. Your help is greatly appreciated!

  • 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?

  • Well the one outside the layout gets destroyed because it's not on-screen.

  • 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...)

  • 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?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ramones - I did notice that (I have a Text object set up to check...). That's okay for now, because the final part of the project for this "grapple hook" will eventually lead to it being destroyed when it hits a solid object...I just haven't gotten to that point yet. Thank you for noting that for me, though. :) You've been extremely helpful!

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