Detecting if the same sprite is hit twice in a row

0 favourites
  • 4 posts
From the Asset Store
🙌 J-BoB Damage & Hit Sound Pack comes with 585 high-quality sound effects
  • Suppose I have 6 sprites on the screen and they are 2 sprites named "apple", 2 sprites named "orange" and 2 sprites named "cherry". If I have another sprite named "rock" and I drop it on the sprites below, is there a way to detect if it hit the same sprite twice in a row. It would have to reset if it hit an apple first and then an orange. If for example, it hit the orange first and then the other orange, it would do something like play a sound. Thanks much if you can say how.

  • Have a 'lastHit' global variable and set it to the object's name on collision with that object. Then you can say 'on collision with cherry + global variable = cherry: play sound'. Then as a sub-event 'set global variable to cherry'. Setting the variable needs to be after checking the variable, or else it will always be true obviously.

    Hope that helps!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 1.-use a text instance variable in your items, like: "howManyTimesHaveThisBeenHit".

    2.- on first hit, set it to "first",

    3.- on second hit, set it to "second"

  • Thanks guys! Appreciate your input. I haven't been able to make either idea work yet but I'm still working on it. I think I'm getting close though.

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