Skip to content

Instantly share code, notes, and snippets.

@omidahourai
Created January 5, 2013 18:25
Show Gist options
  • Save omidahourai/4462949 to your computer and use it in GitHub Desktop.
Save omidahourai/4462949 to your computer and use it in GitHub Desktop.
--Hud.lua
scene:addEventListener('onEnemyKill', Hud)
function Hud:onEnemyKill(event)
local points = self.points + 20
self.points = points
self:dispatchEvent({name='onEnemyKill', points=points}) --dispatch to Hud scope
end
--Score.lua
Hud:addEventListener('onEnemyKill', Score) --listen on Hud scope
function Score:onEnemyKill(event)
self.text = event.points
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment