Download

Querying framedata efficiently

I’m working on a third-person brawler, which means that my design needs to reflect my need to easily edit which frames individual animations can transition into and out of other animations. An extremely polished version of this functionality was showcased in Aztez’s editor recently: http://aztez.com/wp-content/uploads/2014/09/MoveFrameDataSWORDSTANDINGA1.gif

In essence, every single animation in my game, including the basic walk cycle, has an associated Move class which encapsulates information on when in the animation each event can fire. It has a boatload of variables like startHitboxActive, endHitboxActive, startCanDodge, endCanDodge, and so forth, each with an int value between 0 and the number of frames in the animation. Right now, this is best pseudocode I’ve come up with to actually use the data to constrain animation transitions:

GetKeyJump(Move currentMove){ //Runs every time the jump key is pressed

if(currentMove.frame >= currentMove.startCanJump && currentMove.frame <= currentMove.endCanJump){
//code adding vertical velocity and triggering the jump animation
}

}

This works well for things anchored exclusively to input, but I’m having a lot of trouble conceptualizing how to make this work efficiently for things that need to be toggled automatically, like enabling and disabling hitboxes. One option would be to put something in my main input class’s Tick() that checks currentMove.enableHitbox and currentMove.disableHitbox, but that sounds like an absolutely massive waste of resources on a check that will only return true a fraction of the time. Is there any way to keep durational toggles like this event-oriented?