On click not working

0 favourites
  • 2 posts
From the Asset Store
High quality sound effect pack, in the following categories: Simple, negative, pozitive
  • Hey Guys,

    I'm trying to build something fairly simple. I have a band with players. And when you click (or tap) on a bandmember, a loop will start playing. And if you click (or tap) the same bandmember the loop will stop. In reality, I want this loop to keep playing, but just change the volumes. So far I have part of it working but I run into a weird problem..

    My 3rd solution so far:

    I tried lots of things and I thought maybe clicking on the same sprite is gonna cause problems. So I now made 2 sprites. SpriteA (volume up) and SpriteB (volume down).

    As soon as you start the scene, SpriteA is created and the volume is set to -100. When you now click on SpriteA, the volume will go to 25. In the same click SpriteA will be destroyed after clicking, and SpriteB will be created in the same location.

    The idea was that, if you now click on SpriteB, the volume will go back to -100. SpriteB will get destroyed. And SpriteA will be loaded in the same spot again.

    This is very clunky I realize that, but the logic not working. Made me desperate, and it brought me here eventually I guess hahah. I even tried to create the sprites on different layers but the effect was the same.

    What I discovered:

    This solution does not work, I can provide a screenshot as well. BUT... if I let SpriteB to be created on a different location on the screen. So not where SpriteA was. THEN IT WORKS !!!

    But if I have both sprites in the same location, nothing happens. SpriteA does not get destroyed, it just gets recreated again (the sprite animation starts over at least). No sound volume gets changed, and SpriteB will not be created.

    So if I create SpriteB 200 pixels to the left. Everything works fine!

    Is this a bug or am I just being an idiot? I mean, it happens every now and then so I wouldn't be surprised. But I hope someone could maybe help me with this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The reason this is happening is because of the way Construct runs events top to bottom and it all happens very quickly in the same tick. So when you click on Base2 and create Base, actually it is created in time to be true for the event below so then it is like you are clicking on Base. You could probably add a short wait between destroy and create actions (the wait you have is in the wrong place) and then it should work.

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