Skip to content

Commit

Permalink
handle ranges of events
Browse files Browse the repository at this point in the history
  • Loading branch information
flyover committed Dec 18, 2015
1 parent 006a74a commit ad29605
Showing 1 changed file with 56 additions and 19 deletions.
75 changes: 56 additions & 19 deletions spine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3358,33 +3358,70 @@ spine.Pose.prototype.strike = function ()
pose.events.push(pose_event);
}

if (wrapped_min)
if (elapsed_time < 0)
{
var keyframe_index = spine.Keyframe.find(anim.event_keyframes, anim.min_time);
if (keyframe_index !== -1)
if (wrapped_min)
{
var event_keyframe = anim.event_keyframes[keyframe_index];
add_event(event_keyframe);
// min prev_time time max
// | | | |
// ----------x o<---------
// all events between min_time and prev_time, not including prev_time
// all events between max_time and time
anim.event_keyframes.forEach(function (event_keyframe)
{
if (((anim.min_time <= event_keyframe.time) && (event_keyframe.time < prev_time)) ||
((time <= event_keyframe.time) && (event_keyframe.time <= anim.max_time)))
{
add_event(event_keyframe);
}
});
}
}
else if (wrapped_max)
{
var keyframe_index = spine.Keyframe.find(anim.event_keyframes, anim.max_time);
if (keyframe_index !== -1)
else
{
var event_keyframe = anim.event_keyframes[keyframe_index];
add_event(event_keyframe);
// min time prev_time max
// | | | |
// o<---------------x
// all events between time and prev_time, not including prev_time
anim.event_keyframes.forEach(function (event_keyframe)
{
if ((time <= event_keyframe.time) && (event_keyframe.time < prev_time))
{
add_event(event_keyframe);
}
});
}
}

var keyframe_index = spine.Keyframe.find(anim.event_keyframes, time);
if (keyframe_index !== -1)
else
{
var event_keyframe = anim.event_keyframes[keyframe_index];
if (((elapsed_time < 0) && ((time <= event_keyframe.time) && (event_keyframe.time <= prev_time))) ||
((elapsed_time > 0) && ((prev_time <= event_keyframe.time) && (event_keyframe.time <= time))))
if (wrapped_max)
{
add_event(event_keyframe);
// min time prev_time max
// | | | |
// --------->o x----------
// all events between prev_time and max_time, not including prev_time
// all events between min_time and time
anim.event_keyframes.forEach(function (event_keyframe)
{
if (((anim.min_time <= event_keyframe.time) && (event_keyframe.time <= time)) ||
((prev_time < event_keyframe.time) && (event_keyframe.time <= anim.max_time)))
{
add_event(event_keyframe);
}
});
}
else
{
// min prev_time time max
// | | | |
// x--------------->o
// all events between prev_time and time, not including prev_time
anim.event_keyframes.forEach(function (event_keyframe)
{
if ((prev_time < event_keyframe.time) && (event_keyframe.time <= time))
{
add_event(event_keyframe);
}
});
}
}
}
Expand Down

0 comments on commit ad29605

Please sign in to comment.