diff options
| author | Tom Black <[email protected]> | 2017-05-19 20:58:44 -0400 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2017-05-20 21:17:49 -0400 |
| commit | 6ab1ad93c6ae1704fee0adb77dbcf8c721913a73 (patch) | |
| tree | b7e428b3885ae249b73d23c99399d4c5d4208ae4 /lib | |
| parent | f69598768e9a3002d9e7c2acbed109016fac6ae9 (diff) | |
| download | ruby2d-6ab1ad93c6ae1704fee0adb77dbcf8c721913a73.tar.gz ruby2d-6ab1ad93c6ae1704fee0adb77dbcf8c721913a73.zip | |
Call extensions explicitly
No more are extension methods magically added to Ruby classes. Now, classes must explicitly call web and native extensions using methods with the naming convention `ext_<class>_<method>`.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ruby2d/image.rb | 2 | ||||
| -rw-r--r-- | lib/ruby2d/music.rb | 21 | ||||
| -rw-r--r-- | lib/ruby2d/sound.rb | 6 | ||||
| -rw-r--r-- | lib/ruby2d/sprite.rb | 2 | ||||
| -rw-r--r-- | lib/ruby2d/text.rb | 2 | ||||
| -rw-r--r-- | lib/ruby2d/window.rb | 8 |
6 files changed, 36 insertions, 5 deletions
diff --git a/lib/ruby2d/image.rb b/lib/ruby2d/image.rb index 91bb3f3..89c447b 100644 --- a/lib/ruby2d/image.rb +++ b/lib/ruby2d/image.rb @@ -19,7 +19,7 @@ module Ruby2D @x, @y, @path = x, y, path @z = z @color = Color.new([1, 1, 1, 1]) - init(path) + ext_image_init(path) add end diff --git a/lib/ruby2d/music.rb b/lib/ruby2d/music.rb index e0fdf11..bd7df45 100644 --- a/lib/ruby2d/music.rb +++ b/lib/ruby2d/music.rb @@ -14,10 +14,29 @@ module Ruby2D end end - init(path) @path = path @loop = false + ext_music_init(path) end + def play + ext_music_play + end + + def pause + ext_music_pause + end + + def resume + ext_music_resume + end + + def stop + ext_music_stop + end + + def fadeout(ms) + ext_music_fadeout(ms) + end end end diff --git a/lib/ruby2d/sound.rb b/lib/ruby2d/sound.rb index 4e0c385..776d718 100644 --- a/lib/ruby2d/sound.rb +++ b/lib/ruby2d/sound.rb @@ -14,8 +14,12 @@ module Ruby2D end end - init(path) @path = path + ext_sound_init(path) + end + + def play + ext_sound_play end end diff --git a/lib/ruby2d/sprite.rb b/lib/ruby2d/sprite.rb index 93f4f58..4d6ac23 100644 --- a/lib/ruby2d/sprite.rb +++ b/lib/ruby2d/sprite.rb @@ -22,7 +22,7 @@ module Ruby2D @current_frame_time = 0 @z = z - init(path) + ext_sprite_init(path) if Module.const_defined? :DSL Application.add(self) end diff --git a/lib/ruby2d/text.rb b/lib/ruby2d/text.rb index e326029..022f79c 100644 --- a/lib/ruby2d/text.rb +++ b/lib/ruby2d/text.rb @@ -20,7 +20,7 @@ module Ruby2D @z = z @text = text.to_s self.color = c - init + ext_text_init add end diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb index b8d8a2f..837b55a 100644 --- a/lib/ruby2d/window.rb +++ b/lib/ruby2d/window.rb @@ -224,6 +224,14 @@ module Ruby2D @update_proc.call end + def show + ext_window_show + end + + def close + ext_window_close + end + private def add_object(o) |
