undefined method `pause' for #<Ruby2D::Sound:0x000002728db4b250 @path="musics/machinegun.mp3", @data=#<Object:0x000002728db4b1d8>> (NoMethodError)
pause
or stop
etc is a built-in method in ruby2d but I can not seem to make this work. I think that a specific part of ruby2d method might ran into an error because the play
method, which is in the same category, still works fine but not the other aforementioned functions.
assault_rifle = Sound.new('musics/machinegun.mp3')
on :key_held do |event|
if event.key == 'k'
mainscreen.player_fire_bullet
assault_rifle.play # this works!
end
if event.key == 'l'
assault_rifle.pause # this is just to test my theory that the method is broken
end
end
on :key_up do |event|
if event.key == 'k'
assault_rifle.stop #method error here?
end
end
For more information regarding ruby2d 's audio, you can read it here: https://www.ruby2d.com/learn/audio/ I hope some one could look into this