Created
September 26, 2019 02:18
-
-
Save ericoporto/cbe5e8b2f3444fe9371a4b24d640d925 to your computer and use it in GitHub Desktop.
CoolAnimate for Adventure Game Studio, Animate from any frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// new module header | |
import void CoolAnimate(this Character*, int view, int loop, int frame, int delay, BlockingStyle blockStyle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use a Base64 decoder like this to get the below text as a zip file containing the module