After reading your post, I think I can offer some help. I am new to ROKU development so I am currently working on my first application. Having mostly built it using the standard components and then rewriting a portion of it using imageCanvas, I decided to rewrite it entirely using the 2d api. As you know, this is not well documented and you basically have to discover it for yourself. Anyway lets start with the easing functions:
The time and duration values in the easing functions should not be taken literally as time of day but rather length or duration. This is more easily expressed as frames
for our purpose. It does not matter what you use (time or frames), but it must be the same 'type' for each parameter of the easing equation. I use frames; increasing the number of frames increases the duration or time it takes to ease from one point to another; and obviously the opposite is true as well. In the following code I am
moving in the x direction form x = 100 to x = 800 and I want to have a duration or time of 30 frames. To go back you simply negate newX. Just change the y direction
the same way if you are moving in the y direction. If you use are using offsets such as you would to move a region, then just subtract the difference from the previous
newX ( you would have to save the value of course)
' In this example we are moving the x position it would be the same for y you just move in the y direction instead of x
curr_time = 0 ' START TIME OR FRAME IS USUALLY 0 OR 1 DEPENDING ON YOUR FLAVOR
start_val = 100 ' START X OR Y POSITION DEPNDING ON MOVEMENT DIRECTION (CURRENT X POS OF YOUR SPRITE)
change_val = 800 ' WHERE WE ARE MOVING TO FROM START_VAL THIS WOULD BE X OR Y AS MENTIONED IN PREV LINE
duration = 30 ' HOW LONG SHOULD IT TAKE TO EASE THERE. To go back just use a negative ( -newX)
for i = 0 to duration
newX = CubeEaseOut(curr_time + i, start_val, change_val, duration)
end for
]Function CubeEaseOut(t_from_frame As Float, d_to_frame As Float, b_from_xory As Float, c_to_xory As Float) As Integer
l_ff! = t_from_frame / d_to_frame
l_ff! = l_ff! - 1.0
l_val! = c_to_xory *(l_ff! * l_ff! * l_ff! + 1.0) + b_from_xory
l_ret% = int(l_val!)
return l_ret%
End Function
As you can see I have changed the names to better reflect what we are trying to do: we are going to ease horizontally or vertically: from xory (b_from_xory) to xory
( c_to_xory ) , and we want the duration to be from frame (t_from_frame) to (d_to_frame). So for 20 frames it would be for i = 1 to 20.
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )