How do I fix this bug (if it is a bug)?

Get help using Construct 2

Post » Sat Jul 11, 2015 6:42 am

I'm using tilemap to create a long arrow that follows the mouse across the tiles it goes through. This doesn't matter though cause the problem isn't related to that. The problem is the event in the red box does not trigger even though the action in the green box does print "21" which is the tile im comparing to in the red box.

Image

What's also weird is that this only happens when I enable this "or" statement in the red box in the picture below:

Image

The red box statement is just comparing the tile where the mouse is to "21". When it's disabled the program runs fine. Why is this problem happening?
B
4
S
1
Posts: 9
Reputation: 268

Post » Sat Jul 11, 2015 9:42 am

I wondered if it might be due to a collision (e.g. a triggered event) firing elsewhere. I'm not sure (and the docs don't say) if a triggered event only fires when the 'event processor' is at the outer level.

How about creating a local variable and putting the Tile() = 21 test in that, calculated at the top of your tile checking, replace the green and red bits with testing that instead ? See if that works, if it does, see if the value of that test is somehow changing between the initial test and the end.

It also looks to me that you are testing Tile(x,y) = something or other and as a consequence of that changing x and y. This is quite chancy for knock on effects. I'd be inclined to read Tile(x,y) into a local and then test it. What you basically have is a case/switch statement on Tile(x,y) and it is not a good idea to change the case/switch expression as you go :)
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Sat Jul 11, 2015 11:18 am

Thanks for the reply. Can you explain the first paragraph more?

I have fixed the problem by separating the two "or" statements and not allowing the second statement to fire if the first one did. What do you think is going on? I will revert it and try what you said though by putting the "Tile() = 21" test at the top. I just gotta go to sleep now.

You're right about the testing while x,y are changing though. I tried to circumvent that with the "tuned" variable, but your way is the better more obvious way to do it.
B
4
S
1
Posts: 9
Reputation: 268

Post » Sat Jul 11, 2015 3:55 pm

In C2 (I think !) events run sequentially, but triggers - collisions, keystrokes etc. fire on as needed basis. I don't know where these fire in the 'event processing' though - if they could fire in mid event then this might be whats causing your problem.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328


Return to How do I....?

Who is online

Users browsing this forum: tdcostas and 1 guest