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.

DarkBASIC Professional Discussion / Ways to STOP an animation playing to an image?

Author
Message
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 12th Apr 2014 05:25 Edited at: 7th May 2014 20:21
Hey y'all!
I've been working on something for a while, and I was just doing the last few tests on it before this problem had to screw things up
Although you can use 'play animation to image' to stream an animation to an image, there doesn't seem to be any way to stop it streaming
To give you an idea what I'm trying to do, I'm trying to create a TV in my game which can play several different animations. There are two ways I can think of to do this: The best way, which would be to load up my 3 different animations, and when I want to swap between them, stop the one that was playing, and play another one to the same image. That'd give me something like this:


The other way (which I tried when I realized the first way wasn't working), would be to use a different image for each animation I want to play. That'd give me this:


The second way, unfortunately, isn't an option for me - Streaming an animation to an image seems to suck away a lot of frame rate per animation, and my game sure doesn't need a lower frame rate :/
The reason I can't use the first option is that any new animation played to the same image as another animation seems to overwrite the other animation (which is what I want), but after that, I can't switch back to the old animation (which isn't what I want). For some reason, using 'play animation to image' only works once on an image - after that, if I overwrite the image with a different animation, I can't get the old animation back!
Sorry, that's probably pretty confusing... This is how it works:
I play animation 1 to image 1 - TV screen is now playing animation 1
I then play animation 2 to image 1 - TV screen is now playing animation 2
I play animation 1 to image 1 again, to swap back > TV screen still shows animation 2
I play animation 3 to image 1 > TV screen is now playing 3
After that, neither animation 1 or 2 can be shown again!

It's also worth nothing that this method gives exactly the same FPS drop as the the second method, because the other animations are apparently still streaming.
I had an idea to fix the problem, which was to delete and reload an animation every time I wanted to stop streaming it - annoying, but I thought it might work. Turns out that just causes the program to crash with a windows error (Program has stopped working...)
So as far as I can see, using 'play animation to image', which is the only way I know to get an animation to an image, is a one-way ticket :/
Sorry for the long post people, I just wanted to give you plenty of detail
Thanks for any help

The code never bothered me anyway...
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 12th Apr 2014 05:46
This is probably way too obvious to be of any help, but just for the heck of it, you're saying stop animation doesn't stop the animation from streaming?
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 12th Apr 2014 06:06 Edited at: 7th May 2014 20:22
Nope, sorry
Using 'stop animation' stops the animation from playing, but not streaming to the image. If you play an animation to an image then stop the animation, the image just shows the first frame of the stopped animation.

The code never bothered me anyway...
WickedX
17
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 12th Apr 2014 06:48
Try "stop animation" then delete the image before you "play animation to image" with a new animation number.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Apr 2014 13:31
That doesn't seem to work either.

Looks like a DBPro bug to me.



Powered by Free Banners
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Apr 2014 14:55
Quote: "
I play animation 1 to image 1 - TV screen is now playing animation 1
I then play animation 2 to image 1 - TV screen is now playing animation 2
"


Hadn't we better to :

play animation 1 to image 1...
play animation 2 to image 2...
then texture object 1,image 1...or image 2

This example works...




Every time we press a or s, animation reset to frame 1

Cheers.

I'm not a grumpy grandpa
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Apr 2014 17:11
Yes, he's already considered that - but he thinks the animations are still playing to the image you're not using, i.e. a performance hit I guess.



Powered by Free Banners
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 12th Apr 2014 19:16 Edited at: 7th May 2014 20:22
Thanks for the suggestions!
Yeah, the performance hit is the main problem with the second method (and the first actually) for me :/
I played around with a few test programs to try to solve this one. Every time I used 'play animation to image' on a new animation, the frame rate pretty much halved :/
I had one more idea I might try this evening, which is maybe trying to use 'place animation' or something similar to play an animation to a different bitmap, then using 'get image' to manually stream to an image. Not sure how practical it really is, but worth a try...

The code never bothered me anyway...
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 13th Apr 2014 01:31 Edited at: 7th May 2014 20:22
Well, just played around with it, and it was a 100%, total... failure -.-
Both the 'play animation' and 'loop animation' commands have extra parameters which are supposed to allow you to specify a bitmap to draw the animation to, but that apparently does nothing, since they'll draw to bitmap 0 whatever you put :/
Even if they did, it'd still be useless, because calling 'get image' once per loop is enough to slow a program with nothing except a spinning plain object down to 20 fps.
I'm really hoping someone else has an idea what to do, because I've hit a solid dead end with this one

The code never bothered me anyway...
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 13th Apr 2014 07:53 Edited at: 13th Apr 2014 07:57
It's a shame you can't specify which frames of animation to play and put them all into one file.. The only thing I see that's even close are the DVD commands which of course would be ridiculous in this scenario.

I do have another idea, what if you used the get image command and chopped your animation frames up on a sprite sheet?
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 13th Apr 2014 23:34 Edited at: 7th May 2014 20:21
Thanks for the idea
If nothing else works, I might have to try that... Hopefully not, because it'll be as annoying as hell to do, but it could work

The code never bothered me anyway...
Barry Pythagoras
12
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 14th Apr 2014 02:22
If you are really desperate for speed convert the graphics to 256 colours. Use an adaptive palette. It is not so bad as it sounds, you get nice Retro colours.
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 7th May 2014 20:16 Edited at: 7th May 2014 20:25
Just thought I'd let you guys know, I finally cracked it
After trying about 5 different workarounds, including making my own animation format which averaged 500 Mb for a 5 second low-res animation, I was pretty sure it was going to crack me, but it turns out you can stop an animation playing to an image if you do it the right way. Contrary to what I thought before, you can delete an animation after setting it to play to an image without crashing the program, and it completely stops the FPS drop caused by streaming the animation to the image - that's the only way I can find of stopping an animation playing to an image.
The problem comes if you try to load another animation (or the same one) with the same number as the deleted animation. Apparently, although the animation is deleted, some part of DBPro's animation handing system remembers that the animation was playing to an image. Consequentially, when you load another animation with the same number, you have to immediately set it playing to an image again, otherwise the program will crash when it reaches the next sync command in your code. Here's an example:

This will crash the program:


But this won't!


Of course, the downside here is that you can't do anything with that animation number again except play it to an image, but that's fine for me, since that's all I want to do with them.
Hope this helps anyone else trying to do the same thing
Having to delete an animation to stop it streaming to an image, then reload it each time you want to use again it isn't ideal, but at least it works!

The code never bothered me anyway...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th May 2014 21:22
Sounds good. Thanks for letting us know.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 07:18:00
Your offset time is: 2026-07-06 07:18:00