Mouse cursor over ANY object

0 favourites
  • 6 posts
From the Asset Store
Mouse cursor is something that the player controls and sees all the time, that's why it is so important to make it cool!
  • Hi folks. So I am trying to make a city building game. I already got the grid system in place, and the buildings menu. Now, I want to make so that I can't build when there is something else in the way. You know, like when you try to build something in Sim City or Age of Empires, but if something else is in the way it has like a red overlay?

    I know it should have something to do with "mouse over object", but in the even system it requires me to select a specific object. I want my overlay thingy to happen when I mouse over ANY object. Or do I really need to make an event for each and every object in my game?

    BONUS POINTS. Any other advice to make this part of my script better, before I add more buildings? Here is the c3p.

    drive . google . com/open?id=0B4VhsizTyhDHSDNoblpqbW9TTmM

  • Stick all the objects that you want to register in a family and then test the mouse over for that family, rather than the individual object types.

  • Also, your link is bust - copy and paste automatically contracts the link (notice the ellipsis towards the end) - you'll need to post the full link and add a space either side of the periods to stop it contracting again.

  • Also, your link is bust - copy and paste automatically contracts the link (notice the ellipsis towards the end) - you'll need to post the full link and add a space either side of the periods to stop it contracting again.

    Thanks for the tip about the link. I added the spaces before and after the periods.

    Okay, I will try the family thing, thanks. I didn't think about that. Though I do think that having an "any" option would be kind of useful, don't you think?

  • Hi, I took a look at your code; here are a few suggestions that you might want to consider:

    1) Instead of spawning objects you could use a tilemap and change the tiles to when you click. This would only be a suitable option if you don't intend to animate placed objects (you can animate tiles, but it is fiddly to set up and kills your framerate).

    2) Your code in each object group is essentially the same - you could replace all of these with a single function and instead of having the booleans plantWheat, plantCorn etc just have a single global string variable "plantObject" that you set to the object type. C3 has the very cool action "create object by name", so you can pass plantObject in order to spawn the correct object type.

    3) Alternatively, rather than having individual shop objects and placed objects you could have one shop object and one placed object, and have the different types as separate animations. This would reduce your object count and also allow you to simplify the code.

    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
  • Hi, I took a look at your code; here are a few suggestions that you might want to consider:

    1) Instead of spawning objects you could use a tilemap and change the tiles to when you click. This would only be a suitable option if you don't intend to animate placed objects (you can animate tiles, but it is fiddly to set up and kills your framerate).

    2) Your code in each object group is essentially the same - you could replace all of these with a single function and instead of having the booleans plantWheat, plantCorn etc just have a single global string variable "plantObject" that you set to the object type. C3 has the very cool action "create object by name", so you can pass plantObject in order to spawn the correct object type.

    3) Alternatively, rather than having individual shop objects and placed objects you could have one shop object and one placed object, and have the different types as separate animations. This would reduce your object count and also allow you to simplify the code.

    Hope that helps

    This actually helps a lot! The thought of functions did cross my mind, but because I didn't know about the spawn by name thing, I didn't think it would work so well. I'm still very new to this, so thanks for the advice!

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