How do I check is my mouse over the sprites?

0 favourites
  • 7 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • I know that there is "is over object" but it won`t work for me because my sprites have transparent parts too so even when mouse isn`t over the sprite it technically is :/

    I would like to be able to select each of the provinces ( I cut them up in photoshop and exported them as separate png files ) but that isn`t possible if their boundaries overlap

    See? It is a big problem and I can`t continue without solving it, is using collisions possible? And if so wouldn`t it lag the game to have around 250 collision dots?

    Thanks in advance guys!

  • You can paint each province with different colors and use Canvas plugin to detect RGB color at mouse cursor position.

    scirra.com/forum/plugin-canvas_topic46006.html

  • Thanks so much not only does it help with provinces it also helps with ownership over them which I can change with this plugin!

  • Stenky

    dop2000's solution sounds like it would work fine... but I was curious how I would tackle that - and what the performance hit would be.

    so, I made a sample. The irregular shape of the provinces does make it tricky. but if you edit the collision masks to cover as much as possible (without adding too many points) it does seem to work well. Neither my computer or iPad broke a sweat... (debugger said it was using about 5% on both)

    I like to keep things as simple as possible and avoid plugins unless you really need the functionality.

    anyway, you can try my version here:

    https://www.rieperts.com/games/forum/france.capx

    it works with mouse or touch... but I only did 10 provinces. Obviously, there are some dead areas near the edge of a province if the collision mask doesn't cover that spot. In the code, I make sure to Pick the Top instance, just to make sure you can only select one province if the masks do overlap.

  • AllanR Thank you so much! This is amazing, I just did it ( On a bigger scale ) and it works perfectly! I can`t thank you enough..

    drive.google.com/open

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome! :) good luck with your game!

  • Stenky

    dop2000's solution sounds like it would work fine... but I was curious how I would tackle that (...)

    I grabbed some popcorn and started reading. :D

    Great to see AllanR taking time to put this much effort in it. (dop2000, oosyrag, kyatric and newt also offer lots of insight of course)

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