Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411505 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 25, 2024, 09:19:32 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Differences in result when code goes in draw/step event [resolved]
Pages: [1]
Print
Author Topic: Differences in result when code goes in draw/step event [resolved]  (Read 546 times)
AuntEggma
Level 0
**



View Profile
« on: September 26, 2016, 07:49:11 AM »

Hey folks, I have a type of ground object that's supposed to get a yellow border when the player is on top of it

As it is now, the ground only lights up when the player is on top of one instance in particular... And even then, every object gets a yellow border - not just the one the player is on top of.

If I delete the step event and move place_meeting(x, y-1, oPlayer) to replace global.PlayerOnGlowGround in my draw event, it works perfectly.  Each individual ground object lights up when the player is on top of it.

What am I not seeing about how the step/draw events work?  Or maybe my problem is with how place_meeting works...?
« Last Edit: September 26, 2016, 08:14:45 AM by AuntEggma » Logged
Thorves
Level 0
*


View Profile
« Reply #1 on: September 26, 2016, 08:03:37 AM »

Your image link is dead, but from your explanation I think I know whats going on.

You are using a global variabele, meaning it's value is shared between all instances. When one ground object detects the player standing on it, it sets the value to true, but then the next object does the same check and sets it back to false. Remember dat first ALL step events are executed and then all draw events every frame.

When you step on the ground object whose step gets executed last (highest instance id) there is no object to override it and when drawing all objects see the value as true.

Using a local variabele instead should fix it.
Logged
AuntEggma
Level 0
**



View Profile
« Reply #2 on: September 26, 2016, 08:08:39 AM »

Oops.  Posting images from slack isn't smart...  Thanks.  That was my problem.  I needed to know which instance the player is standing on so I can light it up and also whether the player is standing on any instance.  That's why I was using a global var.  But I'll just get rid of the global var and do the place_meeting check again.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic