Skip to content

Instantly share code, notes, and snippets.

@jakejscott
Created July 19, 2011 16:07
Show Gist options
  • Save jakejscott/1092912 to your computer and use it in GitHub Desktop.
Save jakejscott/1092912 to your computer and use it in GitHub Desktop.
Nom nom iPhone app written in Corona SDK
local _H = display.contentHeight;
local _W = display.contentWidth;
local monster = display.newText("a", 0, 0, "Monsterz", 120);
monster.x = _W * 0.5; monster.y = _H * 0.5;
local hello = display.newText("Tap me, I'z hungree", 0, 0, "BorisBlackBloxx", 24);
hello.x = _W * 0.5; hello.y = (_H * 0.5) + 80;
local nom = display.newText("Nom nom", 0, 0, "BorisBlackBloxx", 12);
nom.x = monster.x + 60; nom.y = monster.y;
nom.rotation = -15;
nom.isVisible = false;
local nomsound = audio.loadSound("nom.aiff");
local chomp = { "a", "A", "S", "S", "T", "T", "T", "S", "A", "a" };
function monster:touch(e)
if (e.phase == "ended" or e.phase == "cancelled") then
local function nomnom(e)
if (e.count == 1) then
nom.isVisible = true;
audio.play(nomsound);
end
self.text = chomp[e.count % #chomp + 1];
if (e.count == #chomp) then
nom.isVisible = false;
timer.cancel(self.timer);
self.timer = nil;
end
end
monster.timer = timer.performWithDelay(30, nomnom, #chomp);
end
end
monster:addEventListener("touch", monster);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment