Hello all!
What ideas do you guys have for starting an animation from a specific frame on, and not from the beginning?
I have some quirky or creative solutions, but if anyone else has their own way of doing it or any ideas, I'd be really curious to hear about it, if anyone ever came across that problem.
I would need to pause and play an animation very, very flexibly and very fast for what I'm trying to do, so the ideas I have so far are really sub-optimal.
So if you have any basic approaches or ideas, I'd greatly appreciate it!
I don't know if there is a coding way to do this but, if not, the obvious solution would be to create a bunch of views, each starting the animation from a different frame and then change the sprite's view to the specific one when needed.
This won't work well with really long animations of course, but for 10 or so frames should be doable.
deleted
I gave a try, not sure how well it works.
CoolAnimate.ash (https://gist.github.com/ericoporto/cbe5e8b2f3444fe9371a4b24d640d925#file-coolanimate-ash)
Spoiler
import void CoolAnimate(this Character*, int view, int loop, int frame, int delay, BlockingStyle blockStyle);
CoolAnimate.asc (https://gist.github.com/ericoporto/cbe5e8b2f3444fe9371a4b24d640d925#file-coolanimate-asc)
Spoiler
// new module script
managed struct CoolAnimateData{
bool animating;
int delay;
int count;
};
CoolAnimateData* coolData[];
void game_start(){
coolData = new CoolAnimateData[Game.CharacterCount];
for(int i=0; i<Game.CharacterCount; i++){
coolData[i] = new CoolAnimateData;
}
}
void repeatedly_execute_always(){
for(int i=0; i<Game.CharacterCount; i++){
if(coolData[i].animating){
if(coolData[i].count>coolData[i].delay){
coolData[i].count = 0;
int frame = character[i].Frame+1;
if(frame < Game.GetFrameCountForLoop(character[i].View, character[i].Loop)){
character[i].LockViewFrame(character[i].View, character[i].Loop, frame);
} else {
coolData[i].animating = false;
character[i].UnlockView(eKeepMoving);
}
} else {
coolData[i].count++;
}
}
}
}
void CoolAnimate(this Character*, int view, int loop, int frame, int delay, BlockingStyle blockStyle){
this.LockViewFrame(view, loop, frame);
coolData[this.ID].delay = delay;
coolData[this.ID].count = 0;
coolData[this.ID].animating = true;
if(blockStyle == eBlock){
int frame_count = Game.GetFrameCountForLoop(view, loop);
for (int i=0; i<frame_count; i++){
Wait(delay);
}
}
}
You use this module by just calling it in your character like
function hGlowingOrb_AnyClick() {
cEgo.CoolAnimate(VIEW1 /* view */, 2 /* loop */, 3 /* frame */, 5 /* delay */, eBlock);
}
I assumed you needed this for a character, if it's for something else, you have to figure out something else :P
Seeing that it's trivial to add in the engine but requires much hassle in script, I am considering adding this ability to the engine, to AGS 3.5.0.
I don't really like doing this, since the version is almost out, but it appeared to be possible to complete in just couple of hours (spent 1 hour discussing how it should work).
You are still my favorite wizard!!!
(Gandalf comes a close second though)
Quote from: Mandle on Thu 26/09/2019 01:54:54
I don't know if there is a coding way to do this but, if not, the obvious solution would be to create a bunch of views, each starting the animation from a different frame and then change the sprite's view to the specific one when needed.
This won't work well with really long animations of course, but for 10 or so frames should be doable.
It's a great idea, but it's not really ideal for what I try to do. Thanks for sharing though!! :)
That's dope eri0o!
Thanks for taking the time to write this.
I like the name coolanimate.
I let you know how it works after I experimented with it.
Quote from: Crimson Wizard on Thu 26/09/2019 20:30:33
Seeing that it's trivial to add in the engine but requires much hassle in script, I am considering adding this ability to the engine, to AGS 3.5.0.
I don't really like doing this, since the version is almost out, but it appeared to be possible to complete in just couple of hours (spent 1 hour discussing how it should work).
You rock, Crimson Wizard!
Wanted to mention, the 3.5.0 RC1 is posted and it has this feature now ready for testing: https://www.adventuregamestudio.co.uk/forums/index.php?topic=57133.msg636611285#msg636611285
I had this problem with a few animations too. But I did the animation separately, and its not time consuming.
Thanks I downloaded the new version.
eri0o,
I know this is super late, but I promised I would let you know how your script works.
I was just too busy to take a look, so, since I finally got to it:
It works fine, but the blocking part does not.