alestane

Function factory

Apr 22nd, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- outside function
  2. local function countup(view, x, y, stats, name)
  3.     return function(event)
  4.         if stats[name] < 25 then stats[name] = stats[name] + 1 end
  5.         view.text = stats[name]
  6.         view:setReferencePoint(display.TopLeftReferencePoint)
  7.         view.x, view.y = x, y
  8.     end
  9. end
  10.  
  11. --  in place
  12.     if goalAttack - self.Stats.Attack ~= 0 then
  13.         timer.performWithDelay(100, countup(self.attackText, 194, 153, self.Stats, "Attack"), goalAttack - self.Stats.Attack)
  14.     end
Advertisement
Add Comment
Please, Sign In to add comment