mouse clicked/mouse over-difference?

This forum is currently in read-only mode.
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • The problem I have is: when I hover (no click) over a sprite, all spawned instances react, instead of only that one sprite.

    MouseKeyboard: On Left Clicked on Sprite
    

    Sprite set opacity to 20[/code:309roz2z]

    With 4 instances spawned, no problems here. Only the instance I clicked on gets the opacity-change.

    MouseKeyboard: Mouse is over Sprite
    

    Sprite set opacity to 20[/code:309roz2z]

    Problem here is: all 4 instances get an opacity of 20, instead of the 1 instance I am pointing at.

    How should I change the code so that I can point at 1 instance and only that pointed on instance gets the opacity change?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Mouse & Keyboard should be picking the affected sprites properly. However, you could try working around it by throwing a "For each sprite" condition above it.

  • I changed the use of private variable (the Sprite) to global variable, as switch and it works now.

    I didn't know this had impact on the decision making of Construct.

    The setup was:

    • switch turned on (private variable sprite set to "1")
    • mouse over 1 of the 4 instances of sprite: they all responded.

    The setup is now:

    • switch turned on (global variable set to "1")
    • mouse over 1 of the 4 instances of sprite: only the pointed at-sprite responds.

    Thanks for reading and the reply.

  • The setup was:

    - switch turned on (private variable sprite set to "1")

    - mouse over 1 of the 4 instances of sprite: they all responded.

    Try reversing the order of the conditions to:

    • if mouse is over sprite
    • private variable sprite is set to 1

    Also make sure that the pv you're checking for is 1, not "1".

    Edit: In the example you mentioned, how many sprites had a pv=1? Each extra condition works as an "and". If there were no sprites with a pv=1, this could have happened:

    If pv=1 (if there are none, construct picks no sprites)

    AND

    mouse is over sprite (there were no sprites chosen from the previous condition - therefore still no sprites chosen because no sprites meet BOTH conditions)

    Then the object list has no picked sprites, so when you tell construct to set the opacity, it sets the opacity of all of them.

  • Thanks, I'll try it

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