How do I detect the animation frame of the sprite clicked on

Get help using Construct 2

Post » Tue Nov 10, 2015 3:51 am

I have a sprite with 10 animation frames and I have 10 copies of he sprite each set to a different initial frame .
When I click on any sprite , I want a different music file to play . I have the names of the music files stored in an array and I am using <sprite name>.animationframe to identify which element of the array contains name of the music file to play.
Using "pick instance with UID Function.Param(0)", I can identify the clicked on sprite for flash / rotation resize etc effects & the music associated with all frames plays , but I also hear the music associated with the first frame , along with the music for individual other frames.
I sorted the part where music of first sprite plays with the music for others by setting the "mute effect " to the music file for the first sprite, but now I want to remove the mute effect when user cliks on the first sprite.
This led me to think I need to know the <sprite name>.AnimationFrame which will give the music file to conditionally mute/unmute a music file.
Somehow when I set a text box text to <sprite name>.AnimationFrame, it always shows the value "0" being the initial frame of the first sprite.
I need to get numbers like so -
2 when I click on 3rd sprite,
0 when I click the first sprite, ,
5 when I click the 6th sprite so that the music associated with the first sprite doesn't play alongwith others, but plays when the first if clicked.
What am I doing wrong ?
B
6
Posts: 16
Reputation: 296

Post » Tue Nov 10, 2015 4:35 am

You are trying to get the animation frame of a certain UID of a sprite?
Eat ALL THE BACON!
B
47
S
17
G
3
Posts: 290
Reputation: 5,070

Post » Tue Nov 10, 2015 4:39 am

It's a little tough following what you're doing without at least a screenshot of your events, but I would give each music track a tag called object.animationframe. Then I believe you could use the inverse of is tag=object.animation frame to mute all of the others.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Tue Nov 10, 2015 9:45 am

The action sprite on clicked: text set text to sprite.animationframe should work, because you reference the sprite you want in the event..

Without seeing your capx, with the information you give, it seems like you have problems with picking..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 56 guests