Skip to content

Instantly share code, notes, and snippets.

@codepaladin
Created June 6, 2014 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codepaladin/3d554c91ee65fbd27fdb to your computer and use it in GitHub Desktop.
Save codepaladin/3d554c91ee65fbd27fdb to your computer and use it in GitHub Desktop.
-- update the damage bar
function updateDamageBar()
damageBar.x = currentHealth / 2
damageBar.width = maxHealth - currentHealth
end
-- lower the character's currentHealth
function damageCharacter(damageTaken)
currentHealth = currentHealth - damageTaken
updateDamageBar()
end
-- move the character to the right and apply 25 damage
function moveRight()
if(currentHealth > 0) then damageCharacter(25) end
transition.to( characterGroup, { time=1500, x=(characterGroup.x+100), onComplete = moveLeft} )
end
-- move the character to the left
function moveLeft()
transition.to( characterGroup, { time=1500, x=(characterGroup.x-100), onComplete = moveRight} )
end
moveLeft()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment