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

0 favourites
  • 4 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • 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 ?

  • You are trying to get the animation frame of a certain UID of a sprite?

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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..

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