Created
June 6, 2014 16:21
-
-
Save codepaladin/3d554c91ee65fbd27fdb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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