Mouse cursor over ANY object

Get help using Construct 3!

Post » Sat Jun 17, 2017 7:21 am

Message: PSyCHoHaMSTeRza can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
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.

https://drive . google . com/open?id=0B4VhsizTyhDHSDNoblpqbW9TTmM
Last edited by PSyCHoHaMSTeRza on Sat Jun 17, 2017 3:15 pm, edited 1 time in total.
B
13
S
4
Posts: 25
Reputation: 867

Post » Sat Jun 17, 2017 11:25 am

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.
B
20
S
8
G
3
Posts: 458
Reputation: 4,055

Post » Sat Jun 17, 2017 11:29 am

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.
B
20
S
8
G
3
Posts: 458
Reputation: 4,055

Post » Sat Jun 17, 2017 3:18 pm

mekonbekon wrote: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?
B
13
S
4
Posts: 25
Reputation: 867

Post » Sun Jun 18, 2017 10:43 am

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 :)
B
20
S
8
G
3
Posts: 458
Reputation: 4,055

Post » Sun Jun 18, 2017 2:59 pm

mekonbekon wrote: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!
B
13
S
4
Posts: 25
Reputation: 867


Return to How do I...?

Who is online

Users browsing this forum: beohs, plinkie and 0 guests