How do I make adjacent sprites clickable?

Get help using Construct 2

Post » Sun Jan 29, 2017 6:54 pm

I'm trying to make a grid system where you can click on an adjacent block to turn it red. I've placed sprite blocks in a grid system and put a boolean variable on each sprite that determines whether or not it's clickable depending on its adjacency to other blocks. Sometimes it does not set variable to true even though other times it should, even when multiple act on the same block it should set it to the same state.
Last edited by lauwise on Sun Jan 29, 2017 7:00 pm, edited 2 times in total.
B
3
Posts: 4
Reputation: 183

Post » Sun Jan 29, 2017 6:57 pm

Probably some logic error but it's impossible to tell without an event sheet. can you post a screenshot of the event sheet, the game screen or a link to the capx?
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Sun Jan 29, 2017 7:01 pm

Here's a picture, took a while to get it uploaded

http:// imgur .com /a/xLM0x
B
3
Posts: 4
Reputation: 183

Post » Sun Jan 29, 2017 7:18 pm

Seems alrite, are the tile positions definitely +/- 100 of each other. Launch in debug and check the co-ords, clickable won't be true if it's slightly out. Change the opacity of clickable tiles so it's easier to see for testing.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Sun Jan 29, 2017 7:23 pm

Tiles are definitely exactly 100 +/- of one another. It seems random which tiles are clickable, though the ones that are clickable are adjacent like we want them to be. All we are able to tell is that it might depend on the order in which we click the initial tiles.
B
3
Posts: 4
Reputation: 183

Post » Sun Jan 29, 2017 7:37 pm

Ah I just ran a test and I can see what's happening. It's only comparing against previous IU tiles and not always picking the new one. Put your x,y checks within a For each IU tile event, that way you know it's checking adjacent tiles on every IU tile.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Sun Jan 29, 2017 8:30 pm

That seems to have worked! Thank you!
B
2
Posts: 1
Reputation: 152


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi and 17 guests