diff options
| author | Amir Rajan <[email protected]> | 2020-07-30 16:45:24 -0500 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2020-07-30 16:58:40 -0500 |
| commit | eb8b770e1952af371832f5f31e00dae09d498cf9 (patch) | |
| tree | 0884e11fedbfa01c7ce9f1e028cb6c43a13d2052 /docs/search_results.txt | |
| parent | 8d000345a3489988e9e86ee9fda9dcc6c70b7012 (diff) | |
| download | dragonruby-game-toolkit-contrib-eb8b770e1952af371832f5f31e00dae09d498cf9.tar.gz dragonruby-game-toolkit-contrib-eb8b770e1952af371832f5f31e00dae09d498cf9.zip | |
OSS synced with 1.12.
Diffstat (limited to 'docs/search_results.txt')
| -rw-r--r-- | docs/search_results.txt | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/docs/search_results.txt b/docs/search_results.txt new file mode 100644 index 0000000..b4c5e12 --- /dev/null +++ b/docs/search_results.txt @@ -0,0 +1,63 @@ +* DOCS: ~Numeric#frame_index~ + +This function is helpful for determining the index of frame-by-frame + sprite animation. The numeric value ~self~ represents the moment the + animation started. + +~frame_index~ takes three additional parameters: + +- How many frames exist in the sprite animation. +- How long to hold each animation for. +- Whether the animation should repeat. + +~frame_index~ will return ~nil~ if the time for the animation is out +of bounds of the parameter specification. + +Example using variables: + +#+begin_src ruby + def tick args + start_looping_at = 0 + number_of_sprites = 6 + number_of_frames_to_show_each_sprite = 4 + does_sprite_loop = true + + sprite_index = + start_looping_at.frame_index number_of_sprites, + number_of_frames_to_show_each_sprite, + does_sprite_loop + + sprite_index ||= 0 + + args.outputs.sprites << [ + 640 - 50, + 360 - 50, + 100, + 100, + "sprites/dragon-#{sprite_index}.png" + ] + end +#+end_src + +Example using named parameters: + +#+begin_src ruby + start_looping_at = 0 + + sprite_index = + start_looping_at.frame_index count: 6, + hold_for: 4, + repeat: true + + sprite_index ||= 0 + + args.outputs.sprites << [ + 640 - 50, + 360 - 50, + 100, + 100, + "sprites/dragon-#{sprite_index}.png" + ] +#+end_src + + |
