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 / Play Animation based on timer

Author
Message
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 23rd Jun 2010 07:48
Ok, so i want to play an animation for reloading in one of my games. i'll give you the psuedo because it's easier to explain what i'm trying to do.



so i can play the first animation and i think i know how to loop the animation until the Ammo is full, but i don't know how to wait until the first animation is done (i've never used timers before). if someone could show me a code example or tell me how i can do it would be great. thx
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 23rd Jun 2010 10:55
Here's where the "object Frame" command is useful. when an object is playing, it tells you which animation frame the object has currently reached. Also of note is "Object playing", it tells you when the object nimation has stopped.

So, say anim1 is frame 1 to 5, reload anim is frame 6 to 10.
You would use something like this in your main program loop:

Hope this helps!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 23rd Jun 2010 17:37 Edited at: 23rd Jun 2010 17:37
i tried it, and it didn't work. The problem is it's in a function and when ever i call the function, it plays that information. Let me show you:



As you can see, i even tried using the do...loop in it, but it just does an infinite loop of animation. Without the loop, it still just plays the first animation and thats it.
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 23rd Jun 2010 21:03
You could try making "mode" a global variable. Are you calling this function every loop, or just once? If you're calling it every loop, bear in mind that "mode" is being reset to 0 each time by this code:


Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 23rd Jun 2010 21:19
See but global is not gonna work. ok, so i have this function in a random source file and i call it when ever or where ever i need to play an animation for my gun. for example, when i'm not shooting, moving, or reloading, i play the idle animation using play_animation("Idle"). my question is, how can i play the starting animation for reloading, wait until its done playing, then loop my reloading animation, then when my ammo is full, play the end animation. Like i said, i've never used timers, but i'm not sure it would be useful here.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 23rd Jun 2010 22:25
that can get very complicated, I had the exact same problem as you and I have a bit of code that works for it, as soon as I get home in a few hours I'll try and post it.

Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 23rd Jun 2010 23:13
Ok, great! Sorry, i've been stuck forever on this and it's really bugging me. Thx
Derekioh
17
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 25th Jun 2010 06:11 Edited at: 25th Jun 2010 06:12
Can someone plz help me out here?

@thenerd: Were you not able to find it or are you just busy? Sorry for asking, i just really want this fixed.

Login to post a reply

Server time is: 2026-07-25 08:13:37
Your offset time is: 2026-07-25 08:13:37