Player coordinates and triggering events

Get help using Construct 2

Post » Fri Aug 23, 2013 3:17 pm

Rough example showing the problem
I'm trying to trigger an event when the player hits a certain x coordinate on the screen - in the example attached when the player hits 320 pixels the top textbox should change its text to say "done" - but for some reason it doesn't work.

If I store the x coordinate as a private variable and test that instead, it sometimes works - but not reliably. I know I could use an invisible sprite to trigger this but I would prefer not to, and am interested to see why construct doesn't play nice triggering events from screen positions. Any advice appreciated.
B
67
S
25
G
4
Posts: 212
Reputation: 7,084

Post » Fri Aug 23, 2013 3:21 pm

It only triggers if the player is at exactly 320, so if the player-movent is fast and it skips x-coordinates it will never trigger.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 23, 2013 3:25 pm

In the example capx - at least on my end even if you slowly position the sprite to 320 and leave it sitting there it still doesn't register. Slowing the speed right down yields the same results, it doesn't seem to register at all.
B
67
S
25
G
4
Posts: 212
Reputation: 7,084

Post » Fri Aug 23, 2013 3:30 pm

By setting it to greater or equal to and stopping the player movement in the same event, you'll notice the player doesn't stop at 320, but at 321 (in my tries). Which means the player was never at 320.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 23, 2013 3:31 pm

You floor the x-coordinate in the text-field, so probably it isn't exactly 320 even if the text says so..LittleStain2013-08-23 15:32:41
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 23, 2013 3:41 pm

Hmm, changing it greater or equal it works here (and stops at 320 for me) but unfortunately it won't be flexible enough for what I need it to do. Thanks for your help anyway though.
B
67
S
25
G
4
Posts: 212
Reputation: 7,084

Post » Fri Aug 23, 2013 3:46 pm

you should just check if the player is between 320 and 322.. that will work..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Aug 23, 2013 3:58 pm

That did the trick, thanks! :)
B
67
S
25
G
4
Posts: 212
Reputation: 7,084


Return to How do I....?

Who is online

Users browsing this forum: alextro and 59 guests