• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED] Exist

M

Marten

Guest
Hey,

I've got a quick question; what does gamemaker define as exist? I've got a draw event that draws a sprite, and deletes that sprite as another one is drawn at that exact position, but the second sprite 'doesn't exist', while the name is correct and does indeed exist in my game files. The error code is "Trying to draw non-existing sprite."

The code is really simple:

Code:
if obj_player.hp = 6   
{
    draw_sprite(spr_sprite1,1,view_xview[0]+10, view_yview[0]+10);
}

if obj_payer.hp < 6

{
sprite_delete(spr_sprite1);   
draw_sprite(spr_sprite2,1,view_xview[0]+10, view_yview[0]+10);
}
 

Paskaler

Member
Straight outta the manual:

This function will delete a sprite from the game, freeing any memory that was reserved for it. This is a permanent removal, and if the asset that you delete was included as part of the game's resources, not even restarting the game (unless you close the application first) will recover it. This is a very important function for those moments when you need to create and change sprites from external resources and should always be used to remove those assets that are no longer needed by a game, or to clear an indexed asset from a variable before re-assigning another asset to that variable.
Also, this code doesn't even need the sprite_delete part at all to work as expected, I believe. spr_sprite1 will be drawn if the hp is 6 and it won't be drawn if hp is either less than or greater than 6.
 

TsukaYuriko

☄️
Forum Staff
Moderator
You seem to assume that a "sprite" is a tangible entity that is placed into a room when draw_sprite is called, much like object instances. I'm unsure where you got this misinformation from.

Sprites are graphic resources which can be drawn to the back buffer in draw events to make them appear on the screen. As the back buffer is cleared every step and there is no way to identify a sprite after it has been drawn because it turns into mere RGBA pixels on a surface, there is no need and, in fact, no way, to "undo" the drawing of sprite, which you seem to be attempting to do. In reality, you are literally wiping a sprite resource out of existence and subsequently wonder why it apparently no longer exists.
 
M

Marten

Guest
You seem to assume that a "sprite" is a tangible entity that is placed into a room when draw_sprite is called, much like object instances. I'm unsure where you got this misinformation from.

Sprites are graphic resources which can be drawn to the back buffer in draw events to make them appear on the screen. As the back buffer is cleared every step and there is no way to identify a sprite after it has been drawn because it turns into mere RGBA pixels on a surface, there is no need and, in fact, no way, to "undo" the drawing of sprite, which you seem to be attempting to do. In reality, you are literally wiping a sprite resource out of existence and subsequently wonder why it apparently no longer exists.
Yeah, sounds very cool and all the way you explain it, yet you completaly miss what I originally asked. Yet again, and this is the third time it happened, I am seen as a stupid person (or so you make it sound) because I think something works in a certain way. I am going to repeat myself once again: You do not know how long I have been using Gamemaker, nor how much I know of computers. All I know is that a sprite is a picture, and an object can do things, that's it. This rudeness doesn't help anyone, yet people like to be this way.

Besides, you did not even read my whole post, or you forgot completely what I asked, so I'll repeat myself yet again: "I've got a quick question; what does gamemaker define as exist?". All you did was go on about something Paskaler already said, but in a nice way.

Oh, and by the way, I did not remove the sprite I was trying to call in, take a better look at the code of people you're trying to be mean to, thanks.

Now I'll ask again nicely, what did I do wrong here, and what does gamemaker define as exist?
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Code:
ex·ist
iɡˈzist/
verb
verb: exist; 3rd person present: exists; past tense: existed; past participle: existed; gerund or present participle: existing
1.
have objective reality or being.
"remains of these baths still exist on the south side of the Pantheon"
synonyms: live, be alive, be living; More

be found, especially in a particular place or situation.
"two conflicting stereotypes of housework exist in popular thinking today"
synonyms: prevail, occur, be found, be in existence;
be the case
"the liberal climate that existed during his presidency"
2.
live, especially under adverse conditions.
"how am I going to exist without you?"
synonyms: survive, subsist, live, support oneself; More

Origin
early 17th century: probably a back-formation from existence.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Yeah, sounds very cool and all the way you explain it, yet you completaly miss what I originally asked. Yet again, and this is the third time it happened, I am seen as a stupid person (or so you make it sound) because I think something works in a certain way. I am going to repeat myself once again: You do not know how long I have been using Gamemaker, nor how much I know of computers. All I know is that a sprite is a picture, and an object can do things, that's it. This rudeness doesn't help anyone, yet people like to be this way.

Besides, you did not even read my whole post, or you forgot completely what I asked, so I'll repeat myself yet again: "I've got a quick question; what does gamemaker define as exist?". All you did was go on about something Paskaler already said, but in a nice way.

Oh, and by the way, I did not remove the sprite I was trying to call in, take a better look at the code of people you're trying to be mean to, thanks.

Now I'll ask again nicely, what did I do wrong here, and what does gamemaker define as exist?
sprite_delete(spr_sprite1);

so yeah your deleting the sprite permanently so when the objects hp is above 6 again it has no sprite to draw thus creating the crash
 
Can you quote exactly which sentences of the replies you received that you interpreted as being mean to you? I don't see anywhere that the replies above were trying to be anything but informative and helpful.

sprite_delete() removes the sprite resource completely, causing it to no longer exist within your game.

While the manual does not seem to use the actual word "exist", it can be inferred from the phrase "permanent removal".

So when you try to draw a sprite that has been removed via sprite_delete(), GameMaker will be unable to locate that sprite resource, hence the does not exist message.
 

Smiechu

Member
Yeah, sounds very cool and all the way you explain it, yet you completaly miss what I originally asked. Yet again, and this is the third time it happened, I am seen as a stupid person (or so you make it sound) because I think something works in a certain way. I am going to repeat myself once again: You do not know how long I have been using Gamemaker, nor how much I know of computers. All I know is that a sprite is a picture, and an object can do things, that's it. This rudeness doesn't help anyone, yet people like to be this way.

Besides, you did not even read my whole post, or you forgot completely what I asked, so I'll repeat myself yet again: "I've got a quick question; what does gamemaker define as exist?". All you did was go on about something Paskaler already said, but in a nice way.

Oh, and by the way, I did not remove the sprite I was trying to call in, take a better look at the code of people you're trying to be mean to, thanks.

Now I'll ask again nicely, what did I do wrong here, and what does gamemaker define as exist?
sprite_delete(spr_sprite1); - this function deletes the sprite with index "spr_sprite1" form the program memory not from the screen!
"Doesn't exist" means in this case that the resource (or reference to it) under index "spr_sprite1" is no longer in the program memory.

PS.
Nobody is rude here. You ask for help, get correct answers, but you don't even try to understand a word from what people say to you.
 
M

Marten

Guest
Okay, so for everyone: I start my game, spr_spr1 is drawn. My player takes damage, spr_spr2 should be draw, but it doesn't, instead the game crashed saying that spr_spr2 doesnt exist. This is my problem, looks like I did not explain this clearly at all.

Now to answer all the comments:
In reality, you are literally wiping a sprite resource out of existence and subsequently wonder why it apparently no longer exists.
The last part of this sentence seems rude and like TsukaYuriko is looking down on me for thinking as I do.

sprite_delete(spr_sprite1); - this function deletes the sprite with index "spr_sprite1" form the program memory not from the screen!
"Doesn't exist" means in this case that the resource (or reference to it) under index "spr_sprite1" is no longer in the program memory.

PS.
Nobody is rude here. You ask for help, get correct answers, but you don't even try to understand a word from what people say to you.
Why do you think I don't even try to understand what they mean? Ofcourse I do, why would I ask questions if I wouldn't?

To make it more clear I understand that deleting the sprite will eventually cause another problem, and that I am stupid for using it seeing as multiple people need to explain it even though two people already didi before I answered, it's enough guys, I understand. The only thing I don't understand is the problem mentioned at the top of this reply.
 

samspade

Member
Okay, so for everyone: I start my game, spr_spr1 is drawn. My player takes damage, spr_spr2 should be draw, but it doesn't, instead the game crashed saying that spr_spr2 doesnt exist. This is my problem, looks like I did not explain this clearly at all.
Nothing in the code you posted seems likely to cause your problem unless sprite_delete has some additional issues consequences. You could test that by simply removing the line. Otherwise, the problem is elsewhere.

Have you put

Code:
sprite_delete(spr_sprite2);
anywhere else in the code?
 
M

Marten

Guest
Nothing in the code you posted seems likely to cause your problem unless sprite_delete has some additional issues consequences. You could test that by simply removing the line. Otherwise, the problem is elsewhere.

Have you put

Code:
sprite_delete(spr_sprite2);
anywhere else in the code?
Turns out the line was in an object I used to test with, which I forgot to remove, thanks for the help!
 

Smiechu

Member
To make it more clear I understand that deleting the sprite will eventually cause another problem, and that I am stupid for using it seeing as multiple people need to explain it even though two people already didi before I answered, it's enough guys, I understand. The only thing I don't understand is the problem mentioned at the top of this reply.
If you erase the line with sprite delete... is everything OK??
 

TsukaYuriko

☄️
Forum Staff
Moderator
Okay, whoa there. Timeout. o_O

Let's take a look at what happened here... I'd normally put this in a PM, but it seems more suitable to post here because multiple people were dragged into this.

Yeah, sounds very cool and all the way you explain it, yet you completaly miss what I originally asked.
Besides, you did not even read my whole post, or you forgot completely what I asked, so I'll repeat myself yet again: "I've got a quick question; what does gamemaker define as exist?". All you did was go on about something Paskaler already said, but in a nice way.
Yup, I did actually miss the part about it being the second sprite that's causing issues rather than the first - but nonetheless, I, much like others, tried my best to help out a fellow member, and while I apologize that I was unable to provide a solution for your problem, I don't have the slightest clue how it could have prompted you to respond in such a rash and completely uncalled for manner. Neither me nor anyone else in this topic can perceive any part of my reply as rude.

While I may have missed the original question with my reply, I didn't miss out on what's most likely incorrect usage of a function. This may or may not cause problems further down the road - no way for me to know, as I don't have access to the complete project and possess no knowledge regarding how the sprites in question are used elsewhere), but I proceeded to try to clarify what it does because it was the next best thing I could do. (As it turns out, the problem was in fact of a similar nature, so I'd say my guess wasn't too far off.)

My reply tackled the issue from a technical standpoint instead of from a programming language-oriented standpoint, so I'm not sure how it was identical to the previous one - and even if it was, I couldn't see anything wrong with that, nor with any other reply in this topic that tried to help and may or may not have repeated previous posts partially or fully. Having a second opinion never hurts.

Yet again, and this is the third time it happened, I am seen as a stupid person (or so you make it sound) because I think something works in a certain way.
I don't see anything remotely hinting at this in my previous reply, which could be summarized as a guess as to what might be wrong - which, for the record, was not clearly visible in the opening post due to the offending bit of code not being included in it, so the only choice we had at this point was to guess.

You're the only one calling yourself a stupid person, or anything similar to it. I see a far more glaring issue with the way you're responding to people than with your way of thinking how things work. Nobody was ever attacking you in this regard, so I'm not sure why you're getting so defensive about it.

It is only natural for someone who is posting in a programming help forum to receive replies resembling explanations of how things work or how they don't work, and it's also natural that not everyone who tries to help will be successful at doing so.

Please try to keep this in mind for the future - we may miss things in your code just as much as you may miss to post the relevant code in the first place. Nobody was lashing out at you for that, either - up until just now, and only for the sake of demonstration.

I'd have understood your dissatisfaction if my first post roughly consisted of the meaning and wording of "You didn't even post all relevant code because there's no way the code you showed can produce that error, how are we supposed to help you?" - as that would actually be rude.

I am going to repeat myself once again: You do not know how long I have been using Gamemaker, nor how much I know of computers.
... and I never claimed otherwise, nor does it matter to anyone involved. Whether someone is a hobbyist who just started using GameMaker, a freelancer, a member of an indie game studio or a professional software developer, on the GMC, we're nothing more and nothing less than members who help each other with their programming problems - and each and every one of us is welcome to do so in every topic, as defined by the guidelines.

Not sure who you're repeating any of this to as I am unaware of the context due to not having been involved in any of it, and therefore should not be drawn into it. Please don't take out your accumulated frustration on people who are trying to help you, that's rude and against this community's spirit.

If you commonly get into situations like this around here, I would say there might be a mismatch between the replies you are receiving and how you are interpreting them, as this topic and, apparently, other topics, have demonstrated multiple times by now.

This rudeness doesn't help anyone, yet people like to be this way.
This seems like a classic example for why people who live in glass houses shouldn't throw stones.

Accusing people of being rude to you when they're trying to help you doesn't help anyone, either. It just makes them not want to help you again in the future.

Explaining what a sprite is and what it isn't, on the other side, may or may not be helpful, but definitely is intended to be helpful, which is an intrinsically well-meant act and therefore should not be responded to with hostility under any circumstances.

Allow me to quote the guidelines of this forum to better illustrate what I mean:
Programming Forum Guidelines said:
(from https://forum.yoyogames.com/index.php?threads/programming-forum-guidelines.27723/)
Be grateful to every member who took the time to respond.

Even if someone's response doesn't solve your problem, thank them, for they at least took time to reply and tried to help. It is common courtesy.

Oh, and by the way, I did not remove the sprite I was trying to call in, take a better look at the code of people you're trying to be mean to, thanks.
Why would I be spending my spare time on a programming help forum if my intention was to be mean to people who are requesting help? What kind of person do you think I am? :p

Seriously now, that's just ridiculous. On top of the irony of outright antagonizing someone who tried to help you, I beg your pardon, but... re-reading your post, wouldn't you agree that you are the one being undeniably and unnecessarily rude to multiple people out of every participant of this topic?


Please try to work on your manners a bit. Appreciate the effort that goes into reading a topic, trying to analyze the issue and composing a reply. It's rather disheartening to go through all of this to simply be discarded as "rude" when we all have the best intentions. Once that's done, you won't run into these types of situations anymore, these discussions will become entirely unnecessary and we can all go back to doing what this community is about and what we've been doing all the time so far - trying to help each other...
 
Top