SOLVED Sprite is not being destroyed

cabsob

Member
Whenever I hit the esc key, my sprite is not destroyed (the instance_destroy() does work though). No clue why. I know it's not because I destroy the object that is running the same command to destroy the sprite, since removing instance_destroy() still does not destroy the sprite. I've tried using things like layer_get_sprite_id and stuff like that thinking it doesn't recognize the name, but all to no avail. What am I missing? Thanks. View attachment 37568View attachment 37569
 

curato

Member
I think the issue is your are using the sprite name from your resource tab and not the assest ID from instance_sprite_create
 

TsukaYuriko

☄️
Forum Staff
Moderator
Hi! It seems like you've found a solution to your topic and subsequently removed the contents of this topic. Please note that this is explicitly against the forum rules, as other members could benefit from this topic and the suggestions/solutions that have been provided in it. Sabotaging topics like this thus makes the topic very self-centered and something only you profit from, which is something we generally don't want to be how the community operates.

I've restored the contents of your post and gave the topic a title I felt was fitting (as I don't have access to the edit history for topic titles). You may change the title to something more relevant if you wish to do so. In the future, please don't sabotage topics once they've been resolved anymore.
 

cabsob

Member
Hi! It seems like you've found a solution to your topic and subsequently removed the contents of this topic. Please note that this is explicitly against the forum rules, as other members could benefit from this topic and the suggestions/solutions that have been provided in it. Sabotaging topics like this thus makes the topic very self-centered and something only you profit from, which is something we generally don't want to be how the community operates.

I've restored the contents of your post and gave the topic a title I felt was fitting (as I don't have access to the edit history for topic titles). You may change the title to something more relevant if you wish to do so. In the future, please don't sabotage topics once they've been resolved anymore.
Hi Tsuka,
I totally agree with that rule and glad you guys have it (though I did not know if it until now). The reason I wanted to remove my post is that I found the solution to my problem on my own and would feel bad wasting anyone's time answering a problem I didn't have. The one person who did respond made their response after I sabotaged my topic somehow, so it wasn't like I was trying to keep his/her answer to myself. I now have no reason to try any solutions posted here, and therefore cannot confirm if they worked for me or not, so this problem will never actually be solved so that it may help future forum members. I suppose the right thing to do would've been to post the solution I came to, though it is more of a workaround rather than solving this exact problem (if this post still exists, I'll post my solution later tonight so that this thread has an answer). I still think this is a great rule to enforce in most cases and thanks for moderating.
 

curato

Member
I did see the attachment when I responded. But it is always good form if you find the answer to post the answer you found so that it might also help someone else down the line.
 

cabsob

Member
I did see the attachment when I responded. But it is always good form if you find the answer to post the answer you found so that it might also help someone else down the line.
Yea you're right. Thanks for responding earlier too btw. For future reference, how would I get the sprite asset ID (I'm pretty new to GML)? And my solution was to use draw_sprite instead of what I was doing, which works for my case as it will stop being drawn with the object being destroyed like I wanted to.
 
I think you're confusing yourself a little. You don't ever need to "destroy" a sprite. A sprite is something that is almost always drawn by an instance of an object (learn the difference between instances and objects). If you want a sprite to be drawn, you can either assign that sprite to an object and place an instance of that object in the room, or you can manually draw a sprite in the Draw Event of an object (and then place an instance of that object in the room). If you want the sprite to stop being drawn, you'll need to do something to the instance that is doing the drawing, not the sprite itself (which is only really an asset in so far as it's a pointer to a place on the texture page, it doesn't "exist" in the game the same way as an instance does). You can use a boolean variable and only draw the sprite if the boolean is true, you can simply destroy the instance itself, you can set visible = false in the instance. etc. There's many different ways of determining whether something is drawn or not, but which one you choose depends on why you want the sprite to be drawn or not drawn.
 
Top