Scrupp 0.1 Manual
Create your own 2D games and applications

The music support is implemented using SDL_mixer.

Scrupp supports only one music file playing at a time. Because of that there is only one method for a music object: play. All the other music manipulating functions are independant from a special music object. They change whatever music file is playing at the moment.

Loading

game.addMusic(filename)
Loads a music file with the given filename. This can load WAV, MOD, MIDI, OGG and MP3. Returns a music object.
Note: Only MP3 files with id3v1 tag are supported. If you try to load a file with id3v2 tag, the error message will say: Module format not recognized. To strip a possible id3v2 tag you can use the command id3convert from the id3lib:
id3convert -s -2 <mp3 file>

Methods

music:play([loops=0], [fade_in_time=0])
Plays a music file loaded with game.addMusic(). The optional parameter loops defines the number of times the music will be played. 0 means inifite looping and is the default. The optional parameter fade_in_time defines the number of milliseconds the music will fade in, the default is 0 ms.

Functions

game.setMusicVolume(volume)
Sets the music volume to the specified value between 0 (mute) and 128 (maximum volume).
game.getMusicVolume()
Returns the current music volume. This value is between 0 (mute) and 128 (maximum volume).
game.pauseMusic()
Pauses the music playback. Paused music may be stopped with game.stopMusic().
game.resumeMusic()
Unpauses the music. This is safe to use on stopped, paused and playing music.
game.stopMusic([fade_out_time=0])
Stop the playback of music. The optional paramter fade_out_time gives the number of milliseconds the music will fade out. It defaults to 0 ms.
game.rewindMusic()
Rewinds the music to the start. This is safe to use on stopped, paused and playing music. This function only works for these streams: MOD, OGG, MP3, Native MIDI.
game.isMusicPlaying()
Tells you if music is actively playing, or not.
Note: Does not check if the music has been paused, i.e. paused music returns true. Only stopped music returns false.
game.isMusicPaused()
Tells you if music is paused, or not.
Note: This state is only influenced by calls to game.pauseMusic() and game.resumeMusic().

Example

game.init("Music Test", 600, 400, 32, false)

-- load some music
music = game.addMusic(<music file>)
-- start music
music:play()

main = {
	-- empty render function
	render = function(dt)
	end
}

Hosted by
SourceForge.net Logo

Valid XHTML 1.0!

Last modified Sat Feb 28, 2009