Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Trying to delete an animated sprite

Author
Message
roswell1329
9
Years of Service
User Offline
Joined: 12th Apr 2010
Location:
Posted: 6th Sep 2014 04:28
I have an explosion sprite that I'd like to clear from the screen when the animation is completed, but for some reason, the last frame of the animation sticks around on the screen until the sprite is triggered again. I would think the delete sprite command is what I should use, but it doesn't seem to have any effect (image attached):



Any ideas?

Attachments

Login to view attachments
WickedX
10
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 6th Sep 2014 05:10
Try using an animated sprite with a new frame added to the image. New image attached.

Code:


Attachments

Login to view attachments
roswell1329
9
Years of Service
User Offline
Joined: 12th Apr 2010
Location:
Posted: 6th Sep 2014 05:32
Ah, of course. Just using the new image you created with my own code works just fine. I thought of this, but then wondered why there would be a delete sprite command if it didn't work, so I assumed I was using it wrong. Do you happen to know why the sprite stays on the screen even after the delete sprite command is used?
WickedX
10
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 6th Sep 2014 05:47 Edited at: 6th Sep 2014 07:53
I know, I just don't know how well I can explain. Basically there are synchronous functions and asynchronous functions. Inside your mouse click condition you are mixing the two. This is the main reason I suggested using the animated sprite functions. Hope that makes sense.

roswell1329
9
Years of Service
User Offline
Joined: 12th Apr 2010
Location:
Posted: 6th Sep 2014 06:54
I think I understand the difference between asynchronous and synchronous. If I'm not mistaken, synchronous code is code that has to complete before the code moves on whereas asynchronous code can be triggered to run while the main program continues to work. Is that correct?

In the case of my code, I'm guessing the WAIT and SYNC commands are the synchronous commands, and everything else would have been asynchronous. Is that right? Just want to make sure I follow.

I see in your code that you prepare the sprite to be used for that loop and then sync everything at once. Not sure if that would be considered asynchronous or synchronous since it could really run either way.
WickedX
10
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 6th Sep 2014 07:33 Edited at: 6th Sep 2014 08:06
Synchronous in this case means everything is synced simultaneously by the sync function call. The sync function seems pretty simple going by the help file. But as I have said before. I could write a 500 page book on the subject, if I had incentive to do so. When running a program with sync turned on, unless you’re using a camera shader technique or something you should only need to sync once. Since you are calling sync inside a condition check, if your program requires additional functionality you will need to call sync every time you want to display something. Basically defeating the purpose of turning sync on. The next problem is the wait function. This is not meant to be used while running your program synchronously. Such things as these will kill your frame rate. Seem a lot of users have problems with this, some functions should be used with sync on and some not. There may be times when you may want to use a function like - input. Input is a asynchronous function. So, if you’re running with sync on the program will wait for the user to type a response. This response will not display until after the user hits enter. This would be undesirable but, before calling input you can turn sync off then after the user has type the response turn it on again. This is the reason for the sync off as well as sync on. Notice in my code, I turned the backdrop on removing the need for CLS.

roswell1329
9
Years of Service
User Offline
Joined: 12th Apr 2010
Location:
Posted: 6th Sep 2014 07:35
Excellent explanation, and good advice. Thank you very much for the detailed reply!
WickedX
10
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 6th Sep 2014 07:45
My pleasure.

Login to post a reply

Server time is: 2020-01-23 02:10:54
Your offset time is: 2020-01-23 02:10:54