Sorry if this has been asked before but I couldn’t find the article if so.
I am needing to have actions happen if certain sprites are present on the screen and not doing anything else. I either don’t see or don’t know the proper verbiage for an object just being present.
I’ve tried to just use a collision condition, with the background or other objects that they would just naturally be touching with no reaction, but this condition does not work (or update that it is no longer colliding) for when things are deleted.
I’ve also tried to use an animation condition as most of these objects are just simple single sprites.
Both of these conditions trigger the correct actions when the objects are created, but when the object is deleted it does not update that the collision/animation is no longer active.
You have to go to conditions, press on common conditions for all objects and go to Layer (press on layer check). Then, choose the layer you want to check for the presence of your sprite.("" will be the base layer). That’s all.
Thank you!! I was having to create “xIsPresent” variables for when things were created and destroyed to check if an object was present. This will be much easier.
Another issue now. I need something to happen when it is deleted and for some reason inversing the condition doesn’t work. So it gets deleted but does not realize that it is not present on the layer anymore?
You have to use “trigger once” on this events. Keep in mind that you have to use the condition “trigger once” on many of your events. If you don’t, the action will repeat one and over again while the condition is true. If you use “trigger once”, the action will be applied just one time when the conditions get true.
With this, you are saying that when there isn’t the object “Sprite” on the base layer, then will happen something. But if u have 2 objects of “Sprite” on the layer, if u delete one of them, the condition will not be true because there will be 1 more object “Sprite” on the layer. So, i suggest to do an event with the conditions you want get true to delete the object “Sprite” (also the condition “trigger once”) and the action delete object “Sprite” and more successive actions on this event. On this way, the extra actions will occur associated with the deleting object action.
This is very weird. I knew about the trigger once condition as I ran into many issues pertaining to that early on lmao. Almost every condition I have is trigger once. Every functional sprite will only be present once.
Just to clarify here: “Object is on layer” has nothing to do with if the object is on the screen or not. It only checks if the objects exist on a layer. It could be 1000s of pixels outside of the screen and still be on the layer.
You can create a hidden sprite, resized to fit the screen. If there isn’t a collision between that and a sprite, then the sprite is off the screen. Remember to move the hidden sprite if the camera move.
yeah that makes since but if the object gets completely deleted from the scene and not just moved off camera it should update that it is no longer on the layer IMO.
That’s correct, if an object is deleted then it’s no longer on the layer. But what Silver-Streak said was that it’s not a way to determine if a sprite is on the screen.
A sprite doesn’t automatically get deleted if it goes off screen. There are behaviours or events that can do this, but it doesn’t happen by default.
Oh yeah I realize all that. My problem is that when an object is being deleted from the scene, it is not updating the condition that
IF x_object is not on layer “” THEN do textChange
I’ve figured out a way around this, though I was just wondering if there was a way to make the inverse of object being present work.
As I stated above, I just created a separate variable for every object that is xIsPresent = 0
When xObject is created, that variable is set to 1
When xObject is deleted, that variable is set to 0
Then a condition that just checks that variable which is basically checking if the object is present on the screen. It works, you just end up with a crap ton of variables and extra work it seems. But if that is the way it must be done then that is the way I will do it lmao
Because what I’m doing isn’t as simple as the text needing to change based on one object being or not being present. There are multiple combinations of objects needing to be present or in certain spots in order to cause the text change.
Thanks for the explanation though that makes since it being able to check something that doesn’t exist. Looks like I’m doing it the way it has to be done lol