Javis.jl
Javis.jl copied to clipboard
Specify frames for actions relative to actions from different objects
Is your feature request related to a problem? Please explain.
When a new action is created and the frames are specified using RFrames it is always relative to the frames of the previous action within the same object. This makes sense since internally the frame ranges for actions are stored relative to the object they are being applied to. But occasionally, one might feel the need to specify these frames relative to a recently added action from another object.
Consider the following example, when we need to know the current active frame to specify a new action
obj1 = Object(1:100, (args...)->draw(), Point(20, 20))
act!(obj1, Action(1:15, appear(:fade)))
obj2 = Object(50:100, (args...)->draw(), Point(100, 100))
act!(obj2, Action(1:15, appear(:fade)))
.
. # Add a bunch of actions on obj1
.
act!(obj1, Action(RFrames(1:12), disappear(:fade)))
# And now we need to disappear obj2 just after obj1 disappears
This is difficult since the global frame numbers are not known anymore.
Describe the solution you'd like
PR #338 solves some problems around relative ordering of frames much more than what RFrame offers but this problem still stays unsolved. Having a function like prev_action_end which can be later used as
Action(@Frames(prev_action_end()+5, len=20))
would serve the purpose. The is challenging since the way the rendering function is executed, which calculates frames for every action of an object before moving to a new object.
Describe alternatives you've considered
It might be possible to have a function like prev_action_end(a) which takes in a reference to an action and calculates frames relative to it.
function prev_action_end(a)
return a.frames.frames[end] + PREVIOUS_OBJECT[1].frames.frames[1] - 1
end
However it is not a good solution.
Additional context Add any other context or screenshots about the feature request here.
How about letting act! return the global frames and have a @GFrames macro. I would also not call it something with prev_ when an object or action is defined specifically