affecting a large group of duplicate objects seperately

This forum is currently in read-only mode.
  • I have a large grid of duplicate objects.

    I'd like to have each one have seperate collision.

    right now if I create a large grid of the same object, and then apply

    if mouse is over object then change opacity to 50

    if mouse is not over object then change opacity to 100

    each object is changed as I mouse over each one, but I have to move the mouse away from the entire group for them to change back to 100 opacity, i'd like each object to change individually..

    can anyone point me in the most sensible direction to achieve this?

    thanks as always..

  • If objects are too close together, then the condition remains true while mouse moves over objects, as it doesn't actually leave the object type yet.

    But here is an unique property of each object instance: Unique ID - UID. See the code:

    +MouseKeyboard: Mouse is over Sprite 
    

    System Set global variable 'Test' to Sprite.UID

    Sprite Set opacity to 50

    +Sprite: Unique ID is NOT global('Test')

    Sprite Set opacity to 100

    [/code:nwff6iyo]

    Basically, whenever you hover mouse over an object, you change its opacity and store its UID, so it is exempt from the other event, which sets objects with different UID back to original opacity.

  • There's an even simpler way.

    + Always

    -> Set object opacity to 100

    + Mouse is over Sprite

    -> Set object opacity to 50

    Events are read in top to bottom order, so they all have 100 opacity, except for the one under the mouse. "Mouse not over object" won't be true and won't run until the mouse isn't over any of the object, hence the problem.

  • thanks, that seems to only affect one at a time though, if a larger object that covers more than one object overlaps them, only one is affected..

    my apologies if I came across as too specific..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sprite is over sprite

    set opacity-

    Sprite is not over sprite

    set opacity+

    using a sprite as pointer....

  • thanks, that seems to only affect one at a time though, if a larger object that covers more than one object overlaps them, only one is affected..

    I don't understand. Do you have a .cap?

  • Sprite is over sprite

    set opacity-

    Sprite is not over sprite

    set opacity+

    using a sprite as pointer....

    Yep, this would work pretty good. Just make a tiny sprite and always set it to mousex, mousey.

  • sorry ash, that works wonderfully, I was responding to the previous poster..

    I think we may have posted our responses around the same moment

    Thankyou all

  • I learned a lesson, too!

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