Mouse trigger not working properly

0 favourites
  • 5 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Link to .capx file (required!):

    Steps to reproduce:

    1. Preview the project

    2. Click on the image to stop the music

    Observed result:

    It still playing...

    Expected result:

    Should stop, and if clicked again, should play.

    It's a trigger, We can't put "Once while true" for it, so, it's not working properly or how We imagine it should work.

    Construct 2 version:



    I did it work by another way:

  • Closing as not a bug, your events say to stop the music then immediately restart it. Try using a sub-event and 'else'.

  • Ashley

    Maybe it help clear the understanding, because I need to make sure how the things work to teach right, and sometimes it happen and I can't explain why...

    This image is from the music_box.CAPX followed by the music.CAPX events, where the issue is affecting only the music_box.CAPX. (I edited the first post and updated the file)

    <img src="" border="0" />

    Using the trigger "On object touched" or "On object clicked" plus, adding the frame conditional, it will run the action with the frame state = 0 or 1 once, while the second conditional is not meet, it wouldn't run.

    How it's saying to stop the music then immediately restart it, if, it's using a trigger?

    There is no choice of use the "Once while true" here.

    By the way, it is possible to the event happening first, change the condition of the second to valid and the second run at the same time, making it valid, making a looping? Sorry, but it don't make sense.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try a wait(0.1) on the touch event, before doing "set animation" and stop or play music :)

    The events are triggered almost in the same time!

  • TELLES0808 - events (including triggers) run top to bottom. So your first set of events runs like this:

    1. User touches the 'som' object

    2. The touch object runs 'On touched 'som'' in top to bottom order in the event sheet

    3. Event 2 runs. The animation frame is set to 1.

    4. Event 3 runs. The animation frame was just set to 1, so this event is also true. So it sets the animation frame back to 0 and restarts the music.

    In other words, both events run at the same time. It's a common mistake. In your second example it works because you first toggle the variable then check the result, so it's not possible for both events to run at once.

    The best way is just to use 'else' in a subevent, like this:

    + On touched 'som'

    ----+ Animation frame = 0

    ----> Set animation frame to 1

    ----+ Else

    ----> Set animation frame to 0

    This works because 'else' doesn't check the animation frame again, it only runs if the previous event did not run.

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