Skip to content

Instantly share code, notes, and snippets.

@alexey-dc
alexey-dc / MSMOAI Button
Created April 17, 2013 22:01
Button API
-- Production usage
local anyKindOfProp = Group.new()
local clickHandler = function(button) print("Hello", button) end
local buttonFromProp = Button.new(anyKindOfProp, clickHandler)
-- Helper functionality
local path = "assets/button.png"
local buttonWithBG = Button.createWithBackground(path, clickHandler)
buttonWithBG:setText("Click ME!")
@alexey-dc
alexey-dc / AHUSound
Last active December 15, 2015 19:49
Sound API
-- cached, sound played based on the name for the sound effect, rather than the file name
SoundManager.map("dropped_bass", "dropped_bass.ogg")
SoundManager.map("explosion", "explosion.ogg")
SoundManager.preload("dropped_bass")
-- Assume a script that does mapping and preloading for each game (based on a data file)
-- volume is in [0, 1], pitch is in [0, inf)
SoundManager.playSound("explosion", volume, pitch) -- Sounds that aren't preloaded are loaded automatically, does not loop