Mouse trigger not working properly

Bugs will be moved here once resolved.

Post » Mon May 06, 2013 4:04 am

Link to .capx file (required!):
https://dl.dropboxusercontent.com/u/47035927/Samples/Music_Box.capx

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:
    128.2

Edited:
I did it work by another way: https://dl.dropboxusercontent.com/u/47035927/Samples/Music/music.capxTELLES08082013-05-06 17:12:57
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Tue May 07, 2013 3:14 pm

Closing as not a bug, your events say to stop the music then immediately restart it. Try using a sub-event and 'else'.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue May 07, 2013 6:31 pm

@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)



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.
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Tue May 07, 2013 6:37 pm

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!
B
40
S
9
G
5
Posts: 127
Reputation: 6,609

Post » Wed May 08, 2013 2:11 pm

@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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests